DHCP SERVER CONFIGURATION IN CENTOS LINUX
Configuration of the dhcpd.conf
We will be editing the "/etc/dhcp/dhcpd.conf". open the file with a text editor of your choice. I am using vim so the command is "vim /etc/dhcp/dhcpd.conf".
We start by opening the dhcpd.conf and writing it to be as shown in the figure. The dhcp server configuration shown has been used in centos 6,7,8 and 9. I will explain the important parts of the configuration file step by step.
- Firstly, we need to set the lease time for the IP address settings given by the server. So the first two lines give the default and maximum lease times.
- We also use the “authoritative” line to make sure that this is a primary server.
- We need to set the update style to configure how the updates are sent out. In this case we use interim. This means that the server will send updates to the DNS server whenever there is a change in the client's lease status, such as when a client initially acquires an IP address or renews its lease.
- We then set the ddns-ttl value. If we set it to 3600 for example, it means that DNS records updated by the DHCP server will have a TTL of 3600 seconds (1 hour). After this time period, DNS servers may discard the old DNS records, and if a client requests a DNS resolution after this time, a fresh DNS update may be required.
- For our IP settings the subnet section sets the network range for the IP addresses to be given out.
- We then set the range of IP addresses with the first and last IP to be given to the clients. This is what is in the “range”.
- The “option-routers” sets the default gateway.
- The “option-broadcast-address” sets the broadcast address for the network.
- We then set the domain name for the local network and the DNS server IP address for the clients to use.
- The “host auto” line is meant to give settings to one machine. The name auto can be replaced with some other name of course.
- We insert the mac address using the “hardware ethernet”. The mac address should be of the machine that will be receiving the same IP address.
- The IP address of the said machine can then be set using the “fixed-address” line.
Make sure that your network interface has a network address that is within the network range of the configuration file. In this case "ifconfig enp0s8 10.0.13.1" swap enp0s8 with your network interface.