Menu

Setup DHCP server on ubuntu 14.04


The Dynamic Host Configuration Protocol (DHCP) is a network protocol used to assign IP

 addresses and provide configuration information to devices such as servers, desktops, or 

mobile devices, so they can communicate on a network using the Internet Protocol (IP).

DHCP server on ubuntu 14.04


Before installation, Make sure you have assigned static IP to the server.
Step 1 : Issue the below command to update repository.
root@hackthesec:~$ sudo apt-get update
Step 2 :  Now install isc-dhcp-server package and dependencies.
root@hackthesec:~$ sudo apt-get install isc-dhcp-server -y
Step 3 :  After installing, open /etc/default/isc-dhcp-server file and assign interface.
root@hackthesec:~$ sudo nano /etc/default/isc-dhcp-server
INTERFACES="eth0"

Step 4 :  We need to define below values in dhcpd.conf file located in /etc/dhcp/ directory.
Example:
Network : 192.168.100.0/24Range : 192.168.100.20 ( Starting IP ) – 192.168.100.100 ( Ending IP )Gateway : 192.168.100.1Primary DNS : 192.168.100.5Sec DNS : 8.8.8.8


Take backup copy before making changes to the original file .Better rename the file and create a new one .
root@hackthesec:~$ sudo mv /etc/dhcp/dhcpd.conf /etc/dhcp/dhcpd.conf.org
root@hackthesec:~$ sudo nano /etc/dhcp/dhcpd.conf

and add the below code after making changes as per your network values.

default-lease-time 600;max-lease-time 7200;# If this DHCP server is the official DHCP server for the local# network, the authoritative directive should be uncommented.authoritative;# Use this to send dhcp log messages to a different log file (you also# have to hack syslog.conf to complete the redirection).log-facility local7;
subnet 192.168.100.0 netmask 255.255.255.0 {  #network range 192.168.100.20 192.168.100.100; # Range option domain-name-servers 192.168.100.5, 8.8.8.8; #Pri DNS , Sec DNS option domain-name "hackthesec.co.in"; #Domain name  option routers 192.168.100.1; #Gateway option broadcast-address 192.168.100.255; #Broadcast default-lease-time 600; max-lease-time 7200;}
Step 5 » Now start/restart dhcp service using the below command.
root@hackthesec:~$ sudo service isc-dhcp-server restart


Address Reservation

Sometimes you need to reserve IP to some devices like printers, camera, linux machines etc.
In this case, first you need to find MAC Address of that device and define values in that particular subnet.
For example, Printer with 00:DD:HD:66:55:9B MAC Address has to be assigned with 192.168.100.50 IP. For this, you need to add code like below to that subnet.

subnet 192.168.100.0 netmask 255.255.255.0 {  #network       -  -   -    -   -         max-lease-time 7200;     host printer-finance {                hardware ethernet 00:DD:HD:66:55:9B;                 fixed-address 192.168.100.50;        }       host cam-gate {                hardware ethernet 00:KK:HD:44:55:22;                fixed-address 192.168.100.90;        }}

And restart DHCP service.
root@hackthesec:~$ sudo service isc-dhcp-server restart
Hack The Security
Hack The Security Twitter
Hack The Security Facebook Page

About Author:


I am a Linux Administrator and Security Expert with this site i can help lot's of people about linux knowladge and as per security expert i also intersted about hacking related news.TwitterFacebook

Next
Newer Post
Previous
Older Post

0 comments:

Post a Comment

 
Top