DHCP Servers

A DHCP server automatically provides and assigns IP addresses and other network parameters to client devices. It relies on DHCP to respond to broadcast requests from clients.

Basic Configuration

This section shows you how to configure a DHCP server using the following topology, where the DHCP server is a switch running Cumulus Linux.

To configure the DHCP server on a Cumulus Linux switch:

  • Create a DHCP subnet (pool) by providing an IPv4 or IPv6 prefix.
  • Provide the IP address of the DNS Server you want to use in this subnet. You can assign multiple DNS servers.
  • Provide the domain name you want to use for this subnet for name resolution (optional).
  • Define the range of IP addresses available for assignment.
  • Provide the default gateway IP address (optional).

In addition, you can configure a static IP address for a resource, such as a server or printer:

  • Create an ID for the static assignment. This is typically the name of the resource.
  • Provide the static IP address you want to assign to this resource.
  • Provide the MAC address of the resource to which you want to assign the IP address. Instead of the MAC address, you can set the interface name for the static assignment; for example swp1.

  • To configure static IP address assignments, you must first configure a subnet.
  • You can set the DNS server IP address and domain name globally or specify different DNS server IP addresses and domain names for different subnets.

The following example configures the subnet 10.1.10.0/24 with DNS and static DHCP assignments for server1.

cumulus@switch:~$ nv set vrf default dhcp-server-v4 subnet 10.1.10.0/24
cumulus@switch:~$ nv set vrf default dhcp-server-v4 subnet 10.1.10.0/24 domain-name example.com
cumulus@switch:~$ nv set vrf default dhcp-server-v4 subnet 10.1.10.0/24 domain-name-server 192.168.200.53
cumulus@switch:~$ nv set vrf default dhcp-server-v4 subnet 10.1.10.0/24 range 10.1.10.100 to 10.1.10.199
cumulus@switch:~$ nv set vrf default dhcp-server-v4 subnet 10.1.10.0/24 gateway 10.1.10.1
cumulus@switch:~$ nv set vrf default dhcp-server-v4 static-host server1
cumulus@switch:~$ nv set vrf default dhcp-server-v4 static-host server1 ip-address 10.0.0.2
cumulus@switch:~$ nv set vrf default dhcp-server-v4 static-host server1 mac-address 44:38:39:00:01:7e
cumulus@switch:~$ nv config apply

To allocate DHCP addresses from the configured subnet, you must configure an interface with an IP address from the subnet. For example:

cumulus@switch:~$ nv set interface vlan10 ip address 10.1.10.1/24
cumulus@switch:~$ nv config apply

To set the DNS server IP address and domain name globally, use the nv set vrf <vrf-id> dhcp-server-v4 domain-name-server <address> or nv set vrf <vrf-id> dhcp-server-v6 domain-name-server <address> and the nv set vrf <vrf-id> dhcp-server-v4 domain-name <domain> nv set vrf <vrf-id> dhcp-server-v6 domain-name <domain>commands.

To set the interface name for the static assignment, run the nv set vrf <vrf-id> dhcp-server-v4 static-host <server> ifname or nv set vrf <vrf-id> dhcp-server-v6 static-host <server> ifnamecommand.

cumulus@switch:~$ nv set vrf default dhcp-server-v6 subnet 2001:db8:1::/64 
cumulus@switch:~$ nv set vrf default dhcp-server-v6 subnet 2001:db8:1::/64 domain-name-server 2001:db8::64
cumulus@switch:~$ nv set vrf default dhcp-server-v6 subnet 2001:db8:1::/64 domain-name example.com
cumulus@switch:~$ nv set vrf default dhcp-server-v6 subnet 2001:db8:1::/64 range 2001:db8::100 to 2001:db8::199 
cumulus@switch:~$ nv set vrf default dhcp-server-v6 static-host server1
cumulus@switch:~$ nv set vrf default dhcp-server-v6 static-host server1 ip-address 2001:db8::100
cumulus@switch:~$ nv set vrf default dhcp-server-v6 static-host server1 mac-address 44:38:39:00:01:7e
cumulus@switch:~$ nv config apply

To allocate DHCP addresses from the configured subnet, you must configure an interface with an IP address from the subnet. For example:

cumulus@switch:~$ nv set interface vlan10 ip address 2001:db8::10/64
cumulus@switch:~$ nv config apply

To set the DNS server IP address and domain name globally, use the nv set vrf <vrf-id> dhcp-server-v6 domain-name-server <address> and nv set vrf <vrf-id> dhcp-server-v6 domain-name <domain> commands.

  1. In a text editor, edit the /etc/dhcp/dhcpd-default.conf file. Use following configuration as an example:

    cumulus@switch:~$ sudo nano /etc/dhcp/dhcpd-default.conf
    authoritative;
    subnet 10.1.10.0 netmask 255.255.255.0 {
       option domain-name-servers 192.168.200.53;
       option domain-name example.com;
       default-lease-time 3600;
       max-lease-time 3600;
       default-url ;
       ping-check off;
       range 10.1.10.100 10.1.10.199;
    

    } #Statics group { host server1 { hardware ethernet 44:38:39:00:01:7e; fixed-address 10.0.0.2; } }

