Installing and configuring DHCP server and client in Centos 7

Installing and configuring DHCP server and client in Centos 7

DHCP (English Dynamic Host Configuration Protocol) is a network protocol that allows computers to automatically obtain an IP address and other parameters necessary to operate on a TCP / IP network. This protocol works on a client-server model.

Setting up a DHCP server

DHCP server is available in the official repository. To install, run the command in the terminal

                        [[email protected]]# yum install dhcp

Next, you need to register the network interface for which the DHCP server will serve requests

                        [[email protected]]# nano /etc/sysconfig/dhcpd

DHCP server configuration

The main DHCP server configuration file is located /etc/dhcp/dhcpd.conf Copy the template and open it for editing

                        [[email protected]]# cp /usr/share/doc/dhcp-4.2.5/dhcpd.conf.example /etc/dhcp/dhcpd.conf	
[[email protected]]# nano /etc/dhcp/dhcpd.conf
option domain-name "domain.local";
option domain-name-servers ns1.domain.local, ns2.domain.local;
default-lease-time 3600; 
max-lease-time 7200;
subnet netmask {
        option routers        ;
        option subnet-mask    ;
        option domain-search            "domain.local";
        option domain-name-servers;

Let’s add the service to startup, start it and check the status

                        [[email protected]]# systemctl enable dhcpd
[[email protected]]# systemctl start dhcpd
[[email protected]]# systemctl status dhcpd

Let’s add an allowing rule for the firewall

                        [[email protected]]# firewall-cmd --zone=public --permanent --add-service=dhcp
[[email protected]]# firewall-cmd --reload 

DHCP client configuration

Editing the network interface configuration file

                        [[email protected]]# nano /etc/sysconfig/network-scripts/ifcfg-eth0

Restart the network service

                        [[email protected]]# systemctl restart network

Related Posts