with the attached code and
and with the following command the router will re-lease its IP number:
./telnettorouter.sh routeripnumber admin yourrouterpassword /sbin/udhcpc
ie:
./telnettorouter.sh 192.168.1.1 admin abc123 /sbin/udhcpc
if the ip number of the router is 192.168.1.1 and the router password is abc123
and with the following command the router will reboot:
./telnettorouter.sh routeripnumber admin yourrouterpassword /sbin/reboot
this works for an ASUS RT-AC68U **), most likely works for most newer ASUS roter models.
*) the ASUS userid is hardwired to be admin
**) this one supports 2 WAN connections and automatic switching if you have 2 internet providers..
Karl
ps with
instead of /sbin/reboot your could use :
"cat /tmp/syslog.log | grep -v 'Dec 31' | grep -v '192.168' | grep ' dhcp ' | tail -1"
to get the last dhcp record that shows the current IP number and the ip number of the first router on the internet:
Jan 21 00:52:39 dhcp client: bound 71.11.216.221 via 71.11.216.1 during 20479 seconds.
- Code: Select all
### save this file to your disk, with filename telnettorouter.sh and delete this line from the file and do a "chmod +x telnettorouter.sh" to enable execution
#!/usr/bin/expect
set theReturn \r
set timeout 20
set ipNnumber [lindex $argv 0 ]
set userID [lindex $argv 1 ]
set password [lindex $argv 2 ]
set routerCommand [lindex $argv 3 ]
spawn telnet $ipNnumber
expect "*?ogin:" { send "$userID$theReturn" }
expect "*?assword:" { send "$password$theReturn" }
expect "*?#" {send "$theReturn" }
expect "*?#" {send "$routerCommand$theReturn" }
expect "*?#" {send "$theReturn" }