How to configure DHCP in Linux ?

Dynamic Host Configuration Protocol (DHCP) is a network protocol that is used to enable host computers to be automatically assigned IP addresses and related network configurations from a server.

The IP address assigned by a DHCP server to DHCP client is on a “lease”, the lease time normally varies depending on how long a client computer is likely to require the connection or DHCP configuration.

The following is a quick description of how DHCP actually works:

  • Once a client (that is configured to use DHCP) and connected to a network boots up, it sends a DHCPDISCOVER packet to the DHCP server.
  • When the DHCP server receives the DHCPDISCOVER request packet, it replies with a DHCPOFFER packet.
  • Then the client gets the DHCPOFFER packet, and it sends a DHCPREQUEST packet to the server showing it is ready to receive the network configuration information provided in the DHCPOFFER packet.
  • Finally, after the DHCP server receives the DHCPREQUEST packet from the client, it sends the DHCPACK packet showing that the client is now permitted to use the IP address assigned to it.

In this article, we will show you how to setup a DHCP server in Ubuntu/Debian Linux, and we will run all the commands with the sudo command to gain root user privileges.