DNSmasq DHCP Fixed IP For Ethernet And Wireless Networking

With the current mobility that laptops provide, it may be useful to unplug a laptop from an ethernet cable and take it around the house. If you wish to keep the same IP after switching network interfaces, this code may come in handy. If you're using DNSmasq for DHCP server duties, you can add this to the dnsmasq.conf file:
dhcp-host=00:aa:bb:cc:dd:e0,00:aa:bb:cc:dd:e1,pc0,192.168.0.2
dhcp-host=00:aa:bb:cc:dd:e2,pc1,192.168.0.3
dhcp-host=00:aa:bb:cc:dd:e3,pc2,192.168.0.4

DNSmasq will attribute the same IP, 192.168.0.2, to the MAC addresses 00:aa:bb:cc:dd:e0 and 00:aa:bb:cc:dd:e1, when one of the devices requests one. Be careful though, as if you're using the devices in different machines afterwards, you will loose connectivity in one of them.
The two other lines are normal dhcp-host lines, with only the single MAC address. The pc* parameter is the name that the DHCP server will assign to the machines identified by the respective MAC address.

No comments:

Post a Comment