Configure DHCP Server or Relay on a Switch

Follow these steps to configure DHCP server or relay on a switch.

Prerequisites

Before configuring the DHCP server or relay, ensure the following:

  • The VLAN for which DHCP server will be configured on switch is assigned to the ports connecting to the DHCP clients. You can do this by applying a relevant port profile to the port. For more information about port profiles, see Static and Dynamic Port Profiles.
  • The switch has a Static IP Configuration or Additional IP configuration for the network to run DHCP server. Or the L3 Interface is configured for DHCP server or relay.

See Wired Clients for information on displaying DHCP client properties in the Wired Clients list.

Configure DHCP Server

To configure DHCP server on a switch:

  1. Navigate to Switches on the left menu and then click a Switch from the list.
    The switch details page is displayed.
  2. On the switch details page, scroll down to the DHCP Server / Relay tile in the Services section.
    User interface for managing network switches, showing DHCP Server/Relay settings for switch S2-EX1 with red error message: At least one DHCP network is required. Options to enable or disable Campus Fabric Defined, section showing no networks defined, and button to add DHCP network. Navigation panel includes Monitor, Marvis, Clients, Access Points, Switches, WAN Edges, Mist Edges, and Location. Top bar includes Utilities, Save, and Cancel options.
  3. On the DHCP Server / Relay tile, select the Enabled check box and then click Add DHCP Network.
    The DHCP Server / Relay configuration window is displayed.
  4. Ensure that Server is selected as configuration Type.
  5. From the Network drop-down list, select a network for the DHCP server.
  6. Specify the following fields:
    • IP Start—The starting IP address within the DHCP IP address assignment pool.

    • IP End—The ending IP address within the DHCP IP address assignment pool.

    • Gateway—Default gateway for the DHCP client. Usually, it is the switch IRB IP address for the corresponding network.

    • DNS Servers (Optional)—You can add up to three DNS IP addresses in a comma separated format.

    • DNS Suffix (Optional)—You can add up to three domain suffixes in a comma separated format.

    Configuration interface for adding a DHCP network with type set to Server, network ID 10 labeled vl10, IP range 10.0.0.100 to 10.0.0.200, gateway 10.0.0.10, DNS servers 8.8.8.8, 8.8.4.4, 1.0.0.1, and DNS suffix test.net, tesing1.net, testing3.net.

    If you do not configure the DNS Servers and DNS Suffix, Mist auto-generates the configuration by taking DNS servers and DNS Suffix configured at the switch level.

  7. Save the changes.

    The following configuration will be applied to the API /sites/:site-id/devices/device-id:

    DHCP server JSON configuration showing enabled status, VLAN 10 with IP pool from 10.0.0.100 to 10.0.0.200, gateway 10.0.0.10, DNS servers 8.8.8.8, 8.8.4.4, 1.0.0.1, and DNS suffixes test.net, testing1.net, testing3.net.

    Check the corresponding intended configuration to be pushed to the following API: /sites/:site-id/devices/device-id/config_cmd

    The DHCP server is enabled on the irb.10 interface for the vl10. The following example applies to Junos switches:

    The address assignment pool configuration looks like the below (applicable to Junos switches):

  8. Verify the configuration on the switch by using the following CLI. The following example is applicable to Junos switches:
    Configuration comparison showing changes on a network device. DHCP relay removed and replaced with a local DHCP server setup. Key updates include DHCP server under services for group vl10 using interface irb.10, address assignment pool vl10 for network 10.0.0.0/24 with IP range 10.0.0.100 to 10.0.0.200, DHCP attributes defining name servers 8.8.8.8, 8.8.4.4, 1.0.0.1, router 10.0.0.10, and domain names test.net tesing1.net testing3.net.

    The DHCP clients for v110 networks should now be assigned IP address by DHCP server as shown below:

    DHCP server bindings showing two client IPs, MAC addresses, lease states, expiration times, interfaces, and detailed lease information for troubleshooting.

    The example above apply to Junos switches.

Here are some useful Junos CLI commands:

  • show dhcp server binding or show dhcp server binding detail—To view the DHCP server binding information.

  • show dhcp server statistics—To view the DHCP messages sent/received statistics.
  • clear dhcp server binding interface x-x/x/x—To clear the DHCP client binding for a client on a particular interface.
  • clear dhcp server binding <address>—To clear the DHCP client binding based on an IP address or MAC address of the wired client.

Configure DHCP Relay

To configure DHCP relay on a switch:

  1. Navigate to Switches on the left menu and then click a Switch from the List.
    The switch details page is displayed.
  2. On the switch details page, scroll down to the DHCP Server / Relay tile in the Services section.
    User interface for managing network switches, showing DHCP Server/Relay settings for switch S2-EX1 with red error message: At least one DHCP network is required. Options to enable or disable Campus Fabric Defined, section showing no networks defined, and button to add DHCP network. Navigation panel includes Monitor, Marvis, Clients, Access Points, Switches, WAN Edges, Mist Edges, and Location. Top bar includes Utilities, Save, and Cancel options.
  3. On the DHCP Server / Relay tile, select the Enabled check box and then click Add DHCP Network.
    The DHCP Server / Relay configuration window is displayed.
  4. Select Relay as configuration Type.
    DHCP configuration form titled DHCP SERVER / RELAY with error message IPv4 or IPv6 DHCP Servers are required. Includes type selection for Server or Relay, network field with add button, text boxes for IPv4 and IPv6 server addresses with format notes.
  5. In the Network field, click + to add networks for the DHCP relay.
    Note:

    Ensure that a corresponding Layer 3 interface is configured for the VLAN on which DHCP services are provided. This L3 interface is required for the device to process and forward DHCP traffic for that VLAN.

  6. In the IPv4 and IPv6 DHCP Servers field, configure the IP address for the remote DHCP server. You can add up to three IP addresses in a comma separated format.
  7. Save the changes.

    The following configuration will be applied to the API /sites/:site-id/devices/device-id:JSON configuration showing DHCP enabled with type relay and server IP 192.168.1.1 under site and device-specific paths.

    Check the corresponding intended configuration to be pushed on following API: /sites/:site-id/devices/device-id/config_cmd

    The configuration looks like the below (this example apply to Junos switches):

  8. Verify the configuration on the switch using the following CLI. The following sample CLI commands apply to Junos switches:
    Configuration snippet showing DHCP relay setup on Junos OS. Server-group vl11 with DHCP server 192.168.1.1 is linked to interface irb.11 under forwarding-options hierarchy.
  9. Make sure the remote DHCP server is reachable from the switch. The following sample CLI commands apply to Junos switches:
    Ping command output showing connectivity test to 192.168.1.1 with 2 packets sent and received, 0 percent packet loss, and round-trip times ranging from 7.553 ms to 16.166 ms.
  10. Verify DHCP relay binding on the switch. The following sample CLI commands apply to Junos switches:
    Output of the command show dhcp relay binding detail on a Juniper device showing details like client IP 11.0.0.218, MAC address d4:20:b0:83:dd:9c, lease state bound, expiration time 2022-06-16 18:46:58 IST, incoming interface irb.11:ge-0/0/8.0, DHCP server IP 192.168.1.3, relay address 11.0.0.10, and session ID 15.

See also: DHCP Relay Agent.