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?
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 184.108.40.206):
host 220.127.116.11 nslookup 18.104.22.168
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
--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.