To set the DNS server IP address and domain name globally, add the DNS server IP address and domain name before the subnet information in the /etc/dhcp/dhcpd-default.conf file. For example:

cumulus@switch:~$ sudo nano /etc/dhcp/dhcpd-default.conf
authoritative;
option domain-name servers;
option domain-name-servers 192.168.200.51;
subnet 10.1.10.0 netmask 255.255.255.0
   default-lease-time 3600;
   max-lease-time 3600;
...
  1. Edit the /etc/default/isc-dhcp-server configuration file so that the DHCP server starts when the system boots. Here is an example configuration:

    cumulus@switch:~$ sudo nano /etc/default/isc-dhcp-server
    DHCPD_CONF="-cf /etc/dhcp/dhcpd-default.conf"
    

    INTERFACES="swp1"

  2. Enable and start the dhcpd service:

    cumulus@switch:~$ sudo systemctl enable dhcpd.service
    cumulus@switch:~$ sudo systemctl start dhcpd.service
    
  1. In a text editor, edit the /etc/dhcp/dhcpd6-default.conf file. Use following configuration as an example:

    cumulus@switch:~$ sudo nano /etc/dhcp/dhcpd6-default.conf
    authoritative;
    subnet6 2001:db8:1::/64 {
       option dhcp6.name-servers 2001:db8::64;
       option domain-name "example.com";
       default-lease-time 3600;
       max-lease-time 3600;
       ping-check off;
       range6 2001:db8::100 2001:db8::199;
    }
    #Statics
    group {
       host server1 {
           hardware ethernet 44:38:39:00:01:7e;
           fixed-address6 2001:db8::100;
       }
    }
    

To set the DNS server IP address and domain name globally, add the DNS server IP address and domain name before the pool information in the /etc/dhcp/dhcpd6-default.conf file. For example:

cumulus@switch:~$ sudo nano /etc/dhcp/dhcpd6-default.conf
authoritative;
option domain-name servers;
option domain-name-servers 2001:db8:100::64;
subnet6 2001:db8::/64 {
   default-lease-time 3600;
   max-lease-time 3600;
...
  1. Edit the /etc/default/isc-dhcp-server6 file so that the DHCP server launches when the system boots. Here is an example configuration:

    cumulus@switch:~$ sudo nano /etc/default/isc-dhcp-server6
    DHCPD_CONF="-cf /etc/dhcp/dhcpd6-default.conf"
    

    INTERFACES="swp1"

  2. Enable and start the dhcpd6 service:

    cumulus@switch:~$ sudo systemctl enable dhcpd6.service
    cumulus@switch:~$ sudo systemctl start dhcpd6.service
    

Optional Configuration

Lease Time

You can set the network address lease time assigned to DHCP clients. You can specify a number between 180 and 31536000. The default lease time is 3600 seconds.

cumulus@switch:~$ nv set vrf default dhcp-server-v4 subnet 10.1.10.0/24 lease-time 200000
cumulus@switch:~$ nv config apply
cumulus@switch:~$ nv set vrf default dhcp-server-v6 subnet 2001:db8::/64 lease-time 200000
cumulus@switch:~$ nv config apply
  1. Edit the /etc/dhcp/dhcpd-default.conf file to set the lease time (in seconds):

    cumulus@switch:~$ sudo nano /etc/dhcp/dhcpd-default.conf
    authoritative;
    subnet 10.1.10.0 netmask 255.255.255.0 {
       option domain-name-servers 192.168.200.53;
       option domain-name example.com;
       default-lease-time 200000;
       max-lease-time 200000;
       ping-check off;
       range 10.1.10.100 10.1.10.199;
    }
    
  2. Restart the dhcpd service:

    cumulus@switch:~$ sudo systemctl restart dhcpd.service
    
  1. Edit the /etc/dhcp/dhcpd6-default.conf file to set the lease time (in seconds):

    cumulus@switch:~$ sudo nano/etc/dhcp/dhcpd6-default.conf
    authoritative;
    subnet6 2001:db8::/64 {
       option domain-name-servers 2001:db8:100::64;
       option domain-name example.com;
       default-lease-time 200000;
       max-lease-time 200000;
       default-url;
       ping-check off;
       range6 2001:db8:1::100 2001:db8::199;
    }
    
  2. Restart the dhcpd6 service:

    cumulus@switch:~$ sudo systemctl restart dhcpd6.service
    

Ping Check

Configure the DHCP server to ping the address you want to assign to a client before issuing the IP address. If there is no response, DHCP delivers the IP address; otherwise, it attempts the next available address in the range.

cumulus@switch:~$ nv set vrf default dhcp-server-v4 subnet 10.1.10.0/24 ping-check enabled
cumulus@switch:~$ nv config apply
cumulus@switch:~$ nv set vrf default dhcp-server-v6 subnet 2001:db8::/64 ping-check enabled
cumulus@switch:~$ nv config apply
  1. Edit the /etc/dhcp/dhcpd-default.conf file to add ping-check true;:

    cumulus@switch:~$ sudo nano /etc/dhcp/dhcpd-default.conf
    authoritative;
    subnet 10.1.10.0 netmask 255.255.255.0 {
       option domain-name-servers 192.168.200.53;
       option domain-name example.com;
       default-lease-time 200000;
       max-lease-time 200000;
       ping-check on
       range 10.1.10.100 10.1.10.199;
    }
    
  2. Restart the dhcpd service:

    cumulus@switch:~$ sudo systemctl restart dhcpd.service
    
  1. Edit the /etc/dhcp/dhcpd6-default.conf file to add ping-check true;:

    cumulus@switch:~$ sudo nano /etc/dhcp/dhcpd6-default.conf
    authoritative;
    subnet6 2001:db8::/64 {
       option domain-name-servers 2001:db8:100::64;
       option domain-name example.com;
       default-lease-time 200000;
       max-lease-time 200000;
       ping-check on;
       range6 2001:db8:1::100 2001:db8::199;
       }
    }
    
  2. Restart the dhcpd6 service:

    cumulus@switch:~$ sudo systemctl restart dhcpd6.service
    

