How to install and configure DHCP Server in Linux/Ubuntu

Keywords : DHCP Server, How to install DHCP Server in Linux/Ubuntu, Configure DHCP server in Linux/Ubuntu

In this tutorial I am going to explain How to install and configure DHCP Server in Linux/Ubuntu. You might be thinking what is a DHCP Server? Well..

A DHCP Server is used to assign ip-address to client machines connected in a network. It also reduces the effort to assign ip-address manually.

installation of DHCP Server

Open a terminal and type following command:

$ sudo apt-get install dhcp3-server

Above command will install the DHCP Server in your machine. Now we have to configure it in order to use it.

Configuration of DHCP Server

Step 1: Know on which “interface” you want to set up DHCP Server.

Confused.. ?? 😉 I meant if your machine have two NIC’s then you have to choose one NIC on which you want to configure the DHCP Server. (As if you wat to use your machine as a Router, you’ll have two NICs for that. See : Transform Ubuntu Desktop in a Router)

By default, DHCP Server listens for “eth0”. If you want to change it then open “/etc/default/dhcp3-server” file and look for the line ‘INTERFACES=”eth0”’. Change “eth0” with your interface for example “eth1”.

$ sudo gedit /etc/default/dhcp3-server

INTERFACES=”eth1”

Step 2: Now take a backup of your ‘/etc/dhcp3/dhcpd.conf’ file, in case anything goes wrong.

$ sudo cp /etc/dhcp3/dhcpd.conf /etc/dhcp3/dhcpd.conf.bak

Step 3: Edit ‘dhcpd.conf’ file

$ sudo gedit /etc/dhcp3/dhcpd.conf

Copy and paste following in your opened file:

default-lease-time 600;

max-lease-time 7200;

option subnet-mask 255.255.255.0;

option broadcast-address 192.168.1.255;

option routers 192.168.1.1;

option netbios-name-servers 192.168.1.1;

option domain-name-servers 8.8.8.8, 8.8.4.4;

option domain-name “yourdomainname.com”;

subnet 192.168.1.0 netmask 255.255.255.0 {

range 192.168.1.2 192.168.1.200;

}

You can change these options according your network. Save and exit from this file.

Step 4: Restart DHCP Server

$ sudo /etc/init.d/dhcp3-server restart

Step 5: Connect another machine in your network and

  • you can ping from/to your Ubuntu DHCP server to/from your another machine.

  • You get another machine’s ip in 192.168.1.2 – 192.168.1.200 range.

If yes, cheers .. 🙂 Your DHCP Server is working fine.

There are a lot of settings that you can choose according to your need. For more information please check this (https://help.ubuntu.com/community/dhcp3-server)

Related posts

One Thought to “How to install and configure DHCP Server in Linux/Ubuntu”

Leave a comment....