Assigning Static IPv4 and IPv6 Private Addresses using Dnsmasq
- series
- Hacking
- tags
- #dnsmasq #ipv6 #ipv4 #networking #dual-stack #asus #tomato #router #dhcp
- categories
- Technology Tutorial
- published
- reading time
- 2 minutes
On my home LAN I’m using a Shibby build of Tomato running Dnsmasq v2.61 on two of my ASUS RT-N66U routers.
I wanted my routers (namely Dnsmasq) to assign both static IPv4 and IPv6 private addresses to each of my devices in order to set-up a dual-stack network, and experiment more with IPv6.
I browsed forums, mailing lists, blogs, and man pages to no avail but whilst experimenting I managed to find a configuration that worked.
In my dnsmasq.conf, I added the following lines:
dhcp-range=<<Desired IPv6 Subnet>>,static,24h
enable-ra
and then added the following two lines for each device:
dhcp-host=<<Device MAC Address>,<<Desired Hostname>>,<<Desired IPv4 Address>>,<<Lease Time>>
dhcp-host=id:<<Device Client ID>,<<Desired Hostname>>,[<<Desired IPv6 Address>>],<<Lease Time>>
If you need help with what IPv6 subnet range to use, you can get a subnet, range and mask randomly generated for you here: http://v6.ponderworthy.com.
And of course for more information on what each configuration flag does, there is the man page for Dnsmasq here.
Dnsmasq needs the MAC address as a way of identifying devices to give IPv4 addresses to, and the Client ID as a way of identifying devices/interfaces to give IPv6 addresses to. I had a hard time finding out each devices client ID and ended up adding the configuration flag “log-dhcp” to Dnsmasq conf file, then firing off dhclient requests from each device which made their respective client ID’s show up in the Dnsmasq logs.
One last thing I noticed was that in line with the advice on the Dnsmasq man page, I should have been able to put each devices’ set of IPv4 and IPv6 addresses into one dhcp-host flag but unfortunately that didn’t seem to work for me.
Well, now that I have it working, I can sleep soundly.
P/S The version of Shibby that I’m running is v1.28.0000 MIPSR2-104 K26 USB Mega-VPN-64K
Comments