Install DHCP Server in Ubuntu 16

Download as pdf or txt
Download as pdf or txt
You are on page 1of 17

12/6/2016 Install DHCP Server in Ubuntu 16.

04 - OSTechNix

Home
Open Source
Technology
Linux
Unix

Download Free Videos and EBooks

Backup tools
Cloud
Database
Directory servers
Mobile
Reviews
Security
Tips and Tricks
Trouble shooting
Virtualization

COMMAND LINE UTILITIES / FOLLOW:     


DEBIAN / FAQ / LINUX BASICS /
LINUX DISTRIBUTIONS / TROUBLE
SHOOTING / UBUNTU TO SEARCH, TYPE AND HIT ENTER

Install DHCP FOLLOW US ON FACEBOOK

Server in
Ubuntu 16.04
BY SK · AUGUST 4, 2016

DHCP, abbreviation of SHARE

Dynamic Host Control


Free eBook: "The Network Security0Test Lab: A Step-by-Step Guide ($40 Value)
Protocol, is a network
https://www.ostechnix.com/install-dhcp-server-in-ubuntu-16-04/ 1/17
12/6/2016 Install DHCP Server in Ubuntu 16.04 - OSTechNix

protocol that assigns IP 


addresses automatically
2
to client systems in the
network. This reduces 
the tedious task of
0
manually assigning IP
addresses in a large 
network that has 2
hundreds of systems.
We can define the IP 
range (Scopes) in the
DHCP server, and
distribute them across
the network. The client
systems in the network
will automatically get
the IP address.
FOLLOW US ON GOOGLE PLUS
In this tutorial, we will
see how to install DHCP
server in Ubuntu 16.04 FOLLOW US ON TWITTER
LTS server, and My Tweets
configure the DHCP
clients.

  
Install
How To Migrate System Settings And
DHCP Data From Old System To Newly Installed
Ubuntu System
Server in
How To Find And Delete Files Older Than
Ubuntu X Days In Linux

16.04 LTS How To Find Largest And Smallest


Directories And Files In Linux
server
Remove Your Internet Presence
For the purpose of this Completely In Minutes
Free eBook:
tutorial,"The Network
I will be using Security Test Lab: A Step-by-Step Guide ($40 Value)

https://www.ostechnix.com/install-dhcp-server-in-ubuntu-16-04/ 2/17
12/6/2016 Install DHCP Server in Ubuntu 16.04 - OSTechNix

the following system as How To Find Out Maximum Supported


RAM In Linux
DHCP server.

My DHCP Server:

OS – Ubuntu 16.04
LTS 64 bit
IP Address –
192.168.1.105/24
Hostname –
ubuntuserver.ostechnix.lan

Open Terminal and run


the following command
to install DHCP server:

sudo  apt­get 
install  isc­
dhcp­server

Install DHCP server in Ubuntu

DHCP server has been


installed. Now, let us go
further and configure it
to suit our needs.

Configure
DHCP
Free eBook: "The Network Security Test Lab: A Step-by-Step Guide ($40 Value)

https://www.ostechnix.com/install-dhcp-server-in-ubuntu-16-04/ 3/17
12/6/2016 Install DHCP Server in Ubuntu 16.04 - OSTechNix

server
The default
configuration file of
DHCP server
is  /etc/default/isc-
dhcp-server. We need
to edit and modify it as
per our requirements.

If you have more than


one Network interface
card in your DHCP
server, you need  to
mention on which
interface should the
DHCP server serve DHCP
requests.

As I have only one NIC in


my server, I assigned
‘enp0s3’ as the listening
interface. Here,  enp0s3
is network card’s name.

To do so, edit
/etc/default/isc-dhcp-
server  configuration
file:

sudo vi 
/etc/default/
isc­dhcp­
server

Assign the network


Free eBook: "The Network Security Test Lab: A Step-by-Step Guide ($40 Value)
interface:

https://www.ostechnix.com/install-dhcp-server-in-ubuntu-16-04/ 4/17
12/6/2016 Install DHCP Server in Ubuntu 16.04 - OSTechNix

[...] 
INTERFACES="e
np0s3"

If you have more than


one interfaces, mention
them with spaces, for
example “eth0 eth1”.

Save and close the file.

Then, edit dhcpd.conf


file,

sudo vi 
/etc/dhcp/dhc
pd.conf

Modify it as shown
below. Replace the
domain name with your
own values.

Enter the domain name


and domain-name-
servers:

[...] 
  "The Network Security Test Lab: A Step-by-Step Guide ($40 Value)
