Tuesday, August 1, 2017

Install and Configure DHCP Server on Debian 8

Install and Configure DHCP Server on Debian 8

Understanding and Functions of DHCP Server

DHCP server or Dinamic Host Configuration Protocol is a protocol that allows a computer or server to assign IP addresses dynamically or automatically to other computers, or client computers.

When the DHCP client on the client computer is enabled, the client computer will request to the server computer to obtain the IP Address of the DHCP Server. Then the DHCP server will provide the answer to the client computer by providing the IP Address available on the pool or range of IP Address on the DHCP server.

So with this mechanism, a server administrator no longer need to set the IP Address statically or manually one by one on each client computer to be connected to a server computer or with other computers. Imagine if a network has dozens or hundreds of computers, how much time is saved by using a DHCP server.


Configure IP Address in Debian 

IP Address is the main requirement of a device or computer in order to connect with other devices. Before starting to install and configure the Dynamic Host Configuration Protocol (DHCP server) in Debian, we must first set up the IP Address or Network Interfaces on that computer.

If you have followed the previous tutorial, Install and Configure DNS Server in Debian 8 or have configured the IP Address correctly, you can skip this step. But the IP Address you set should be the same as the configuration on the DHCP server that we will do later.
 


If not, to set the IP Address in Debian, open the interfaces file in the / etc / network / directory. Type the following command to open the file: 

CODE :

Once the file is open, add or replace the existing configuration file as follows:

CODE:



When done, save the configuration by pressing the CTRL + O key combination on the keyboard, then press Enter. Then press CTRL + X to exit the nano editor or file.

Adding Domain and Name Server to Resolv.conf File

 Type the following command to open the resolv.conf file:

CODE:

 
Delete the contents of the file and replace it with the DNS and nameservers you use as follows:

 CODE

 Save the configuration.

Since Network Interfaces has just been configured, the machine needs to restart the network service so that the newly configured IP address can work. Type the following command to restart the network service:


 CODE:

 Then you can check whether the Network Interfaces configuration is running by typing the "ifconfig" command.

CODE:


Then will appear IP address settings that exist on the computer, check whether in accordance with what you have configured.

Install DHCP Server Packages on Debian 8

In Debian 8 (especially Debian 8.6 as used in this tutorial), the package provided by default to perform the task as a DHCP server is "isc-dhcp-server". If you are using a DVD for installation, on Debian 8.6 the package is DVD-Binary 2.

Insert DVD-Binary 2 and type the following command to add the list of packages:
 


CODE:

 Then type the following command to install the isc-dhcp-server package as the DHCP server.

CODE:
 
 Make sure the package successfully installed properly. At the time of installation isc-dhcp-server, will appear failed message. No need to fear, the failed message occurs because the configuration of the IP Address on the network interfaces file is different from the default IP Address configuration in the DHCP Server configuration.

Configuring DHCP Server on Debian 8

After successfully install the package for DHCP server. Next make configuration configuration file for DHCP server.

First, open the file "dhcpd.conf" which is the main DHCP server configuration in Debian, open the file with the following command:
 


CODE:


 Then the file will open with nano editor. The file contains many DHCP Server configuration scripts. Find the line with the configuration script as follows.

CODE:


Once you have found it, remove all the fence marks in the configuration scipt from the "# subnet ..." line to the "#}" line (curly brackets).

Then configure the file with IP Address and network configuration as you wish. In this tutorial we use the IP Address and network configuration as in the Installation and Configuring the previous DNS Server tutorial, and the configuration will continue to be used in the next tutorial to make it continuous and easy to learn for beginners.

Change the configuration script line to the following:


CODE:
 

After successfully changed as above or as you want. Save the configuration by pressing the CTRL + O combination on the keyboard, then press Enter. Press the CTRL + X combination on the keyboard to exit the file.

Next is to decide which interfaces or network cards (Network Interfaces Card) will be used for to rebuild the DHCP Server service. Type the following command to open the file:  

CODE:

Then the file will open with the nano editor, then look for the script with the words "INTERFACES =", usually in the bottom row. Then select the interfaces you will use to provide the DHCP Server service. If you only have one interfaces, just enter "eth0" between the quotes in the script, like this: 

CODE:

Or if you have more than one interfaces you use, enter (change) interfaces to how much you use to provide DHCP server services, the order of naming interfaces or Network Interfaces Card starting from "eth0", "eth1", " Eth2 "," eth3 "and so on.

After successfully configuring the file to select interfaces, save the configuration by pressing the CTRL + O combination on the keyboard, then press Enter. To exit, press the CTRL + X combination on the keyboard.

The DHCP server configuration has been completed so far. Then restart the isc-dhcp-server service to restart and the new configuration can be read by entering the following command:


CODE:

 
 When the first service isc-dhcp-server restarts, it will come out an error message, just let it not okay. Simply restart it once again with the same command as above.

If there is still an error, it means a configuration error. Try checking the configuration files carefully one by one, if it is correct.
 

Testing DHCP Server on Debian 8

To test whether the DHCP server configuration is successful or not. Another computer is required to act as a client requesting or requesting an IP Address from DHCP Sever.

Previously, please connect server computer and client computer using cable. Or if you are configuring a DHCP server on a virtual machine such as Virtual Box or VMware, please set the virtual network interfaces to connect to other computers.


Testing DHCP Server Using Linux 

On client computers that use Linux as an operating system, either Debian, Ubuntu, Linux Mint or other distributions. Type the following command to have the computer request or request the IP address of the DHCP server on the server: 

CODE:

"Eth0" in the command is the name of the interfaces or Network Interfaces Card (Network Card) used on the client computer, please adjust the interfaces name if the distribution you use uses the naming of different interfaces.

The order is only temporary or not permanent. Every time you restart the computer you have to re-enter it.

Or for a permanent DHCP client configuration. Open an existing interfaces file in the / etc / network / directory with the following command:


CODE:
 
 
 After the file opens, add or replace the existing configuration of the file as follows:


CODE:


When done, save the configuration by pressing the CTRL + O key combination on the keyboard, then press Enter. Then press CTRL + X to exit the nano editor or file.

Since Network Interfaces has just been configured, the machine needs to restart the network service so that the newly configured interfaces file can work. Type the following command to restart the network service:


CODE:


Then check whether the Network Interfaces configuration is running or not by typing the "ifconfig" command.

CODE:


Then the IP Address will appear that the computer is a gift from the DHCP server service on the server computer, see if the IP address, DNS server, gateway on the computer in accordance with the pool range DHCP server on the Debian server.
To check again, try pinging from client computer to server computer IP address as follows:


CODE:
 
Make sure the ping is successful and is replied from the IP address of the server computer.

Testing DHCP Server Using Windows

To test DHCP server or use DHCP client on Windows. Go to Control Panel -> Network and Internet -> Network and Sharing Center -> Change Adapter Settings, then choose which Adapter to connect to server computer, if you use wired media Select adapters named "Ethernet" or "Local Area Connection "

Select Internet Protocol Version 4 (TCP / IPv4), then enable DHCP Client by selecting "Obtain an IP address automatically" and "Obtain DNS server address automatically" as shown below.
 



If so, Click OK. Then instead of CMD in Windows, type: 

CODE:

To check again, try pinging from client computer to server computer IP address as follows:
 Make sure the ping is successful and is replied from the IP address of the server computer.

No comments:

Post a Comment