DHCP server

Overview

A DHCP server is typically used to configure the IPv4 addresses of the hosts connected to its different LAN subnets, upon their request.

It needs at least one IPv4 subnet on which one interface is configured and a range of addresses to be allocated to DHCP clients.

You can configure the DHCP server in the dhcp server context:

vrouter running config# vrf VRFNAME dhcp server
VRFNAME
VRF name on which the DHCP server must run.

See also

The DHCP server command reference for details.

Subnet configuration

  • Specify which subnet the DHCP server should serve:

    vrouter running server# subnet A.B.C.D/M
    
    A.B.C.D/M

    IPv4 subnet address with prefix mask length.

Each subnet has its configuration parameters in a subcontext.

Address range management

The DHCP server manages a range of addresses to be allocated to DHCP clients.

  • Specify a range of addresses in a defined subnet:

    vrouter running subnet A.B.C.D/M# range A1.B1.C1.D1 A2.B2.C2.D2
    
    A1.B1.C1.D1

    First address of the range.

    A2.B2.C2.D2

    Last address of the range.

Note

The A1.B1.C1.D1 – A1.B2.C2.D2 address range must be included in the configured subnet.

Subnet interface

  • Specify on which interface the server should listen to DHCP requests:

    vrouter running subnet A.B.C.D/M# interface IFNAME
    
    IFNAME

    The interface name.

Note

  • The interface must be able to receive broadcast packets.
  • If this option is not set, the DHCP server will use the first interface that has an IP address corresponding to the subnet.

Default gateway

  • Specify the list of default gateways to provide to DHCP clients, by order of preference:

    vrouter running subnet A.B.C.D/M# default-gateway A.B.C.D
    
    A.B.C.D

    IPv4 address of the default gateway provided to the hosts.

Host management and static address assignment

You can reserve a specific IPv4 address for a given host (mainly servers, whose IPv4 address is supposed to be stable).

  • Define a fixed IPv4 address for a host:

    vrouter running subnet A.B.C.D/M# host NAME mac-address XX:XX:XX:XX:XX:XX ip-address A.B.C.D
    
    NAME

    The DHCP client host name.

    XX:XX:XX:XX:XX:XX

    Ethernet MAC address (e.g 00:02:b3:39:ba:d2).

    A.B.C.D

    IPv4 address to be provided to the host.

Note

Like ranges, the host IP address must be included in the configured subnet.

DHCP options

DHCP options can be specified in the root DHCP server context or overwritten per subnet.

Domain name

  • Specify the domain name to use by default:

    vrouter running subnet A.B.C.D/M# dhcp-options domain-name NAME
    
    NAME

    Domain name to send to clients.

DNS server address

  • Specify the list of default DNS servers, by order of preference:

    vrouter running subnet A.B.C.D/M# dhcp-options domain-name-server A.B.C.D
    
    A.B.C.D

    IPv4 server address provided to the hosts.

NetBIOS name server

  • Specify the list of default NetBIOS/WINS servers, by order of preference:

    vrouter running subnet A.B.C.D/M# dhcp-options netbios-name-server A.B.C.D
    
    A.B.C.D

    IPv4 NetBIOS server address provided to the hosts.

NetBIOS node type

  • Specify the NetBIOS node as broadcast mode and ignore WINS server address:

    vrouter running subnet A.B.C.D/M# dhcp-options netbios-node-type b-mode
    
  • Specify the NetBIOS node as always point-to-point and never broadcast request:

    vrouter running subnet A.B.C.D/M# dhcp-options netbios-node-type p-mode
    
  • Specify the NetBIOS node as try broadcast first if it fails to use WINS address:

    vrouter running subnet A.B.C.D/M# dhcp-options netbios-node-type m-mode
    
  • Specify the NetBIOS node as hybrid mode (starts with WINS address, then use broadcast request).

    vrouter running subnet A.B.C.D/M# dhcp-options netbios-node-type h-mode
    

Lease lengths management

You can define the lease lengths for the DHCP clients.

  • Define the default lease length:

    vrouter running subnet A.B.C.D/M# default-lease-time VALUE
    
  • Define the maximum lease length:

    vrouter running subnet A.B.C.D/M# max-lease-time VALUE
    
    VALUE

    Lease length in seconds (between 180 and 31536000 included).

Configuration example

vrouter> edit running
vrouter running config# vrf main
vrouter running vrf main# dhcp
vrouter running dhcp# server
vrouter running server# enabled true
vrouter running server# dhcp-options
vrouter running dhcp-options# domain-name-server 10.0.0.1
vrouter running dhcp-options# domain-name-server 10.0.0.2
vrouter running dhcp-options# ..
vrouter running server# subnet 1.0.0.0/24
vrouter running subnet 1.0.0.0/24# range 1.0.0.1 1.0.0.50
vrouter running subnet 1.0.0.0/24# range 1.0.0.51 1.0.0.100
vrouter running subnet 1.0.0.0/24# ..
vrouter running server# subnet 2.0.0.0/24
vrouter running subnet 2.0.0.0/24# interface eth0
vrouter running subnet 2.0.0.0/24# range 2.0.0.1 2.0.0.100
vrouter running subnet 2.0.0.0/24# ..
vrouter running server# ..
vrouter running dhcp# ..

The same configuration can be made using this NETCONF XML configuration:

vrouter> show config xml absolute vrf main  dhcp server
<config xmlns="urn:6wind:vrouter">
  <vrf>
    <name>main</name>
    <dhcp xmlns="urn:6wind:vrouter/dhcp">
      <server>
        <enabled>true</enabled>
        <default-lease-time>43200</default-lease-time>
        <max-lease-time>86400</max-lease-time>
        <dhcp-options>
          <domain-name-server>10.0.0.1</domain-name-server>
          <domain-name-server>10.0.0.2</domain-name-server>
        </dhcp-options>
        <subnet>
          <prefix>1.0.0.0/24</prefix>
          <dhcp-options/>
          <range>
            <start-ip>1.0.0.1</start-ip>
            <end-ip>1.0.0.50</end-ip>
          </range>
          <range>
            <start-ip>1.0.0.51</start-ip>
            <end-ip>1.0.0.100</end-ip>
          </range>
        </subnet>
        <subnet>
          <prefix>2.0.0.0/24</prefix>
          <dhcp-options/>
          <interface>eth0</interface>
          <range>
            <start-ip>2.0.0.1</start-ip>
            <end-ip>2.0.0.100</end-ip>
          </range>
        </subnet>
      </server>
    </dhcp>
  </vrf>
</config>

Displaying DHCP server leases

  • Display the DHCP server’s leases:

    vrouter> show dhcp-server
    
  • Display the DHCP server’s leases in a specific VRF:

    vrouter> show dhcp-server vrf VRFNAME
    
    VRFNAME

    The VRF name.

Example

vrouter> show dhcp-server vrf vrf1
authoring-byte-order little-endian;

server-duid "\000\001\000\001#\310\357\010\336\355\001\320\220\235";

lease 10.100.0.3 {
  starts 3 2019/01/09 17:42:36;
  ends 3 2019/01/09 18:42:36;
  cltt 3 2019/01/09 17:42:36;
  binding state active;
  next binding state free;
  rewind binding state free;
  hardware ethernet de:ed:01:e4:13:29;
}