DHCP Server and Client on
CentOS and Ubuntu
I will explain how to configure a DHCP server in
CentOS
and
Ubuntu
Linux distributions to assign IP address automatically to a client machine.
How Does DHCP Work?
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, I 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.
Installing DHCP Server in CentOS and
Ubuntu
The
DCHP
server package is available in the official repositories of mainstream
Linux distributions, installing is quite easy, simply run the following command.
# yum install dhcp #CentOS
$ sudo apt install isc-dhcp-server #Ubuntu
Once the installation
is complete, configure the interface on which you want the
DHCP
daemon to
serve requests in
the configuration file
/etc/default/isc-dhcp-server
or