Free eBook:
# option 
https://www.ostechnix.com/install-dhcp-server-in-ubuntu-16-04/ 5/17
12/6/2016 Install DHCP Server in Ubuntu 16.04 - OSTechNix

definitions 
common to all 
supported 
networks... 
 option 
domain­name 
"ostechnix.la
n"; 
 option 
domain­name­
servers 
ubuntuserver.
ostechnix.lan
; 
 
[...]

To make this server as


official DHCP for your
clients, find and
uncomment the
following line:

[...] 
authoritative
; 
[...]

Free eBook: "The Network Security Test Lab: A Step-by-Step Guide ($40 Value)

https://www.ostechnix.com/install-dhcp-server-in-ubuntu-16-04/ 6/17
12/6/2016 Install DHCP Server in Ubuntu 16.04 - OSTechNix

Scroll down little bit, and


define the subnet, IP
range, domain and
domain name servers
like below.

[...] 
# A slightly 
different 
configuration 
for an 
internal 
subnet. 
 subnet 
192.168.1.0 
netmask 
255.255.255.0 

 range 
192.168.1.20 
192.168.1.30; 
 option 
domain­name­
servers 
ubuntuserver.
ostechnix.lan
; 
 option 
domain­name 
"ostechnix.la
n"; 
 option 
routers 
192.168.1.1; 
 option 
Free eBook: "The Network Security Test Lab: A Step-by-Step Guide ($40 Value)
broadcast­
https://www.ostechnix.com/install-dhcp-server-in-ubuntu-16-04/ 7/17
12/6/2016 Install DHCP Server in Ubuntu 16.04 - OSTechNix

address 
192.168.1.255
; 
 default­
lease­time 
600; 
 max­lease­
time 7200; 
 } 
[...]

As you see in the above


configuration, I have
assigned IP range from
192.168.1.150 to
192.168.1.200. So, the
DHCP clients will get the
IP address from this
range. But, what if you
want assign a specific IP
(fixed IP address) to a
particular client? It’s easy
too. You can easily
assign a specific IP to a
client of your network
by adding the MAC id of
that client with fixed IP
address as shown below.

For example, let us say


we want
Free eBook: to Network
"The assign IPSecurity Test Lab: A Step-by-Step Guide ($40 Value)

https://www.ostechnix.com/install-dhcp-server-in-ubuntu-16-04/ 8/17
12/6/2016 Install DHCP Server in Ubuntu 16.04 - OSTechNix

192.168.1.160 to client
that has MAC
id  00:22:64:4f:e9:3a. To
find out the IP ann MAC
addresses, use ‘ifcon g’
command.

ifconfig

Sample output:

See the underlined


words. Those are the IP
and MAC addresses.

Assign the fixed IP and


MAC id of the client as
shown below.

[...] 
host ubuntu­
client { 
 hardware 
ethernet 
08:00:27:13:1
4:d5; 
 fixed­
address 
192.168.1.160
; 
 }  "The Network Security Test Lab: A Step-by-Step Guide ($40 Value)
Free eBook:
[...]
https://www.ostechnix.com/install-dhcp-server-in-ubuntu-16-04/ 9/17
12/6/2016 Install DHCP Server in Ubuntu 16.04 - OSTechNix

Once you modified all


settings as per your
requirements, save and
close the file.

Now, restart dhcp


service:

sudo 
systemctl 
restart isc­
dhcp­server

Make sure you haven’t


left any unused entries
in the dhcpd.conf file. If
there is any unused or
unnecessary lines, just
comment them out.
Otherwise, DHCP service
will not start.

Let us check if our DHCP


service has been started
or not using command:

sudo 
Free eBook: "The Network Security Test Lab: A Step-by-Step Guide ($40 Value)
systemctl 

https://www.ostechnix.com/install-dhcp-server-in-ubuntu-16-04/ 10/17
12/6/2016 Install DHCP Server in Ubuntu 16.04 - OSTechNix

status  isc­
dhcp­server

Sample output:

As you see in the above


screenshot, DHCP server
is running!

To start or stop DHCP


service, use the
following commands:

sudo 
systemctl 
start  isc­
dhcp­server

sudo 
systemctl 
stop  isc­
dhcp­server

At this stage, you will


have a working DHCP
server. The server side
configuration part is
over. Let’s go ahead and

Free eBook: "The Network Security Test Lab: A Step-by-Step Guide ($40 Value)

