Wake on lan hosts file

networkingwake-on-lan

Is there any such thing as a file linking MAC addresses to IP addresses / DNS names for use with wakeonlan on Linux? Something like this:

$ cat /etc/machosts
00:1f:d0:34:e0:ea 192.168.0.5
00:1f:d0:34:a1:06 192.168.0.7
$ cat /etc/hosts
192.168.0.5 mypc
$ wakeonlan mypc

Thanks.

Best Answer

Some minor bash:

$ cat /path/to/machosts
macs[mypc1]=00:1f:d0:34:e0:ea 
macs[mypc2]=00:1f:d0:34:a1:06 

$ cat wakeonlan.sh
#!/bin/bash

. /path/to/machosts

echo wakeonlan ${macs[$1]}

$ ./wakeonlan.sh mypc1
wakeonlan 00:1f:d0:34:a1:06

This uses bash arrays: http://tldp.org/LDP/abs/html/arrays.html

The unix.stackexchange.com site can probably help more with doing this script and the one that processes arp output.