How To Install & Configure DHCP Server in Ubuntu 16.04/16.10

Step by step manual to learn how to install and configure a DHCP client-server on Ubuntu 16.

DHCP allows us to establish ranges of IP addresses for client computers in the domain and thus we can centrally manage all IP addresses of the domain.

With DHCP implemented, we provide the following parameters:

  • Subnet mask
  • IP address
  • Gateway
  • DNS servers, among others.

In Ubuntu 16 we have the possibility that this is a DHCP server that controls all the IP addresses of the organization dynamically and securely.

In this opportunity we will talk about how to configure DHCP Ubuntu 16 in a practical way.

Installing DHCP in Ubuntu 16

To execute this process we must have root privileges using the sudo term before each command or, failing that, logging in as that user.

To install DHCP in Ubuntu 16 we will enter the following command:

sudo apt-get install isc-dhcp-server
Note: We must have defined what values we have to establish in the DHCP server such as the gateway, the range of IP addresses to assign, etc.

Configuring the network card in Ubuntu 16

Once the installation of DHCP in Ubuntu 16 is complete, we must edit the isc-dhcp-server file to establish the values of the network card that will be responsible for transmitting IP addressing.

We can use the preferred editor, such as Vim or Nano, and we will access using the following:

sudo nano /etc/default/isc-dhcp-server

The following will be displayed where on the INTERFACES line we must indicate which will be the network card responsible for distributing and assigning the IP addresses, in this case we will indicate what the eth0 card will be.

We save the changes using the key combination: Ctrl + O

And we left the editor using the combination: Ctrl + X

Configuring DHCP in Ubuntu 16

Once the values of the network card have been defined, we proceed to make the respective DHCP settings. For this, we will edit the file /etc/dhcp/dhcpd.conf, for this we will enter the following:

sudo nano /etc/dhcp/dhcpd.conf

There we must enter the respective DHCP values, in this case we must add the following lines depending on the required configuration.

subnet 192.168.0.1 netmask 255.255.255.0 {

range 192.168.0.10 192.168.0.40;

option domain-name-servers 8.8.8.8, 4.4.4.4;

option domain-name "solvetic";

option routers 192.168.0.1;

option broadcast-address 192.168.0.255;

default-lease-time 600;

max-lease-time 7200;

}

In this case we have defined the following:

  • The IP address and network mask of the DHCP server
  • Set the range of addresses to allocate
  • We have taken some public DNS support such as Google's.
  • We have defined the name of our domain in option option domain-name
  • The broadcast or broadcast IP has been defined which will always be finished in 255
  • With the default-lease-time value, we specify how many hours an IP address is reserved to a computer
  • The max-lease-time value refers to the maximum time an IP will be reserved for a device.

We save the changes in the editor using: Ctrl + O

In this way we have configured the DHCP parameters in Ubuntu 16. Once these values are configured, we proceed to restart the isc-dhcp-server service using the following command:

sudo systemctl restart isc-dhcp-server

Start and stop the isc-dchp-server service

The commands to start and stop this service are:

Start service

sudo systemctl start isc-dhcp-server

Stop service

sudo systemctl stop isc-dhcp-server

Using DHCP in Ubuntu 16

One of the uses we can practice with the DHCP server in Ubuntu 16 is to assign an IP address to a particular computer.

For example, we have a computer with CentOS 7 which has the following configuration:

  • MAC address: 00:00:27:7e:3a:73
  • IP Address: 192.168.0.32

For some reason we want this computer to have the IP address 192.168.0.40¸, so we will perform the following process on the DHCP server:

To do this we must go to the dhcp.conf file and add the following lines at the bottom:

host localhost-CentOS {

hardware ethernet 00:00:27:7e:3a:73;

fixed-address 192.168.0.40;

}

Once we save the changes we can go to the CentOS computer, restart the service or the computer and we will see the changes applied:

In the same way we can look at the parameters of the subnet and broadcast mask defined by DHCP.

Configure DHCP on a Client Computer

To configure the IP address on a client computer we must go to the network configuration and go to the IPv4 tab :

There we merely establish that the DHCP is configured as automatic and in this way the computer will receive the IP addresses assigned by the DHCP server.

Using these parameters we can configure, in a simple and practical way, a DHCP server in Ubuntu 16 and from there allow IP addresses to be assigned according to the configured range and thus have the possibility of managing the connected equipment in the organization.

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *