Prevent IP Addresses from Rotating with DHCPD.conf (Non-Static)
In Windows DHCP server, it is possible to set the lease time to unlimited duration for an IP address, making it permanent (DHCP static). However, in Linux, the DHCP server does not have this option by default. This article will guide you through the process of preventing IP addresses from rotating with DHCPD.conf (Non-Static) on a Linux system.
Understanding DHCP and DHCPD.conf
DHCP (Dynamic Host Configuration Protocol) is a network protocol used to dynamically assign IP addresses to devices on a network. DHCPD (DHCP Daemon) is the server that manages the DHCP protocol. The DHCPD.conf file is the configuration file for the DHCP daemon, where you can specify the IP address range, lease time, and other settings for DHCP clients.
Preventing IP Addresses from Rotating
To prevent IP addresses from rotating, you need to set a long lease time for the IP addresses you want to keep static. This can be done by modifying the DHCPD.conf file. Here's an example of how to do this:
subnet 192.168.1.0 netmask 255.255.255.0 {
range 192.168.1.100 192.168.1.200;
option routers 192.168.1.1;
option domain-name-servers 192.168.1.1;
default-lease-time 604800; # 1 week in seconds
max-lease-time 604800; # 1 week in seconds
}
In this example, the range of IP addresses from 192.168.1.100 to 192.168.1.200 will be assigned to DHCP clients with a lease time of 1 week. The default-lease-time and max-lease-time options are used to set the minimum and maximum lease time for the IP addresses in the range. By setting both options to the same value, you ensure that all IP addresses in the range will have the same lease time.
Adding Static IP Addresses
If you want to assign a specific IP address to a DHCP client, you can add a host declaration to the DHCPD.conf file. Here's an example:
host client1 {
hardware ethernet 00:11:22:33:44:55;
fixed-address 192.168.1.100;
option routers 192.168.1.1;
option domain-name-servers 192.168.1.1;
}
In this example, the DHCP client with the MAC address 00:11:22:33:44:55 will be assigned the IP address 192.168.1.100. The option routers and option domain-name-servers lines are optional and can be used to specify the default gateway and DNS servers for the DHCP client.
- DHCP is a network protocol used to dynamically assign IP addresses to devices on a network.
- DHCPD is the server that manages the DHCP protocol, and the DHCPD.conf file is the configuration file for the DHCP daemon.
- To prevent IP addresses from rotating, you need to set a long lease time for the IP addresses you want to keep static.
- You can add a host declaration to the DHCPD.conf file to assign a specific IP address to a DHCP client.