x
ChatBox

Please log in with password to access chatbox.
visitor stats
Index | Back | Reply | New Topic

IP Change Automation

IP change automation on D-Link DSL-G624T
2009-11-22 13:36
pioltelloHello,
I'd like to automate the IP change under my router and i need some help. My ISP doesn't provide static IP, i got a new IP every time i disconnect/reconnect. I set static LAN IP's to write some port forwarding rules. I followed the guide "Basic automation with FF-restart" and "IP under Windows 7 RC", but didn't get luck.
My PC runs Windows 7 and always got this internal IP: 192.168.1.2

Thx in advance!
2009-11-22 21:08
utopia.lvHow do you do "disconnect/reconnect"? Do you connect to the router via HTTP and click on disconnect and reconnect buttons? If yes, then it can be automated by sending HTTP requests with specific URL from the script.
2009-11-23 09:47
pioltelloThanks for reply! Yes, i can connect/disconnect via HTTP: i just go to http://192.168.1.1 and i'm in the router control panel. Then i have to click the connect/disconnect button and my router gets a new ip.
Can you help me to configure the automation under Windows 7 please? Could you paste the code here please? Maybe this could be sticked for future help...
2009-11-23 10:01
utopia.lvI personally have no experience with router automation.
The idea is to find disconnect and reconnect URLs and access them from a script.

See this forum topic for additional info: http://www.utopia.lv/exchange/?do=forum&w=view&pid=16210

Please tell me if you're unable to find the URLs or have problems executing them from a script.
2009-11-23 12:06
pioltelloI read the discussion you linked above and you suggest to use the wget program.
Can't i use curl in a batch file? In this way i've not to install any additional software on my pc...
2009-11-23 12:26
utopia.lvcURL is also okey :).
2009-11-24 19:19
pioltelloSorry but i can't find the URL for the connect/disconnect command. Analysing the HTML code, it seems there's a form sending via POST some infos, but i can't find the real link to execute the connect/disconnect command.

Please help needed.
2009-11-25 10:13
utopia.lvcURL allows to pass POST data with a request.
If you're unable to figure that out, please give me the source code of web page where disconnect and connect buttons are located.

P.S. You can also check if your router allows telnet to port 80. In many cases task automation with telnet commands is easier and more flexible.
2009-11-25 19:35
pioltelloHere it is:

<html><script>var remote_user="admin"; </script></html><html>
<head>
<script>
var HistoryHref="home_wan.html";
var HistoryItem="WAN";
//var nextHrefIP="";
var F5End = 4;//0:fail 1:success 2:programing 3:skipped 4:default
var F5Seg = 4;
var PingDNS = 4;
var PingSvr = 4;
var F5testCount = 0;
var SWFeature="0xE000";
var hostname = "DSL-G624T";
var fwVersion = "V3.10B01T02.EU-A.20070924";
var qosIndex =0;
var voiceState = "1";
function GetQoSState()
{
if(SWFeature == "0x8000" || SWFeature == "0xC000"|| SWFeature == "0xA000" || SWFeature == "0xE000")
return 1;
else
return 0;
}
function GetIPSECState()
{
if(SWFeature == "0x2000" ||SWFeature == "0x6000" || SWFeature == "0xA000" || SWFeature == "0xE000")
return 1;
else
return 0;
}
function GetTR069State()
{
if(SWFeature == "0x4000" || SWFeature == "0x6000" || SWFeature == "0xC000"|| SWFeature == "0xE000")
return 1;
else
return 0;
}
function GetEthWANState()
{
return ethwanState;
}
function GetVoiceState()
{
return voiceState;
}
function GetCheckNum()
{
var modelname,checknum;
if(hostname =="DVA-G2240S" || hostname =="DSL-2650B" ||hostname =="DI-524B" ||hostname =="DVG-G14021S" ||hostname =="DVG-2740B" )
return 4;
if(hostname.substring(0,3) == "DSL")
{
if(hostname.substring(4,5) == "G")
modelname=hostname.substring(5,8);
else
modelname=hostname.substring(4,7);
}
else if(hostname.substring(0,3) == "ASL")
modelname=hostname.substring(5,8);
else if(hostname.substring(0,3) == "AVA")
modelname=hostname.substring(5,6);
checknum = parseInt(modelname.charAt(modelname.length-1));

return checknum;
}

function GetHistoryHref()
{
return HistoryHref;
}
function GetHistoryItem()
{
return HistoryItem;
}
</script>
</head>

