1. Install DHCP server on nodes:
root@node1:~# apt-get install dhcp3-server root@node2:~# apt-get install dhcp3-server 2. Important. Synchronize time on both nodes using NTP service. 3. We need to configure a config which should be identical on both machines. It will describe fail-over peer and range of IP addresses, as well as other information as described below. Create it in /etc/dhcp/ and name as general or common, or master. Do not forget to change dhcpd.conf include accordingly (see below).
root@node1:~# vim /etc/dhcp/dhcpd.general root@node2:~# vim /etc/dhcp/dhcpd.general 4. Paste in each of them and change according to your needs: ddns-update-style none;
log-facility local7;
subnet 192.168.2.0 netmask 255.255.255.0 {
pool {
failover peer "dhcp";
range 192.168.1.100 192.168.1.200;
}
option routers 192.168.1.254;
option subnet-mask 255.255.255.0;
# option broadcast-address 192.168.1.255;
option domain-name "your domain";
option domain-name-servers 192.168.1.1, 192.168.1.2;
# option ntp-servers 192.168.1.1, 192.168.1.2;
# option netbios-node-type 8;
default-lease-time 600;
max-lease-time 7200;
5. Configure dhcpd.conf for each node:
5.1. First node:
root@node1:~# vim /etc/dhcp/dhcpd.conf
failover peer "dhcp" {
primary;
address 192.168.1.1;
port 519;
peer address 192.168.1.2;
peer port 520;
max-response-delay 60;
max-unacked-updates 10;
mclt 600;
split 128;
load balance max seconds 3;
}
include "/etc/dhcp/dhcpd.general";
5.2. Second node:
root@node2:~# vim /etc/dhcp/dhcpd.conf
failover peer "dhcp" {
primary;
address 192.168.1.2;
port 520;
peer address 192.168.1.1;
peer port 519;
max-response-delay 60;
max-unacked-updates 10;
mclt 600;
split 128;
load balance max seconds 3;
}
include "/etc/dhcp/dhcpd.general";
6. Testing
root@node1:~# cat /var/lib/dhcp/dhcpd.leases
root@node2:~# cat /var/lib/dhcp/dhcpd.leases