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 commanddhcp-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 commandauthoritative.
  3. Define an address pool for the VRF with the commandpool. This switches to the DHCPv4 server pool context. Customize pool settings as follows:
    1. Define the range of addresses in the pool with the commandrange.
    2. Set the lease time for addresses in the pool with the commandlease.
    3. Set the domain name for the pool with the command域名.
    4. Define up to four default routers with the commanddefault-router.
    5. Define up to four DNS servers with the commanddns-server.
    6. Create static bindings for specific addresses in the pool with the commandstatic-bind.
    7. Configure custom DHCPv4 options for the pool with the commandoption.
    8. Configure NetBIOS support with the commandsnetbios-name-serverandnetbios-node-type.
    9. Configure BOOTP options with the commandbootp.
    10. 退出DHCPv4上下文wi服务器池th the commandexit.
  4. Enable the DHCP server on the VRF with the commandenable.
  5. Configure support for persistent external storage of DHCP settings with the commanddhcp-server external-storage.
  6. View DHCPv4 server configuration settings with the commandshow dhcp-server all-vrfs.

Example

This example creates the following configuration:

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

  • Defines the poolprimary-poolwith the following settings:

    • Address range:10.0.0.1to10.0.0.100.

    • Lease time: 12 hours.

    • Domain name:example.org.in.

    • Default routers:10.30.30.1and10.30.30.2.

    • DNS servers:125.0.0.1and125.0.0.2.

    • Static binding of10.0.0.11for MAC address24:be:05:24:75:73.

    • DHCP custom option3with IP address10.30.30.3.

  • Enables the DHCPv4 server.

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