Freitag, 6. Juli 2012

Scheduled reconnect with Pirelli PRGAV4202N Modem


The Pirelli PRGAV4202N is the model often provided by A1 (former Telekom Austria). Some providers tend to limit the IP-lease in their consumer products. In my case A1 limits connections to 24 hours. After 24 hours the connection is cut and the modem must reconnect. This leaves me without an internet connection for a few seconds. This also terminates all my downloads, uploads, VoIP, game connections, etc. So ideally I want this reconnect to occur at some time when I don't care (like e.g. 5 o'clock in the morning). A trivial solution would be to just get up at 5 o'clock once and force the modem to reconnect manually, so that all subsequent reconnects would also occur at roughly 5 o'clock. But this only works as long as there is no other random reconnect which happens every now and then.

How to

This guide requires some linux-based box that is powered on when the reconnect should occur (e.g. an OpenWRT-powered router or a linux-powered home-server).

You need to install the "expect"-script language.

You can use the following script to force your modem to reconnect:


set timeout 1
set cmd {uname -a}

spawn ssh Telek0m@
expect_after eof { exit 0 }

## interact with SSH
expect "yes/no" { send "yes\r" }
expect "password:" { send "<the-password>\r" }

expect "OpenRG> "
send "conf\r"
expect "conf> "
send "set /dev/ppp0/enabled 0\r"
expect "conf> "
send "reconf 1\r"
expect "conf> "
send "set /dev/ppp0/enabled 1\r"
expect "conf> "
send "reconf 1\r"
expect "conf> "
send "exit\r"
expect "OpenRG> "
send "exit\r"

The "Telek0m"-user that is used for the SSH-connection was used in earlier firmwares as universal support-user. As I'm not sure how legal it is to provide the password here, I'll just skip it (you'll find it using a good search engine).

make sure the script is executable

# chmod +x reconnect.exp

and put it in a cronjob

# crontab -e
0 5 * * * /path/to/reconnect.exp

That's it.

Keine Kommentare:

Kommentar veröffentlichen