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:
- 30 Handy Bash Shell Aliases For Linux / Unix / Mac OS X
- Top 30 Nmap Command Examples For Sys/Network Admins
- 25 PHP Security Best Practices For Sys Admins
- 20 Linux System Monitoring Tools Every SysAdmin Should Know
- 20 Linux Server Hardening Security Tips
- Linux: 20 Iptables Examples For New SysAdmins
- Top 20 OpenSSH Server Best Security Practices
- Top 20 Nginx WebServer Best Security Practices
- 20 Examples: Make Sure Unix / Linux Configuration Files Are Free From Syntax Errors
- 15 Greatest Open Source Terminal Applications Of 2012

- My 10 UNIX Command Line Mistakes
- Top 10 Open Source Web-Based Project Management Software
- Top 5 Email Client For Linux, Mac OS X, and Windows Users
- The Novice Guide To Buying A Linux Laptop













{ 3 comments… read them below or add one }
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();
For CentOS/Redhat 5/6, edit /etc/sysconfig/network file
and put :
HOSTNAME=myhostnamehere
and finally
# /etc/init.d/network restart
i set static ip on ubuntu 12.(client)
how to send hostname to dns server automatically
thanks