Here is a method you can use to make 100 % sure that you don't get over billed for night time usage plan like HOME500.
This procedure assumes that your router/modem is connected to one Ethernet card in your machine.
This was tested on SmartAX MT882 Router, Windows XP, and Ubuntu Edgy.
For Linux (Ubuntu Edgy Eft)
1 RECOMMENDED:- configure your modem to autodial
2 install expect
3 install kalarm in gnome or KDE if it is not already installed, and make sure it run at startup or add the daemon to sessions
4 RECOMMENDED:- Disable internet time server updates (NTP)
sudo update-rc.d ntp-server remove
5 create a file
router.exp with the following contents
| Code: |
#!/usr/bin/expect -f
set timeout 20
set echo off
# router user name
set name admin
# router password
set pass admin
# your router IP address
set routerip 192.168.1.1
# Read command as arguments to this script
set switch [ lrange $argv 0 1]
if {$switch == "" } {send_user "usage:\n\trouter ON\n\trouter OFF\n\trouter validcommand\n\n"
exit
} else {
if {$switch == "ON"} {set routercmd "pppoe set transport 1 autoconnect enabled\r"
} else {
if {$switch == "on"} {set routercmd "pppoe set transport 1 autoconnect enabled\r"
} else {
if {$switch == "OFF"} {set routercmd "pppoe set transport 1 disabled\r"
} else {
if {$switch == "off"} {set routercmd "pppoe set transport 1 disabled\r"
} else {
set switch [ lrange $argv 0 9]
set routercmd "$switch\r"
}}}}
}
send_user "sending router:- $switch \n"
#other useful commands
# set routercmd "pppoe list transports\r"
# set routercmd "pppoe show transport 1\r"
# set routercmd "pppoe list transports\r"
# start telnet
spawn telnet $routerip
# send username & password
expect "Login: "
send "$name\r"
expect "Password: "
send "$pass\r"
expect -i "--> "
send $routercmd
send '^]'
expect "telnet> "
send "close\r"
send_user "\nDone!\n"
exit |
6. Enter your router IP, router username, router password in the script
NOTE:(if you have some other router change the script to respond according to the menu that you get while you telnet your router)
7. Schedule the following commands in kalarm to run in terminal
| Code: |
/your_script_location/./router.exp OFF |
1:50am and 7:50am ( or fancy your time ! )
| Code: |
/your_script_location/./router.exp ON |
2:10am ( or fancy your time ! )
! be careful with the schedules and make sure that you test it
For Windows XP
This method is safer than using a dialer like the one in DAP because in XP there is a good probability that things can crash.
1) RECOMMENDED:- configure your modem to autodial
2) download TS10 from
www.winsite.com/bin/In...0000000873
3) create two text files
enable.txt
| Code: |
192.168.1.1
WAIT "Login: "
SEND "admin\m"
WAIT "Password: "
SEND "admin\m"
WAIT "--> "
SEND "pppoe set transport 1 autoconnect enabled\m" |
disable.txt
| Code: |
192.168.1.1
WAIT "Login: "
SEND "admin\m"
WAIT "Password: "
SEND "admin\m"
WAIT "--> "
SEND "pppoe set transport 1 disabled\m" |
4) create two .bat files (open notepad and save as "routerON.bat" and "routerOFF.bat")
with the following contents
routerON.bat
| Code: |
chdir C:\RouterSwitch
c:
TST10 /r:enable.txt /o:last_log.txt |
routerOFF.bat
| Code: |
chdir C:\RouterSwitch
c:
TST10 /r:disable.txt /o:last_log.txt
|
5) Create an empty file called last_log.txt to diagnose output of the last run script.Save all the files TST10.exe,enable.txt,disable.txt,routerON.bat,routerOFF.bat
in C:\RouterSwitch
6) schedule the routerOFF.bat to run 1:50am and 7:50am (! or fancy your time )
schedule the routerON.bat to run 2:10am (! or fancy ur time )
7) RECOMMENDED :- to shutdown your computer you don't need to trust a third party app , forced shutdown is probably more successful in different conditions
to do that create a file
shut.bat with the following line
| Code: |
shutdown -f -s -t 30 |
and schedule to run at
your time
this will display a 30 sec warning to all users logged in to your computer
(make sure that u run the scripts once, and test it and make sure your firewall and/or anti virus remembers the settings)
For dynamic IP users (eg-HOME500)
whenever you wanna change your external IP,
(that is disconnect and reconnect)
when autodial is enabled in router you dont need to reach for router switch.
Just run this at terminal or command prompt
| Quote: |
in linux
./router.exp OFF
./router.exp ON
in windows
routerOFF
routerON
|
[NOTE:- in case of power failure or modem restart, you will still be in automatically connected after disconnected by routerOFF.bat in windows
or ./router.exp OFF in linux]
A worst case scenario:
just a good UPS will save you
router OFF at 7:55am (BSNL TIME

)
PC shutdown at 7:56am (BSNL TIME )
power fluctuation or modem restart at 7:57am (BSNL TIME )

modem has LAN link even after PC shutdown

your router gets auto connected
You will be charged for