<frameset rows="0,*" frameborder="0" framespacing="0">
<frame name="fPanel" src="" scrolling="auto" marginwidth="0" marginheight="0">
<frame name="fInfo" src="../cgi-bin/webcm?getpage=../html/home/home_RelaodHref.htm&var:RelaodHref=&var:aprestart=">
<noframes>
<body bgcolor="#008080">
<p>This page uses frames, but your browser doesn't support them.</p>
</body>
</noframes>
</frameset>
</html>

Thanks
2009-11-25 20:30
utopia.lvThere is no disconnect and connect buttons in the source code you pasted here. It might be in the following document:
http://192.168.1.1/cgi-bin/webcm?getpage=../html/home/home_RelaodHref.htm&var:RelaodHref=&var:aprestart=
2009-11-26 13:23
pioltelloi copied/pasted the code from the page where i click connect/disconnect. That page gives me a blank page.
2009-11-26 16:55
utopia.lvPlease save the complete web page (file -> save page as) and upload it for me somewhere (you can use http://www.2shared.com/).
2009-11-27 06:59
pioltelloOk, done what you wanted. Here is the file:
http://www.2shared.com/file/9479960/b3423771/webcm.html
2009-11-27 08:39
utopia.lvHere is data I extracted from the source files:

CONNECT [POST data]

name="getpage" value="../html/status/status_deviceinfo_deviceinfofile.htm"
name="var:conid" value="encaps0"
name="var:mycon" value="connection0"
name="var:contype" value=""
name="encaps0:settings/manual_conn" value="1"
name="var:judge" value="1"
name="encaps0:pppoa:command/start" value=""

DISCONNECT [POST data]

name="getpage" value="../html/status/status_deviceinfo_deviceinfofile.htm"
name="var:conid" value="encaps0"
name="var:mycon" value="connection0"
name="var:contype" value=""
name="encaps0:settings/manual_conn" value="0"
name="encaps0:pppoa:command/stop" value=""

This data needs to be sent to your router with POST request. If you are going to use cURL program, it will look something like this:

CONNECT
curl -d "getpage=../html/status/status_deviceinfo_deviceinfofile.htm&var:conid=encaps0&var:mycon=connection0&var:contype=&encaps0:settings/manual_conn=1&
var:judge=1&encaps0:pppoa:command/start=" 192.168.1.1/webcm_files/webcm

DISCONNECT
curl -d "getpage=../html/status/status_deviceinfo_deviceinfofile.htm&var:conid=encaps0&var:mycon=connection0&var:contype=&encaps0:settings/manual_conn=0&encaps0:pppoa:command/stop=" 192.168.1.1/webcm_files/webcm

I am not sure 192.168.1.1/webcm_files/webcm is correct link to send POST request to, because you did not specify web page URL where connection buttons are displayed. Just append webcm_files/webcm to your real URL and it should work.

If your router requires authorization, add your login data to the URL in the following form:
username:password@192.168.1.1/.......
Or you can try appending -u username:password to the cURL script.

Warm regards,
Utopia
2009-11-30 18:47
pioltelloThe page where the buttons are located has the address http://192.168.1.1/cgi-bin/webcm.
Now, should i put the code you wrote in a .bat file?
2009-12-03 08:02
utopia.lvIt looks that correct link to request from cURL is "192.168.1.1/cgi-bin/webcm".
Before making batch file, make sure connect & disconnect commands work properly from the command line (start -> run -> cmd.exe).

DISCONNECT
curl -d "getpage=../html/status/status_deviceinfo_deviceinfofile.htm&var:conid=encaps0&var:mycon=connection0&var:contype=&encaps0:settings/manual_conn=0&encaps0:pppoa:command/stop=" username:password@192.168.1.1/cgi-bin/webcm
CONNECT
curl -d "getpage=../html/status/status_deviceinfo_deviceinfofile.htm&var:conid=encaps0&var:mycon=connection0&var:contype=&encaps0:settings/manual_conn=1&
var:judge=1&encaps0:pppoa:command/start=" username:password@192.168.1.1/cgi-bin/webcm
2009-12-05 10:38
pioltelloI downloaded cURL prompt, double click on curl.exe file and copied-pasted the code you provided. For the disconnection it worked, but not for the connection.
PS: when i run the disconnection code i had to stop the execution with CTRL+PAUSE because curl wasn't doing anything but i couldn't write in the console. With the connection code instead, the control returned to me after curl read the page but the router didn't connect to the internet.