I have configured dnsmasq to dish out 10.0.0.* addresses to hosts on an ethernet LAN. The hosts on this network request static IP addresses using DHCP from the dnsmasq server running on They also have wifi access to a router in order to access the internet. E.g. host on has these entries in /etc/dhcpcd.conf:

### Wifi-router
interface wlan0
static ip_address=
static routers=

### Ethernet Switch
interface eth0
static ip_address=
static domain_name_servers= ### Where dnsmasq runs

Now, I'd like dnsmasq to automatically act as a DNS server for these hosts so they can communicate to each other by name. E.g. if host at has hostname 'node2', then one would be able to ssh from any host in this network to with e.g. ssh user@node2.

My question is, how can I configure dnsmasq to cache the name of each host automatically? I know you can add entries to /etc/hosts on the machine where dnsmasq runs and apply the expand-hosts option in /etc/dnsmasq.conf, but I don't want to maintain such an additional list -- I'd prefer to just set the hostname on each individual host and let that be the SSOT on how they are named. How can I set that up?

Here is my /etc/dnsmasq.conf file.


### Upstream DNS servers

The problem is that you are specifying a static address on the client. From man 5 dhcpcd.conf:

             Configures a static value.  If you set ip_address then dhcpcd
             will not attempt to obtain a lease and will just use the value
             for the address with an infinite lease time.

Thus dnsmasq never receives a DHCPREQUEST and is never aware of the client's existence.

There are two options here:

  • Assign fixed addresses from the DHCP server. dnsmasq allows you to match on MAC address, client ID, or other custom tags - MAC address is typically used. You'd add a line such as:


    and remove your static address on the client side.

  • Or, use the dhcpcd request or inform option instead, which:

         request [address]
                 Request the address in the DHCP DISCOVER message.  There is no
                 guarantee this is the address the DHCP server will actually give.
                 If no address is given then the first address currently assigned
                 to the interface is used.
         inform [address[/cidr[/broadcast_address]]]
                 Behaves like request as above, but sends a DHCP INFORM instead of
                 DISCOVER/REQUEST.  This does not get a lease as such, just
                 notifies the DHCP server of the address in use.  You should also
                 include the optional cidr network number in case the address is
                 not already configured on the interface.  dhcpcd remains running
                 and pretends it has an infinite lease.  dhcpcd will not de-
                 configure the interface when it exits.  If dhcpcd fails to
                 contact a DHCP server then it returns a failure instead of
                 falling back on IPv4LL.

Generally, I'd recommeng assigning static addresses from the server, as it minimises the chance of clashes. If you merely have a preferred address and don't mind it changing if it's already in use, using request from the client might be alright. inform should generally be considered dangerous, as it risks clashes.

  • This is super useful info. I had mistakenly believed that settings static ip_address=xxx meant that dhcpcd would send out a request to a dhcp-server and iff it were free would it be assigned that address. I now understand this syntax to mean that the device is simply assigning itself that address, regardless of other devices (hence, this option is prone to clashes). I tried following your suggestion to switch this to request [ip_address] on my hosts. Unfortunately, I'm now getting this problem where dnsmasq asigns ALL of my hosts the same address ( :( – Magnus Oct 13 '19 at 21:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.