How to install DHCP on Ubuntu

What is DHCP?

Dynamic Host Configuration Protocol (DHCP) is network protocol for automatically assigning TCP/IP information to client machines. Each DHCP client connects to the centrally-located DHCP server which returns that client’s network configuration including IP address, gateway, host name, and DNS servers.

Why do we need DHCP server?

DHCP is useful for fast delivery of client network configuration. When configuring the client system, the administrator can choose DHCP and not have to enter an IP address, netmask, gateway, or DNS servers. The client retrieves this information from the DHCP server. DHCP is also useful if an administrator wants to change the IP addresses of a large number of systems. Instead of reconfiguring all the systems, he can just edit one DHCP configuration file on the server for the new set of IP address. If the DNS servers for an organization changes, the changes are made on the DHCP server, not on the DHCP clients. Once the network is restarted on the clients (or the clients are rebooted), the changes will take effect.

Furthermore, if a laptop or any type of mobile computer is configured for DHCP, it can be moved from office to office without being reconfigured as long as each office has a DHCP server that allows it to connect to the network.

Installing DHCP server

Become a super user

user@server:~# sudo su -

Install DHCP server using apt-get

root@server:~# apt-get install dhcp3-server

Configure the DHCP server. The main Configuration file for DHCP server is /etc/dhcp3/dhcpd.conf. Below is the sample file.

root@server:~# vim /etc/dhcp3/dhcpd.conf
# Sample DHCP Configuration File.
ddns-update-style none;
log-facility local7;
subnet netmask {
  option subnet-mask;
  #Domain name that client should use when resolving host names
  option domain-name ""
  #IP address of DNS server
  option domain-name-servers;
  #IP address of router
  option routers;
  option broadcast-address;
  #IP address of NTP server
  option ntp-servers;
  group GENERAL {
    host HOST1 {
      hardware ethernet 00:0D:29:A9:D0:CB;
    host HOST2 {
      hardware ethernet 00:AC:29:A4:C0:CB;

You need to restart the DHCP daemon to take effect of your new changes.

root@server:~# /etc/init.d/dhcp3-server restart

If the service restarted without any errors, it means you’ve successfully installed and configured the DHCP Server installation for your LAN.