How to set up a DHCP server in CentOS 7?

To configure a DHCP server on CentOS 7, you can follow the steps below:

  1. Open the terminal and log in as a root user.
  2. Install the DHCP server software package by running the command yum install dhcp.
  3. Configure the DHCP server by editing the configuration file /etc/dhcp/dhcpd.conf, which can be opened using any text editor.
  4. Add the configuration information for the DHCP server in the configuration file. Here is a simple example of DHCP server configuration:
subnet 192.168.1.0 netmask 255.255.255.0 {
  range 192.168.1.100 192.168.1.200;
  option domain-name-servers 8.8.8.8;
  option routers 192.168.1.1;
}

The above settings will assign an IP address range of 192.168.1.100-192.168.1.200, with a DNS server address of 8.8.8.8 and a gateway address of 192.168.1.1.

  1. Save the configuration file and close it.
  2. Start the DHCP server by running the command systemctl start dhcpd.
  3. Enable DHCP server to start automatically on boot by executing the command systemctl enable dhcpd.
  4. Check if the DHCP server has successfully started by running the command systemctl status dhcpd. If the service status displays as “active (running),” then the DHCP server has successfully started.

Your CentOS 7 system is now set up as a DHCP server. When other computers connect to the same network, they will automatically receive the IP address, DNS server, and gateway information assigned by this DHCP server.

广告
Closing in 10 seconds
bannerAds