Assign a Port-based IP Address

You can assign an IP address and other DHCP options based on physical location or port regardless of MAC address to clients that attach directly to the Cumulus Linux switch through a switch port. This is helpful when swapping out switches and servers; you can avoid the inconvenience of collecting the MAC address and sending it to the network administrator to modify the DHCP server configuration.

cumulus@switch:~$ nv set vrf default dhcp-server-v4 static-host server2
cumulus@switch:~$ nv set vrf default dhcp-server-v4 static-host server2 ip-address 10.0.0.3
cumulus@switch:~$ nv set vrf default dhcp-server-v4 static-host server2 ifname swp1
cumulus@switch:~$ nv config apply
cumulus@switch:~$ nv set vrf default dhcp-server-v6 static-host server2
cumulus@switch:~$ nv set vrf default dhcp-server-v6 static-host server2 ip-address 2001:db8:1::100
cumulus@switch:~$ nv set vrf default dhcp-server-v4 static-host server2 ifname swp1
cumulus@switch:~$ nv config apply
  1. Edit the /etc/dhcp/dhcpd-default.conf file to add the interface and IP address:
cumulus@switch:~$ sudo nano /etc/dhcp/dhcpd-default.conf
# Statics
group {
    host server2 {
        ifname "swp1";
        fixed-address 10.0.0.3;
    }
}
   ...
  1. Restart the dhcpd service:

    cumulus@switch:~$ sudo systemctl restart dhcpd.service
    
  1. Edit the /etc/dhcp/dhcpd6-default.conf file to add the interface and IP address:

    cumulus@switch:~$ sudo nano /etc/dhcp/dhcpd6-default.conf
    ...
    host server2 {
        ifname "swp1" ;
        fixed-address 2001:db8::100;
    }
    ...
    
  2. Restart the dhcpd6 service:

    cumulus@switch:~$ sudo systemctl restart dhcpd6.service
    

Multiple Static IP Address Assignments

Cumulus Linux enables you to assign multiple static IP addresses for a single connected host using the vendor-class ID in the DHCP request packet. Use this feature if you have different DHCP requests coming in on the same interface on the DHCP server from different end host applications.

The following examples assign:

  • The fixed IPv4 address 10.1.10.2 (2001:db8:1::2 for IPv6) for DHCP requests coming in on swp6 with the vendor-class-id string bmc-string.
  • The fixed IPv4 address 10.1.10.3 (2001:db8:1::3 for IPv6) for DHCP requests coming in on swp6 with the vendor-class-id string mgmt-string.
