Script to change router config

Sysem

Expert Member
Joined
Mar 26, 2009
Messages
1,891
Reaction score
5
My dad has 2 accounts for his ADSL. When he runs out of cap on one account, he has to switch over to the another. However, I regularly get phone calls/emails asking for help as he cannot remember how to do it on the router. So I thought, "Why not make a little script/batch file that changes it for him with a simple click?". But I have no idea where to start. Any tips on trying to do this? The router is a D'link 2640 and all the config is changed through a browser.

Thanks,
Sysem
 
I did something like this for my billion and later my netgear routers. The method will work with pretty much any router that has a web interface since this method uses automated web calls... The trick.. however, is figuring out (by manually going through the config on your router) how your calls should look. Pretty much generic process would be:

1. get curl HERE ( i assume you on windows cause you mention batch scripts )
2. write a batch script that uses command line curl to call URL's in order. Probably:

1. Login - login to your router by calling e.g. curl http://your_username:[email protected]/
2. Now the router has you in session and you can call pages behind the login.
3. Call the page where you would the ADSL logins details (you can get this by using the address in your browser when your on that page.) ... e.g. curl http://192.168.0.1/somedir/somescriptshowingadsldetailsonyourrouter?blahblah


4. This is the tricky part... you need to check the source of the page and see how the variables in the username and password fields are sent. I dunno your tech prowess, but you basically need to check if the page makes a GET or POST request to the router to update the details. without getting into detail, please post the source code ( browser right-click view source) of the page on your router where you would change the details and I will tell you how to make that final CURL call to change them.
 
Thanks, looks just like what I needed. I should be able to get this going, got programming experience.
 
Top
Sign up to the MyBroadband newsletter
X