Several months ago I finally got the (WOL) Wake On Lan feature of my RTL8111/8168B NIC card working. The problem was that a new driver (other than the provided by Debian) and a special PCI configuration was needed.
The other problem I had to deal with was the ADSL Router (Comtrend HG532c, The one provided by the Spanish ISP Jazztel) configuration:
- Open the required port: This was an easy one just opening the 7 a 9 port and forwarding them to the server we want to WOL from the internet
- Make the router remember the server’s tuple MAC/IP address. That was easy too, but some manual work was needed as when router is restarted the ARP table is flushed. 🙁
In my current job I had to change recently some configuration and restart more than 600 IP phones. To perform such titanic task I created a quick and dirty script using expect. It worked like a charm and made me think about automatize the way I set the ARP table in my Comtrend HG532c ADSL router.
The scripts is very easy to understand. It just simulates a Telnet session with your router:
- Login and password
- Set the required MAC/IP tuple
- Displays the ARP table
Here you are:
#!/usr/bin/expect -f set timeout 10 set env(TERM) set router "router" #your router's dns name or IP set login "admin" #your router's login. admin is the default set password "admin" #your router's password. admin is the default set ip "192.168.1.2" #your server's IP address (not the dns name) set mac "2f:1e:8a:84:2a:f9" #your server's MAC spawn telnet $router expect "Login: " send -- "$login\r" expect "Password: " send -- "$password\r" expect "ATP>" send "sh\r" expect "# " send "arp -s $ip $mac\r" expect "# " ## check that all is right send "arp -a\r" expect "# "
The output must be similar to:
juan@mediacenter:~/bin$ ./ActualizarTablaArpRouterADSL.sh spawn telnet router Trying 192.168.1.1... Connected to router. Escape character is '^]'. ------------------------------- -----Welcome to ATP Cli------ ------------------------------- Login: admin Password: ATP>sh BusyBox vv1.9.1 (2011-05-25 16:23:47 CST) built-in shell (ash) Enter 'help' for a list of built-in commands. # arp -s 192.168.1.2 00:1e:8c:84:2a:f9 # arp -a ? (192.168.1.2) at 2F:1E:8A:84:2A:F9 [ether] PERM on br0
As can be seen in the last line the router have set the ARP entry as permanent…. permanent till router next restart. 🙁 But at least every time this script is run the ARP is set automagically 🙂
The next thing to do is to put this script in a crontab job, /etc/rc.local, etc of one of your servers. This way every time it runs you will be sure that you can restart your server from the internet.
My decision was add a line in my server’s /etc/rc.local file like this:
#### Sets the MAC/IP tuple in ADSL router for WOL from internet /path/to/ActualizarTablaArpRouterADSL.sh |mail -s "`hostname` MAC para el WOL" firstname.lastname@example.org
This has 2 added benefits:
- I will know when my server is started
- I will know that my router configuration is ready for wake on lan
The last step is have at least to ways to start your computer from the internet. Mine are:
- Online Wake-On-LAN web page.
- Wol Wake on Lan Wan for my Android phone.
I have created a github project: expect-update-arp-table-ADSL-router-for-wol (just in case other features can be added later) where you can download also the source code.
Thanks a lot for that one I’d been telneting to portforward my Router before and ATP just needs some extra steps. Thanks.
Happy it works for you. Enjoy! 🙂