mac ddns for wake on lan
Carl Karsten
carl at personnelware.com
Mon Dec 17 14:33:39 UTC 2007
I want to be able to use Wake On Lan without having to remember mac addresses.
So I was thinking I could add mac to the ddns update that dhcpd does. maybe add
a TXT record each time, and then the WOL program can get the mac from a dns query.
How doable is this? Looking at my dhcpd.conf I have no idea where to start.
Carl K
# dhcpd.conf
# Dynamic DNS - update the server
ddns-updates on;
ddns-update-style interim;
do-forward-updates on;
ddns-domainname "personnelware.com";
ddns-rev-domainname "in-addr.arpa.";
update-static-leases on;
# ddns-ttl 7200;
key DHCP_UPDATER {
algorithm HMAC-MD5.SIG-ALG.REG.INT;
secret ZiO1XpvhIDVLRsvnBk9+Qw==;
};
zone personnelware.com. {
primary localhost;
key DHCP_UPDATER;
}
zone 1.168.192.in-addr.arpa. {
primary localhost;
key DHCP_UPDATER;
}
# wol.py
"""
The data that is contained in a Magic Packet is the defined constant as
represented in hexadecimal: FF FF FF FF FF FF followed by sixteen
repetitions of the target computer's MAC address, possibly followed
by a four or six byte password.
"""
import socket, sys
def wake_on_lan(ether_addr):
hw_addr=ether_addr.replace(':','').decode('hex')
msg='\xff'*6+hw_addr*16
s=socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1)
s.sendto(msg, ('<broadcast>', 9))
s.close()
wake_on_lan(sys.argv[1])
More information about the dhcp-users
mailing list