Description

This article provides information on how to configure the Legacy EX-series switch as a DHCP server. 

Symptoms

  • The Dynamic Host Configuration Protocol (DHCP) server provides a framework to pass configuration information to client hosts (such as PCs) on a TCP/IP network.

  • A router or interface that acts as a DHCP server can allocate network IP addresses and deliver configuration settings to client hosts, without user intervention.

  • The DHCP access service minimizes the overhead that is required to add clients to the network by providing a centralized, server-based setup.

  • You do not have to manually create and maintain IP address assignments for clients. DHCP is defined in RFC 2131 Dynamic Host Configuration Protocol .

Solution

The following steps are used to configure the EX-Series switch as a DHCP server:

  1. Create DHCP services on the EX switch by creating a DHCP pool:
    juniper@EX# set system services dhcp pool 10.0.0.0/24
  2. Add the lowest IP address and highest IP address in DHCP pool address-range (optional):
    juniper@EX# set system services dhcp pool 10.0.0.0/24 address-range low 10.0.0.2 high 10.0.0.252
  3. Add the router IP address to be supplied with the IP address (optional):
    juniper@EX# set system services dhcp pool 10.0.0.0/24 router 10.0.0.1
  4. Create a virtual interface associated to the DHCP pool:
    Juniper@EX# set interface vlan unit 0 family inet address 10.0.0.1/24
  5. Associate virtual interface to a VLAN where DHCP client’s machines will be connected
    Juniper@EX> set vlan default l3-interface vlan.0
    Command List Summary:
    set system services dhcp pool 10.0.0.0/24 address-range low 10.0.0.2
    set system services dhcp pool 10.0.0.0/24 address-range high 10.0.0.252
    set system services dhcp pool 10.0.0.0/24 router 10.0.0.1
    set interfaces vlan unit 0 family inet address 10.0.0.1/24
    set vlans default l3-interface vlan.0
  6. Repeat steps 1 to 3 to add more DHCP pools for different subnets.

Note : This article is just for setting up DHCP locally on the EX-series switch. You can also configure routed virtual interfaces on the EX switch for each pool; this is covered in the EX-Series documentation and other associated articles.

Verifying DHCP operations on EX switches :

Verify the statistics of DHCP messages between server and the clients
juniper@EX# run show system services dhcp statistics

Packets dropped:
Total 2233

Messages received:
BOOTREQUEST  0
DHCPDECLINE  0
DHCPDISCOVER 2
DHCPINFORM   0
DHCPRELEASE  0
DHCPREQUEST  8

Messages sent:
BOOTREPLY    0
DHCPOFFER    2
DHCPACK      4
DHCPNAK      0

Verify the DHCP IP address allocations (bindings) to DHCP clients:
juniper@EX# run show system services dhcp binding
IP address Hardware address Type Lease expires at
10.0.0.3 00:23:9c:04:e3:43 dynamic 2012-11-14 18:04:40 PDT
10.0.0.4 00:a0:12:00:13:02 dynamic 2012-11-14 18:04:42 PDT
To view the DHCP binding for a specific IP address, the following command has to be issued
juniper@EX> show system services dhcp binding 10.0.0.3 detail
Dynamic binding information:
    IP address 10.0.0.3
    Hardware address 00:23:9c:04:e3:43
    Pool 10.0.0.0/24
    Request received on vlan.0

Lease information:
    Type DHCP
    Obtained at 2012-11-13 18:04:40 PDT
    Expires at 2012-11-14 18:04:40 PDT
    State active

DHCP options:
    Code: 1, Type: ip-address, Value: 255.255.255.0
    Code: 28, Type: ip-address, Value: 10.0.0.255
    Name: router, Value: [ 10.0.0.1 ]


Debugging DHCP operations on the switches :

Set traceoptions under DHCP to capture packets in log file:

juniper@EX# set system services dhcp traceoptions file
juniper@EX# set system services dhcp traceoptions flag all
To view the log file:
juniper@EX# run file show /var/log/
or
juniper@EX# run monitor start

Modification History

2020-05-02: Article reviewed for accuracy; added specific platforms (Legacy EX).
2022-01-25: Article very similar to KB11018 [juniper.net]. KB11018 [juniper.net] has additional configuration knobs and examples, tagged as duplicate of it. 

Related Information