cumulus@leaf01:mgmt:~$ nv set vrf default dhcp-server-v4 static-host server2 ifname swp6 vendor-class-id bmc-string
cumulus@leaf01:mgmt:~$ nv set vrf default dhcp-server-v4 static-host server2 ip-address 10.1.10.2 
cumulus@leaf01:mgmt:~$ nv set vrf default dhcp-server-v4 static-host server3 ifname swp6 vendor-class-id mgmt-string
cumulus@leaf01:mgmt:~$ nv set vrf default dhcp-server-v4 static-host server3 ip-address 10.1.10.3
cumulus@leaf01:mgmt:~$ nv config apply
cumulus@leaf01:mgmt:~$ nv set vrf default dhcp-server-v6 static-host server2 ifname swp6 
cumulus@leaf01:mgmt:~$ nv set vrf default dhcp-server-v6 static-host server2 ip-address 2001:db8:1::2
cumulus@leaf01:mgmt:~$ nv set vrf default dhcp-server-v6 static-host server2 vendor-class-id bmc-string
cumulus@leaf01:mgmt:~$ nv set vrf default dhcp-server-v6 static-host server3 ifname swp6 
cumulus@leaf01:mgmt:~$ nv set vrf default dhcp-server-v6 static-host server3 ip-address 2001:db8:1::3
cumulus@leaf01:mgmt:~$ nv set vrf default dhcp-server-v6 static-host server3 vendor-class-id mgmt-string
cumulus@leaf01:mgmt:~$ nv config apply
  1. Edit the /etc/dhcp/dhcpd-default.conf file to add the interface and IP address:

    cumulus@switch:~$ sudo nano /etc/dhcp/dhcpd-default.conf
    ...
    # Statics
    group {
        host server2 {
            ifname "swp6";
            vendor-class "bmc-string";
            fixed-address 10.1.10.2;
        }
        host server3 {
            ifname "swp6";
            vendor-class "mgmt-string";
            fixed-address 10.1.10.3;
        }
    }
    ...
    
  2. Restart the dhcpd service:

    cumulus@switch:~$ sudo systemctl restart dhcpd.service
    
  1. Edit the /etc/dhcp/dhcpd6-default.conf file to add the interface and IP address:

    cumulus@switch:~$ sudo nano /etc/dhcp/dhcpd6-default.conf
    ...
    # Statics
    group {
        host server2 {
                ifname "swp6";
                vendor-class "bmc-string";
                fixed-address 2001:db8:1::2;
            }
            host server3 {
                ifname "swp6";
                vendor-class "mgmt-string";
                fixed-address 2001:db8:1::3;
        }
    }
    ...
    
  2. Restart the dhcpd6 service:

    cumulus@switch:~$ sudo systemctl restart dhcpd6.service
    

The vendor-class-id string supports an exact-match with the vendor-class-id on the incoming packet.

To show the DHCP static configuration for all hosts, run the nv show vrf <vrf-id> dhcp-server-v4 static-host --rev=applied or the nv show vrf <vrf-id> dhcp-server-v6 static-host --rev=applied command:

cumulus@leaf01:mgmt:~$ nv show vrf default dhcp-server-v4 static-host --rev=applied
         agent-remoteid-circuitid  ip-address  MAC address        provision-url  Summary     
-------  ------------------------  ----------  -----------------  -------------  ------------
server1                            10.0.0.2    44:38:39:00:01:7e                             
server2                            10.0.0.3                                      ifname: swp1

To show the DHCP static configuration for a specific host, run the nv show vrf <vrf-id> dhcp-server-v4 static-host <host-id> or the nv show vrf <vrf-id> dhcp-server-v6 static-host <host-id> command:

cumulus@leaf01:mgmt:~$ nv show vrf default dhcp-server-v4 static-host server2
            applied  
----------  ---------
ip-address  10.1.10.2
[ifname]    swp6

Troubleshooting

To show the current DHCP server settings, run the nv show vrf <vrf-id> dhcp-server-v4 command for IPv4 or nv show vrf <vrf-id> dhcp-server-v6 for IPv6:

cumulus@leaf01:mgmt:~$ nv show vrf default dhcp-server-v4
               applied     
-------------  ------------
[subnet]       10.1.10.0/24
[static-host]  server1     
[static-host]  server2     
[static-host]  server3

The DHCP server determines if a DHCP request is a relay or a non-relay DHCP request. Run the following command to see the DHCP request:

cumulus@server02:~$ sudo tail /var/log/syslog | grep dhcpd
2016-12-05T19:03:35.379633+00:00 server02 dhcpd: Relay-forward message from 2001:db8:101::1 port 547, link address 2001:db8:101::1, peer address fe80::4638:39ff:fe00:3
2016-12-05T19:03:35.380081+00:00 server02 dhcpd: Advertise NA: address 2001:db8::110 to client with duid 00:01:00:01:1f:d8:75:3a:44:38:39:00:00:03 iaid = 956301315 valid for 600 seconds
2016-12-05T19:03:35.380470+00:00 server02 dhcpd: Sending Relay-reply to 2001:db8:101::1 port 547

Considerations

DHCP discover packets transiting the switch are also sent to the CPU for additional processing, then dropped after being switched by the hardware. This causes the RX_DRP and HwIfInDiscards counters to increment on the interface even though the hardware forwards the packet correctly.