In many networks with DHCP it is desirable to have predictable IP addresses and hostnames for DHCP clients. This can be accomplished by having the DHCP server hand out IP addresses and set hostnames according to the client’s MAC or hardware address. The method will vary according to the DHCP server in use, but for many home routers with DHCP and DNS built in, it can be accomplished through the web interface to the router.

Home router with DHCP and DNS

The router address can be found by looking at the gateway in the route on the client.

# /sbin/route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface   U     0      0        0 eth0     U     0      0        0 eth0         UG    0      0        0 eth0

In this example, the router is at so the web interface would generally accessed by . There is generally a link in the user interface for the router to display current connections, and this will typically include the current hostname, IP address, and MAC address of each client. With this information one can then navigate to a page allowing the reservation and assignment of IP addresses by MAC address. Consult your router’s documentation or on-line help for details.

Linux DHCP server

The same effect can be accomplished by modifying the DHCP server configuration on a Linux host. For the CentOS dhcp package information similar to that obtained from the router in the home example can be obtained from the dhcpd.leases and a section can then be created in dhcpd.conf (for this CentOS package /var/lib/dhcpd/dhcpd.leases and /etc/dhcpd.conf respectively) to define each host. See the dhcpd and dhcpd.conf man pages for details. You may also want to consider using the group and pool directives. Similar techniques can be used for other software providing a DHCP server.


lease {
  starts 3 2010/11/10 21:46:35;
  ends 4 2010/11/11 03:46:35;
  tstp 4 2010/11/11 03:46:35;
  binding state free;
  hardware ethernet 00:01:08:00:ad:33;


host myhost {
  hardware ethernet 00:01:08:00:ad:33;
  option host-name "myhost";

This page created and maintained by PhilSchaffner. Other Wiki contributors are invited to make corrections, additions, or modifications.