Someone asked me today how they can enable their Linux DHCP clients update DNS with their hostnames. This is is pretty easy, so I figured I would put up this quick guide. The exact method will depend on whether you are using a Debian based system, or Red Hat based.

 

Debian Systems

In debian, you just need to adjust the dhclient config file. For example, on Squeeze it is located at:

/etc/dhcp3/dhclient.conf

Simply add append a line for the hostname to this file:

send host-name "ninja-host";

Do not add the domain name to this value or it will not work.

Once finished, just grab a new lease for you interface. For example, using eth0:

sudo dhclient eth0

 

Red Hat Systems

Red Hat is a little different. On these, you want to edit the NIC configuration script. For example, using eth0 as your NIC, you would edit the following file:

/etc/sysconfig/network-scripts/ifcfg-eth0

Once you have your script open, simply append the following variable:

DHCP_HOSTNAME=vivek-laptop

Then restart your networking

service network restart