DHCP Server

DHCP Server in Linux ? How DHCP Works and DHCP Configuration.

DHCP Server

Dynamic Host Configuration Protocol (DHCP) is a network protocol that enables a server to automatically assign an IP Address to a computer from a defined range of numbers configured for a given network.

DHCP allows a computer to join an IP-based network without having a pre-configured IP address. DHCP is a protocol that assigns unique IP addresses as devices leave and rejoin the network.

DHCP Server

Internet service providers usually use DHCP to helps customers join their networks with minimum setup effort required. Likewise, home network equipment like broadband routers offers DHCP support for added convenience in joining home computers to local area networks.

Why DHCP server use:

Imagine that you’re working as a SysAdmin for a large company with 500 desktop computers; you need to set to each desktop computer IP address, subnet mask, default gateway, DNS servers, and other network settings. How could you do that?

If you’ll try to perform this task manually you’re probably going to waste a lot of time sitting on each computer 5-10 minutes, besides time, you can for example accidentally enter wrong IP address to few clients, or to type the same IP address to few clients too.

In order to solve these “problems” you can use Dynamic Host Configuration Protocol (or DHCP) in your network. DHCP allows you manage the networks’ IP addresses scopes and other TCP/IP settings like DNS, Default Gateway, etc. from central place, this central place called DHCP server. Beside the management, if there’s any problem you don’t need to run between your clients, you just need to connect to your server and to check the DHCP settings, as I mentioned – the DHCP works from central place, so if there’s a problem, it’s probably from the server, so you know where to go in case of problem and your saving time.

The DHCP server can provide easily IP addresses to clients automatically so you don’t even need to configure and set options in the client side, all you need is to setup DHCP server, configure scope options and some other TCP/IP settings in the server side and that’s it. You can provide to your clients IP addresses from the selected range that you’ve configured and some other TCP/IP options.

How DHCP Works?

How DHCP Works

Without entering to the related technical information (DORA process) the DHCP client request from the DHCP server IP address for a while, the length of time that the DHCP client can use the dynamic IP address that the DHCP server provided can be called lease, just like the name: lease means that the client “rent” an IP address for a specific time from the DHCP server, if the client want to continue using the specific IP address the client needs to re-assign the address by renew the lease, this will happen before the expiration time of the lease if the client is still in the network.

More in-depth, the DHCP service works by using the DORA (Discover, Offer, Request, and Acknowledgement) process (you can trace on the whole process using a network monitor utility):

DORA Process

  • DHCPDISCOVER – The client broadcast a DHCPDISCOVER packet in order to locate a DHCP server in the network, in some cases that the DHCP server isn’t in the same subnet of the client, you’ll need to configure in your network devices (usual routers) a DHCP Relay Agent, in order to transfer the DHCPDISCOVER packet to the DHCP server.
  • DHCPOFFER – The DHCP server broadcasts a DHCPOFFER packet to the client which includes an offer to use a unique IP address for the client.
  • DHCPREQUEST – The client broadcasts a DHCPREQUEST packet to the DHCP server with an answer, and “asks” from the server to “rent” the unique address that the server offered to her.
  • DHCPACK – The DHCP server broadcast a DHCPACK packet to the client, in this packet the server acknowledge the request from the client to use the IP address, and provide to the client the IP address lease and other details such as DNS servers, default gateway, etc. if the server cannot provide the requested IP address or from some reasons the address is not valid the server sends DHCPNACK packet in stand of DHCPACK, more information about DHCPNACK is under the specific subject – DHCPNACK.

Profile for DHCP Server:

Usage: To Assign IP’s to the computer’s in the network dynamically.

Package: DHCP

Configuration file: /etc/dhcp/dhcpd.conf

Port no: 67 and 68

Daemon: dhcpd

Script: /etc/init.d/dhcpd

Leave a Comment

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