Configuring Linux Static DHCP Clients by Sending Host Name

by on February 19, 2008 · 3 comments· last updated at February 19, 2008

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:
DHCP_HOSTNAME=vivek-laptop
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



You should follow me on twitter here or grab rss feed to keep track of new changes.

Featured Articles:

{ 3 comments… read them below or add one }

1 Gurce December 5, 2012 at 9:47 pm

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();

Reply

2 Mr Xhark March 21, 2013 at 2:58 pm

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

HOSTNAME=myhostnamehere

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

Reply

3 vm-lin April 20, 2013 at 3:36 am

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

Reply

Leave a Comment

You can use these HTML tags and attributes for your code and commands: <strong> <em> <ol> <li> <u> <ul> <kbd> <blockquote> <pre> <a href="" title="">

Tagged as: , , , , , , , , ,

Previous Faq:

Next Faq: