- Computers & Software»
- Computer How-Tos & Tutorials
DHCP Server installation and configuration in UBUNTU
What is dhcp server ?
In a large network it is not feasible to assign IP addresses to all the computers manually. DHCP server provides IP addresses to the clients which need it. When a client needs IP address it sends request to the DHCP server in the network. DHCP server checks availablity of IP address in its pool. If free IP adress is available then it assigns that IP address to the client which has requested for it. DHCP server may provide lease time. Once the lease time is over the client has to go for another IP address or the same if it is still free. DHCP server maintains the record of all the clients.
Why UBUNTU ?
UBUNTU is an open source.So many powerful tools are available in it. They can be easily configured and used. Installation is very easy. The interface of UBUNTU is very attractive and very familiar. UBUNTU is available with server and desktop edition.
Before Installing dhcp server ...
First install UBUNTU in the server or computer with the required configuration. UBUNTU 14 LTS is better than its previous releases. Once the OS is installed make sure to update UBUNTU. For that user must be the root or super use. For this follow the following commands:
It will ask for the password. Enter the password and the prompt will comeback again.
Now type the following command
nareshbaba # sudo apt-get update
and the update will start
Before proceeding for dhcp server first we have to setup network. On the right top corner click on "System Setting", then select wired connection. The network dialouge box will open. In that box got to IPv4 and give IP address, subnet and DNS servers. Finally close it and restart the network service or use the following command:
nareshbaba#service networking restart
Now check whether ip is set or not. Issue the following command:
Installation of DHCP server
Once the Network is configured, we can proceed for installation of dhcp server. This tutorial shows how to install dhcp server with internet connection. So many dhcp packages are available but, we will use isc-dhcp-server. For installation issue the following commands:
nareshbaba#apt-get install isc-dhcp-server
The above command will ask for confirmation. Press 'Y' or 'y'.
Before this be sure to run "apt-get update"
Configuring DHCP server
Once isc-dhcp-server installation is over we have to do some configuration. Issue the following command:
Now editor will open. Find for INTERFACES and modify it as follows:
Once the change is made, press "CTRL+O", it will ask for confirmation to save the changes. Press y. Then press "CTRL+X", which will exit the editor and the prompt will come back.
Here we are assuming that isc-dhcp-server will use eth0 interfaces to lease IP addresses to the clients.
Now issue the following command:
nareshbaba#cp /etc/dhcp/dhcpd.conf /etc/dhcp/dhcpd.conf.backup
The above command will create a back up of original dhcpd.conf as dhcpd.conf.backup
Now issue the following command:
Editor will open. Now just to avoid any type of confusion delete everything in that file. and write the following code:
subnet 22.214.171.124 netmask 255.255.252.0
range 126.96.36.199 188.8.131.52;
option routers 184.108.40.206;
option domain-name-server 220.127.116.11 18.104.22.168;
Save the file and exit. In the above code, the adrees pool consists of all the IP addresses in the range 22.214.171.124 to 126.96.36.199. From this pool IP addresses will be provided to the clients. Gate is given as 188.8.131.52 and DNS servers are 8.8.8. and 184.108.40.206 which are open DNS servers by google.
Start/Stop DHCP server
To start the DHCP server issue the following command:
nareshbaba# service isc-dhcp-server start
To stop the server
nareshbaba#service isc-dhcp-server stop
To check the status of DHCP server
nareshbaba#service isc-dhcp-server status
This tutorial shows how to configure a simple DHCP server. Apart from the the configuration of the server can be enhanced by adding more entities in it like leased time, mac based ip authentication etcc.
1. Before installing the software first update apt-get by the command "apt-get update"
2. The ip address of the interface should in the same range of subnet/mask as used in dhcpd.conf