https://www.ostechnix.com/install-dhcp-server-in-ubuntu-16-04/ 11/17
12/6/2016 Install DHCP Server in Ubuntu 16.04 - OSTechNix

configure the DHCP


clients.

Configure
DHCP
Clients
For the purpose of this
tutorial, I will be using
Ubuntu 16.04 LTS
desktop as my DHCP
client.

My DHCP client:

OS – Ubuntu 16.04
LTS desktop
IP Address – DHCP
enabled

Open Network
Connections either from
Unity dash or Menu.

In the Network
connections window,
Select your Ethernet
card and click Edit.

Free eBook: "The Network Security Test Lab: A Step-by-Step Guide ($40 Value)

https://www.ostechnix.com/install-dhcp-server-in-ubuntu-16-04/ 12/17
12/6/2016 Install DHCP Server in Ubuntu 16.04 - OSTechNix

Click IPv4 Settings, and


select “Automatic
(DHCP)” option. Finally
click Save.

Now, restart your client


system, and check the IP
address of your client
system.

ifconfig

Sample output:

You will see a new IP


address from IP range,
which we defined in the
DHCP server, is assigned
to your client system.

Free eBook: "The Network Security Test Lab: A Step-by-Step Guide ($40 Value)

https://www.ostechnix.com/install-dhcp-server-in-ubuntu-16-04/ 13/17
12/6/2016 Install DHCP Server in Ubuntu 16.04 - OSTechNix

As you see in the above


screenshot, My Ubuntu
16.04 LTS desktop
system, which has MAC
id 08:00:27:13:14:d5, has
been assigned with a
fixed IP address
(192.168.1.160) from
the DHCP server.
Remember we have
mentioned these values
in dhcpd.conf file of our
DHCP server.

Congratulations! DHCP
server is working!!

Also read –  How to


monitor DHCP server
usage

That’s all for now. I will


be here soon with
another article. Until
then, stay tuned with
OSTechNix.

Cheers!

Free eBook: "The Network Security Test Lab: A Step-by-Step Guide ($40 Value)

https://www.ostechnix.com/install-dhcp-server-in-ubuntu-16-04/ 14/17
12/6/2016 Install DHCP Server in Ubuntu 16.04 - OSTechNix

Share this:

 Reddit  Twitter

 Facebook 2

 Google

 LinkedIn 2

 Pocket  Email

 Print

Tags: DHCP server Ubuntu 16.04 LTS server

PREVIOUS NEXT
STORY STORY

How to How to
prevent a monitor 
package DHCP
from being server
 automatically usage
installed,
upgraded
or
removed
in Ubuntu

 YOU MAY ALSO LIKE...

How to How to
install monitor
PXE DHCP
Server server
on usage
Ubuntu AUGUST 5,
16.04 2016

Free eBook: "The Network Security Test Lab: A Step-by-Step Guide ($40 Value)

https://www.ostechnix.com/install-dhcp-server-in-ubuntu-16-04/ 15/17
12/6/2016 Install DHCP Server in Ubuntu 16.04 - OSTechNix

AUGUST 8,
2016

EMAIL NEWSLETTER TODAY’S MOST READ WHO WE ARE


How to install Arch Linux
 About
Subscribe to our How To Migrate System
mailing list Settings And Data From Old
 Contact Us
System To Newly Installed
Ubuntu System  Privacy Policy
How to install Yaourt on
Sign Up Now Arch Linux  Sitemap
We respect your Install VSFTPD server in
Ubuntu 16.04 LTS  Terms and Conditions
privacy
Configure GRUB 2 Boot
Loader settings in Ubuntu
16.04
Install Microsoft Windows
Fonts in Ubuntu 16.04
How To Find And Delete
Files Older Than X Days In
Linux
Arch Anywhere - An easy
way to install a fully custom
Arch Linux system
Install and configure DNS
server in Ubuntu 16.04 LTS
Linux Kernel 4.7 is released –
Install it in CentOS 7 and
Ubuntu 16.04


Free eBook: "The Network Security Test Lab: A Step-by-Step Guide ($40 Value)

https://www.ostechnix.com/install-dhcp-server-in-ubuntu-16-04/ 16/17
12/6/2016 Install DHCP Server in Ubuntu 16.04 - OSTechNix

    
OSTechNix © 2016. All Rights Reserved.
This site is licensed under CC BY-NC 4.0.

Free eBook: "The Network Security Test Lab: A Step-by-Step Guide ($40 Value)

https://www.ostechnix.com/install-dhcp-server-in-ubuntu-16-04/ 17/17

You might also like