Reload a router from VBScript or PERL with a HTTP (web) request
If you have HTTP enabled on your router, you can use it to automate router reloads through web requests. To enable HTTP on the router, use the following commands:
The Visual Basic script to reload the router is extremely simple (just save the following lines into a file called reload.vbs):
ip http serverThe ip http access-class configuration command is vital - it limits the access to the web server on your router to well-defined IP addresses.
ip http access-class 90
access-list 90 permit network-management-ip-address
The Visual Basic script to reload the router is extremely simple (just save the following lines into a file called reload.vbs):
Const RouterIP = "10.0.0.1" ' replace with router's IP addressAnd here is the equivalent PERL code for the open source community:
Const EnablePassword = "password" ' replace with enable password
Set WebRq = CreateObject("MSXML2.XMLHTTP")
WebRq.Open "GET","http://" & RouterIP & "/level/15/exec/reload/CR",false,"Username",EnablePassword
WebRq.Send
use LWP::UserAgent;By default, the username specified in the web request is ignored by the router and the password has to be the enable password. Of course, if you change the authentication scheme on the router with the ip http authentication configuration command, you'd use proper username/password pair in the HTTP request.
$routerIP = "10.0.0.1";
$enablePwd = "password";
$ua = LWP::UserAgent->new;
$req = HTTP::Request->new(GET => "http://$routerIP/level/15/exec/reload/CR");
$req->authorization_basic('', $enablePwd);
print $ua->request($req)->as_string;