I have a voyage 2.6.38 machine running DNSMASQ for a DHCP server and I would like to get the hostnames of the clients that acquire DHCP leases. How would I go about doing this?

2 Answers 2


If the host sends its name you can retrieve it from DNS. If you know its IP address you just do a reverse lookup on the IP address. One of these commands should work (use the host's IP address in place of


You can retrieve a list of all leases including the name provided if any from your dhcp.leases file. Its location will vary depending on the distribution you use. Ubuntu uses /var/lib/misc/dnsmasq.leases while OpenWrt uses /tmp/dhcp.leases. If you have a man page for dnsmasq, then the command man dnsmasq should mention the location of leases file at the end of the document. You can override this location by specifying the dhcp-leasefile option in your configuration or command line. The command line options -l or --dhcp-leasfile= options can be used to do this.

The fields in the leasefile are timestamp, mac address, ip address, hostname, and client id. The client is not required to send a hostname or client id.

If logging has been enabled, you can look at the syslog to see which leases have been negotiated. All DHCP negotiations should be logged. If you have long lease times, the negotiations will be not be frequent. Clients should start negotiating a renewal at half the lease time. It is best to set the lease time at least twice the period you can reasonably expect your DHCP server to be down.

  • /var/tmp/dnsmasq.leases was what I was after, thanks! Nov 7, 2011 at 21:20

It's upto the client whether it wants to send them. In the initial request it can be configured to send the hostname. Most desktop/server DHCP clients do this embedded one often do not.

  • That's fine with me, but if the client did send their hostname, whereabouts could I find it? In some logs? Or some other file somewhere? Nov 7, 2011 at 2:23
  • That would depend on what DHCP server software you are running, ISC DHCPd?
    – ewanm89
    Nov 7, 2011 at 2:34
  • I am running DNSMASQ, sorry, I'll update the question with that information. Nov 7, 2011 at 2:46
  • okay, the manual is a bit sketchy on what it logs for the DHCP part of it (it's a DNS resolver daemon really). However you could turn on the logging and see?
    – ewanm89
    Nov 7, 2011 at 3:10
  • 1
    It looks like it logs the hostname with each DHCPACK in /var/log/daemon.log. Thanks! Care to edit that into your answer? Nov 7, 2011 at 3:47

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .