Configuring Linux Static DHCP Clients by Sending Host Name

Q. My DHCP server configured to assign static IPs to few Debian / Ubuntu Linux boxes using hostnames. My Windows 2000 and XP client computer sends hostname automatically. How do I send my hostname under Linux using dhcp client?

A. By default, the DHCP server requests the subnet-mask, broadcast-address, time-offset, routers, domain-name, domain-name-servers and host-name options. DHCP client configuration allows you to set a hostname using send host-name “hostname” parameter.

Linux dhcpclient configuration – dhclient.conf

dhclient.conf is a configuration file for DHCP client under Linux:

  • Debian / Ubuntu Linux – /etc/dhcp3/dhclient.conf
  • RHEL / Fedora / CentOS Linux – /etc/sysconfig/network-scripts/ifcfg-eth0 (for 1st DHCP network interface)
WARNING! These examples requires correct hostname.

Debian / Ubuntu Linux DHCP Client Configuration

Open configuration file, enter:
$ sudo vi /etc/dhcp3/dhclient.conf
Set hostname as follows:
send host-name "vivek-laptop";
Save and close the file. Test new settings, enter:
$ sudo dhclient eth0
$ sudo dhclient interface-name

RHEL / CentOS / Fedora Linux DHCP Client Configuration

Open configuration file, enter:
# vi /etc/sysconfig/network-scripts/ifcfg-eth0
Append hostname, enter:
Save and close the file. Restart network service:
# service network restart
Please refer to dhclient.conf man page for more information, enter:
$ man dhclient.conf

🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.

🐧 4 comments so far... add one

CategoryList of Unix and Linux commands
Disk space analyzersdf duf ncdu pydf
File Managementcat cp mkdir tree
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Modern utilitiesbat exa
Network UtilitiesNetHogs dig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg glances gtop jobs killall kill pidof pstree pwdx time vtop
Searchingag grep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
4 comments… add one
  • Gurce Dec 5, 2012 @ 21:47

    Just some additional points when I tried this on Ubuntu 12.10 Server. When editing the “dhclient.conf” file, I also had to comment out the the last two lines (shown below) for the technique above to work:

    send host-name “mypreferredhostname”

    #send host-name = gethostname();

    #send fqdn.fqdn = gethostname();

  • Mr Xhark Mar 21, 2013 @ 14:58

    For CentOS/Redhat 5/6, edit /etc/sysconfig/network file
    and put :


    and finally
    # /etc/init.d/network restart

  • vm-lin Apr 20, 2013 @ 3:36

    i set static ip on ubuntu 12.(client)
    how to send hostname to dns server automatically

  • xcomptuer Aug 19, 2013 @ 2:30

    @Mr Xhark

    In CentOS
    /etc/init.d/network [restart/start] or /sbin/service network [start/restart] does not send the hostname when requesting ip, via dhcp, if the variable DHCP_HOSTNAME is not defined in /etc/sysconfig/network-scripts/ifcfg-ethX (where X is a number)

    /sbin/service NetworkManager [restart/start] does send the hostname, even if not defined in ifcfg-ethX.

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre> for code samples. Still have questions? Post it on our forum