Get dnsmasq to automatically register hostnames in its DHCP network on its DNS

Solution 1:

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:

    dhcp-host=00:53:00:11:22:33:10.0.0.2
    

    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.