DHCP Secondary

Network

We will give the DHCP secondary 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.37
        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. Also remember that switching off an existing DHCP server will cause all your devices to get new IP-adresses. Some devices may have to be rebooted to work properly again. If you use the same IP-adress range on both old and new DHCP server, then you may run into IP-address conflicts too.

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.

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_secondary";
include "/etc/dhcp/dhcpd.conf_subnet";
include "/etc/dhcp/dhcpd.conf_static";

Individual Config Files

/etc/dhcp/dhcpd.conf_default

option domain-name "kallenberg.dk";
option domain-name-servers 192.168.1.34, 192.168.1.35;
default-lease-time 3600;
max-lease-time 7200;
log-facility local7;

/etc/dhcp/dhcpd.conf_subnet

ddns-update-style interim;
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.34;
        key ddns-update;
}

# reserse zone for DNS updates
zone 1.168.192.in-addr.arpa {
        primary 192.168.1.34;
        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.34, 192.168.1.35;
        option ntp-servers 192.168.1.38, 192.168.1.39;
        #option ntp-servers ntp01, ntp02;

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

}

/etc/dhcp/dhcpd.conf_static

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

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

/etc/dhcp/dhcpd.conf_secondary

Start the server

service isc-dhcp-server start

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