Self

DHCP Primary

Network

We will give the DHCP primary a static IP-address. Edit /etc/networking/interfaces and make the following changes.

# The primary network interface
#allow-hotplug eth0
#iface eth0 inet dhcp

auto eth0
iface eth0 inet static
        address 192.168.1.38
        network 192.168.1.0
        netmask 255.255.255.0
        broadcast 192.168.1.255
        gateway 192.168.1.1

Software

Before installing the DHCP server, make sure that you do not have other DHCP servers running on your network. It can cause hours of debugging.

Install the DHCP server.

apt-get install isc-dhcp-server

Configure the server

Stop the server

service isc-dhcp-server stop

Get the DDNS update key

Copy your DDNS update key from the DNS Master and save it in /etc/dhcp/ddns-update.kallenberg.dk. Edit /etc/dhcp/ddns-update.kallenberg.dk and remove the quotations. If the quotations are not removed, then the DHCP server will not accept it as a valid key.

key ddns-update {
        algorithm hmac-sha512;
        secret yYFzfibvlpS33+vsngV2jF5tGkTiVSjhYoFuV0T7bnCVfFGx3Mu05SW+LakImdofkNM00LxHCLuvD1W1vSWMmA==;
};

Choose Network Device

Edit /etc/default/isc-dhcp-server and set the dhcp server to run on eth0.

INTERFACESv4="eth0"

Edit dhcpcd.conf

Comment out all lines in /etc/dhcp/dhcpd.conf and add the following to the bottom of the file:

include "/etc/dhcp/dhcpd.conf_default";
include "/etc/dhcp/ddns-update.kallenberg.dk";
include "/etc/dhcp/dhcpd.conf_primary";
include "/etc/dhcp/dhcpd.conf_subnet";
include "/etc/dhcp/dhcpd.conf_static";

Individual Config Files

Server

/etc/dhcp/dhcpd.conf_default

option domain-name "kallenberg.dk";
option domain-name-servers 192.168.1.36, 192.168.1.37;
default-lease-time 3600;
max-lease-time 7200;
log-facility local7;
update-optimization off;

Subnet

/etc/dhcp/dhcpd.conf_subnet

ddns-update-style standard;
ddns-updates on;
ddns-domainname "kallenberg.dk";
ignore client-updates;
update-static-leases on;

# forward zones for DNS updates
zone kallenberg.dk {
        primary 192.168.1.36;
        key ddns-update;
}

# reserse zone for DNS updates
zone 1.168.192.in-addr.arpa {
        primary 192.168.1.36;
        key ddns-update;
}

subnet 192.168.1.0 netmask 255.255.255.0 {

        pool {
                failover peer "network";
                range 192.168.1.96 192.168.1.127;
        }

        option routers 192.168.1.1;
        option subnet-mask 255.255.255.0;
        option broadcast-address 192.168.1.255;
        option domain-name "kallenberg.dk";
        option domain-name-servers 192.168.1.36, 192.168.1.37;
        option ntp-servers 192.168.1.40, 192.168.1.41;
        #option ntp-servers ntp01, ntp02;

        default-lease-time 3600;
        max-lease-time 7200;

}

Static IP-adresses

We would like servers to have static IP-adresses, but not more static than controlling it from the DHCP server. Remember to keep this file synchronized with the one on the DHCP secondary.

/etc/dhcp/dhcpd.conf_static

host ntp01 {
        hardware ethernet 52:54:00:9e:33:2f;
        fixed-address 192.168.1.40;
}

host ntp02 {
        hardware ethernet 52:54:00:c5:f1:92;
        fixed-address 192.168.1.41;
}

DHCP Primary

/etc/dhcp/dhcpd.conf_primary

failover peer "network" {
        primary;
        address 192.168.1.38;
        port 647;
        peer address 192.168.1.39;
        peer port 647;
        max-response-delay 60;
        max-unacked-updates 10;
        mclt 3600;
        split 128;
        load balance max seconds 3;
}

Start the server

service isc-dhcp-server start

Notice that even though the server is started, it will not begin to hand out IP-addresses yet. It will wait until it sees the secondary. Once it has seen the secondary, the DHCP server will begin to work.

References

None: DHCP Primary (last edited 2021-03-15 21:24:19 by Kristian Kallenberg)