Configure DHCP Failover on CentOS 7
Configuring DHCP (Dynamic Host Configuration Protocol) failover on CentOS 7 typically involves using the ISC DHCP server, which is a widely used DHCP server on Linux systems. DHCP failover ensures high availability and redundancy for DHCP services. Here’s a basic guide on how to set up DHCP failover on CentOS 7 using ISC DHCP:
Prerequisites:
- Install ISC DHCP Server: If you haven’t already installed the DHCP server, you can do so with the following command:
sudo yum install dhcp
Configuration:
- Edit the DHCP Configuration File: Open the DHCP configuration file in a text editor. The default configuration file is usually located at
/etc/dhcp/dhcpd.conf
. sudo vi /etc/dhcp/dhcpd.conf
- Configure DHCP Server: Add or modify the following lines in the
dhcpd.conf
file for the primary DHCP server. Replace the placeholders with your network-specific values.plaintextCopy codeauthoritative; subnet <your_subnet> netmask <your_netmask> { range <start_ip_address> <end_ip_address>; option routers <gateway_ip_address>; option domain-name-servers <dns_server_ip>; }
- Configure Failover: Add the following lines to enable DHCP failover. Replace the placeholders with appropriate values.plaintextCopy code
failover peer "dhcp-failover" { primary; address <primary_ip>; port 647; peer address <secondary_ip>; peer port 647; max-response-delay 60; max-unacked-updates 10; load balance max seconds 3; }
primary_ip
: IP address of the primary DHCP server.secondary_ip
: IP address of the secondary DHCP server.
- Restart DHCP Server: After making the changes, restart the DHCP server for the configuration to take effect.bashCopy code
sudo systemctl restart dhcpd
Secondary DHCP Server Configuration:
- Follow the same steps as above for configuring the DHCP server on the secondary server.
- Make sure to change the
primary
keyword tosecondary
in the failover configuration.
Verification:
- Check the DHCP server logs for any errors or warnings.bashCopy code
sudo journalctl -u dhcpd
- Verify that the failover status is as expected.bashCopy code
sudo dhcpd -t
This command tests the configuration and reports any syntax errors.
Notes:
- Ensure that both primary and secondary DHCP servers have synchronized configuration files.
- Adjust the failover settings and subnet parameters according to your network requirements.
- Regularly monitor DHCP server logs to catch any potential issues early on.
This guide provides a basic configuration for DHCP failover. Depending on your network architecture and requirements, you may need to adjust the configuration accordingly. Always test the failover setup in a controlled environment before deploying it in a production network.