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:

vsr 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:

    vsr 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:

    vsr 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:

    vsr 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:

    vsr 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:

    vsr 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.

Warning

Static address assignments are not written in the machine leases, only the dynamic addresses are. As a consequence, they are neither displayed in show dhcp-server nor in show state.

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:

    vsr 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:

    vsr 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.

DNS search domain name

  • Specify the list of DNS domain names that the DHCP client should use for its DNS search, by order of preference:

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

    Domain name available for the client search.

NetBIOS name server

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

    vsr 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:

    vsr 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:

    vsr 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:

    vsr 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).

    vsr 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:

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

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

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

Vendor class identifier

  • Specify the vendor class identifier name sent by the client to be identified:

    vsr running subnet A.B.C.D/M# dhcp-options vendor-class-identifier NAME
    
    NAME

    Client vendor class identifier.

Configuration example

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

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

vsr> 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:

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

    vsr> show dhcp-server vrf VRFNAME
    
    VRFNAME

    The VRF name.

Example

vsr> show dhcp-server vrf vrf1
IP Address MAC Address       Lease Start         Lease End           State
========== ===========       ===========         =========           =====
10.100.0.3 de:ed:01:e4:13:29 2019/01/09 17:42:36 2019/01/09 18:42:36 active
10.100.0.3 de:ed:01:e4:13:29 2019/01/09 16:42:36 2019/01/09 17:42:36 expired

Flushing DHCP server leases

You can flush the DHCP leases by IP, L3VRF, VRF and NIC, those filters are used to narrow down the flush query.

  • Flush all DHCP leases from a specific IP within a specific L3VRF within a specific VRF:

    vsr> flush dhcp-server lease ip-address IP_ADDRESS vrf VRFNAME l3vrf L3VRFNAME
    
    IP_ADDRESS

    The IP address to be flushed.

    VRFNAME

    The VRF name.

    L3VRFNAME

    The L3VRF name.

Example

vsr> flush dhcp-server lease ip-address 10.100.0.3 vrf vrf1 l3vrf l3vrf1
Leases flushed successfully.

Note

Flushing a lease will automatically restart the DHCP server responsible of this lease.