I'm building application that needs the hosting machine to change the IP every 30 minutes, can I do it programmatically without 3rd party applications?
Python is preferable, Java is welcome too.
I'm building application that needs the hosting machine to change the IP every 30 minutes, can I do it programmatically without 3rd party applications?
Python is preferable, Java is welcome too.
If you want to change your external (Internet) IP address and if your machine is connected to the internet via dsl, and your ISP assigns you a dynamic IP, you can reboot your router (actually your dsl modem, but it's built into the router if you don't have an ages-old model) to get a new IP.
Rebooting the router programmatically can in theory be achieved with sending it a small SNMP packet telling it to reboot itself - given that the router follows protocol and correctly interprets the packet, and there's no firewall or other filter that blocks the SNMP message between you and the router.
In the common case, the SNMP OID to set would be 1.3.6.1.2.1.69.1.1.3 - you can do that with any language that has a SNMP library, there's pySNMP for python for example. Depending on your router model, it can be that you need a different OID or it doesn't have a way of being reset via SNMP at all.
Assuming your router ip is 192.168.0.1 and it accepts the default reset OID, something like this should work with pySNMP:
from pysnmp.entity.rfc3413.oneliner import cmdgen
from pysnmp.proto import rfc1902
cmdgen.CommandGenerator().setCmd(
cmdgen.CommunityData('my-agent', 'public', 1),
cmdgen.UdpTransportTarget(('192.168.0.1', 161)),
((1,3,6,1,2,1,69,1,1,3,0), rfc1902.Integer(1))
)