How to send a client’s hostname to the DHCP server

In contrast to Ubuntu (or even Microsoft Windows) default installations of Fedora do not send the client’s hostname to the DHCP server.

To change this behaviour, add a DHCP_HOSTNAME variable to your /etc/sysconfig/network-scripts/ifcfg-eth0 file (eth0 being your NIC’s interface name):

UUID="616426f3-ac0b-4a4a-9221-62a0055bfb07"
NM_CONTROLLED="yes"
NETBOOT="yes"
BOOTPROTO="dhcp"
DHCP_HOSTNAME="MyFedoraBox"
DEVICE="eth0"
TYPE="Ethernet"
ONBOOT=yes
NAME="DHCP"
HWADDR=00:25:22:4A:3F:F2
DEFROUTE=yes
PEERDNS=yes
PEERROUTES=yes
IPV4_FAILURE_FATAL=yes
IPV6INIT=no
USERS=user

Of course, this only works if you actually get your IP address via DHCP (since the DHCP server hands off the hostname to the DNS server). If you use a static IP configuration, nsupdate can be used to dynamically update the DNS server records. Examples and instructions on how to use nsupdate can be found at http://linux.yyz.us/nsupdate/ or http://dijks.wordpress.com/2012/07/17/register-a-hostnames-static-ip-with-your-corporate-dns-server/.

2 thoughts on “How to send a client’s hostname to the DHCP server

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.