Configuring a DHCPv4 server on a VRF

Prerequisites
  • An enabled layer 3 interface.

  • A VRF.

  • An external TFTP server to host BOOTP image files (optional).

  • An external storage device installed and configured (optional).

Procedure
  1. Assign the DHCPv4 server to a VRF with the command dhcp-server vrf. This switches to the DHCPv4 server configuration context.
  2. If you want the DHCPv4 server to be the sole authority for IP addresses on the VRF, enable authoritative mode with the command authoritative.
  3. Define an address pool for the VRF with the command pool. This switches to the DHCPv4 server pool context. Customize pool settings as follows:
    1. Define the range of addresses in the pool with the command range.
    2. Set the lease time for addresses in the pool with the command lease.
    3. Set the domain name for the pool with the command domain-name.
    4. Define up to four default routers with the command default-router.
    5. Define up to four DNS servers with the command dns-server.
    6. Create static bindings for specific addresses in the pool with the command static-bind.
    7. Configure custom DHCPv4 options for the pool with the command option.
    8. Configure NetBIOS support with the commands netbios-name-server and netbios-node-type.
    9. Configure BOOTP options with the command bootp.
    10. Exit the DHCPv4 server pool context with the command exit.
  4. Enable the DHCP server on the VRF with the command enable.
  5. Configure support for persistent external storage of DHCP settings with the command dhcp-server external-storage.
  6. View DHCPv4 server configuration settings with the command show dhcp-server all-vrfs.

Example

This example creates the following configuration:

  • Configures the DHCPv4 server on VRF primary-vrf.
  • Enables authoritative mode.

  • Defines the pool primary-pool with the following settings:

    • Address range: 10.0.0.1 to 10.0.0.100.

    • Lease time: 12 hours.

    • Domain name: example.org.in.

    • Default routers: 10.30.30.1 and 10.30.30.2.

    • DNS servers: 125.0.0.1 and 125.0.0.2.

    • Static binding of 10.0.0.11 for MAC address 24:be:05:24:75:73.

    • DHCP custom option 3 with IP address 10.30.30.3.

  • Enables the DHCPv4 server.

switch(config)# dhcp-server vrf primary
switch(config-dhcp-server)# pool primary-pool
switch(config-dhcp-server-pool)# range 10.0.0.1 10.0.0.100
switch(config-dhcp-server-pool)# lease 12:00:00
switch(config-dhcp-server-pool)# domain-name example.org.in
switch(config-dhcp-server-pool)# default-router ip 10.30.30.1 10.30.30.2
switch(config-dhcp-server-pool)# dns-server 125.0.0.1 125.0.0.2
switch(config-dhcp-server-pool)# static-bind ip 10.0.0.11 mac 24:be:05:24:75:73
switch(config-dhcp-server-pool)# option 3 ip 10.30.30.3
switch(config-dhcp-server-pool)# exit
switch(config-dhcp-server)# enable