Navigation
Guide That Contains This Content
[+] Expand All
[-] Collapse All

    Example: Configuring the Device as a DHCP Server

    This example shows how to configure the device as a DHCP server.

    For information on how to configure JDHCP in a routing instance, see https://kb.juniper.net/InfoCenter/index?page=content=KB26897=search=true.

    Requirements

    Before you begin:

    • Determine the IP address pools and the lease durations to use for each subnet.
    • Obtain the MAC addresses of the clients that require permanent IP addresses. Determine the IP addresses to use for these clients.
    • List the IP addresses that are available for the servers and devices on your network; for example, DNS, NetBIOS servers, boot servers, and gateway devices. See the Understanding Management Predefined Policy Applications.
    • Determine the DHCP options required by the subnets and clients in your network.

    Overview

    In this example, you configure the device as a DHCP server. You specify the IP address pool as 192.168.2.0/24 and from a low range of 192.168.2.2 to a high range of 192.168.2.254. You set the maximum-lease-time to 2,419,200. Then you specify the DNS server IP address as 192.168.10.2.

    Warning: Starting with Junos OS Release 15.1X49-D60 and Junos OS Release 17.3R1, the legacy DHCPD (DHCP daemon) configuration on all SRX Series devices is being deprecated. and only the new JDHCP CLI is supported. When you upgrade to Junos OS Release 15.1X49-D60 and later releases on a device that already has the DHCPD configuration, the following warning messages are displayed:

    WARNING: The DHCP configuration command used will be deprecated in future Junos releases.

    WARNING: Please see documentation for updated commands.

    Configuration

    CLI Quick Configuration

    To quickly configure this example, copy the following commands, paste them into a text file, remove any line breaks, change any details necessary to match your network configuration, copy and paste the commands into the CLI at the set access hierarchy level, and then enter commit from configuration mode.

    set interfaces ge-0/0/2 unit 0 family inet address 192.168.2.1/24set system services dhcp-local-server group g1 interface ge-0/0/2.0set access address-assignment pool p1 family inet network 192.168.2.0/24 set access address-assignment pool p1 family inet range r1 low 192.168.2.2set access address-assignment pool p1 family inet range r1 high 192.168.2.254set access address-assignment pool p1 family inet dhcp-attributes maximum-lease-time 2419200set access address-assignment pool p1 family inet dhcp-attributes name-server 192.168.10.2

    GUI Step-by-Step Procedure

    To configure the device as a DHCP server, specify the DHCP pool information, server information, lease time, and option information:

    1. In the J-Web interface, select Configure > DHCP > DHCP Services.
    2. Select DHCP Pools. Click Add.
    3. Specify the IP address that is used as the source address the DHCP server includes in IP packets when communicating with clients. The address is included in the DHCP packet in option 54.
    4. Specify the subnet information for the IPv4 address-assignment pool. Type 192.168.2.0/24.
    5. In the Address Range Low, type 192.168.2.2.
    6. In the Address Range High, type 192.168.2.254.
    7. In the Exclude Addresses box, type the addresses you want excluded from a DHCP address pool. Type 192.168.0.20
    8. Specify the server identifier to assign to any DHCP clients in this address pool. The identifier can be used to identify a DHCP server in a DHCP message.
    9. Specify the domain name to assign to any DHCP clients in this address pool.
    10. Specify the next server that DHCP clients need to contact. Type 192.168.10.2
    11. Define the maximum amount of time (in seconds) that DHCP should lease an address. Type 2419200.
    12. Define DHCP option 32, the device solicitation address option. You must enter a numeric value for option code. Select the option type from the list that corresponds to the option code.
    13. Click OK.
    14. If you are done configuring the device, click Commit > Commit.

    Step-by-Step Procedure

    The following example requires you to navigate various levels in the configuration hierarchy. For instructions on how to do that, see Using the CLI Editor in Configuration Mode in the CLI User Guide.

    To configure the device as a DHCP server:

    1. Configure an interface with an IP address on which the DHCP server will be reachable.
      [edit]user@host# set interfaces ge-0/0/2 unit 0 family inet address 192.168.2.1/24
    2. Configure the DHCP server.
      [edit]user@host# set system services dhcp-local-server group g1 interface ge-0/0/2.0
    3. Create an address pool for IPv4 addresses that can be assigned to clients. The addresses in the pool must be on the subnet in which the DHCP clients reside. Do not include addresses that are already in use on the network.
      [edit]]user@host# set access address-assignment pool p1 family inet network 192.168.2.0/24
    4. (Optional) Specify the IP address pool range. Define a range of addresses in the address-assignment pool. The range is a subset of addresses within the pool that can be assigned to clients. If no range is specified, then all addresses within the pool are available for assignment. Configure the name of the range and the lower and upper boundaries of the addresses in the range.
      [edit]]user@host# set access address-assignment pool p1 192.168.2.0/24 address-range low 192.168.2.2 high 192.168.2.254
    5. (Optional) Configure one or more routers as the default gateway on the client’s subnet.
      [edit]user@host# set access address-assignment pool p1 family inet dhcp-attributes router 192.168.10.3
    6. (Optional) Configure the IP address that is used as the source address for the DHCP server in messages exchanged with the client. Clients use this information to distinguish between lease offers.
      [edit]user@host# set access address-assignment pool pool1 family inet dhcp-attributes server-identifier 192.168.10.1
    7. (Optional) Specify the maximum time period, in seconds, that a client holds the lease for an assigned IP address if the client does not renew the lease.
      [edit]user@host# set access address-assignment pool pool1 family inet dhcp-attributes maximum-lease-time 2419200
    8. (Optional) Specify user-defined options to be included in DHCP packets
      [edit]user@host# set access address-assignment pool pool1 family inet dhcp-attributes option 98 string test98
    9. Assign a fixed IP address with the MAC address of the client.
      [edit]user@host# set system services static-binding 01:03:05:07:09:0B fixed-address 192.168.2.50

    Results

    From configuration mode, confirm your configuration by entering the show system services dhcp-local-server command. If the output does not display the intended configuration, repeat the configuration instructions in this example to correct it.

    [edit]user@host# show system services dhcp-local-server
    pool 192.168.2.0/24 {address-range low 192.168.2.2 high 192.168.2.254;maximum-lease-time 2419200;name-server {192.168.10.2;}option 32 ip-address 192.168.2.33;}static-binding 01:03:05:07:09:0B {fixed-address {192.168.2.50;}}

    If you are done configuring the device, enter commit from configuration mode.

    Verification

    Confirm that the configuration is working properly.

    Verifying the DHCP Binding Database

    Purpose

    Verify that the DHCP binding database reflects the DHCP server configuration.

    Action

    From operational mode, enter these commands:

    • show dhcp server binding command to display all active bindings in the database.
    • show dhcp server binding address detail command (where address is the IP address of the client) to display more information about a client.

    These commands produce following sample output:

    user@host> show dhcp server binding
    IP Address   Hardware Address   Type          Lease expires at
    30.1.1.20  00:12:1e:a9:7b:81  dynamic       2007-05-11 11:14:43 PDT
    
    user@host> show dhcp server binding address detail
        IP address           192.0.2.2
        Hardware address     00:a0:12:00:13:02
        Pool                 192.0.2.0/24
        Interface  fe-0/0/0, relayed by 192.0.2.200
    
    Lease information:
        Type                 DHCP
        Obtained at          2004-05-02 13:01:42 PDT
        Expires at           2004-05-03 13:01:42 PDT
        State                active
    
    DHCP options:
         Name: name-server, Value: { 6.6.6.6, 6.6.6.7 }
    	 Name: domain-name, Value: mydomain.tld
        Code: 32, Type: ip-address, Value: 192.0.2.33
    

    Verifying DHCP Server Operation

    Purpose

    Verify that the DHCP server operation has been configured.

    Action

    From operational mode, enter the following command:

    • show dhcp server statistics command to verify the DHCP server statistics.
    user@host> show dhcp server statistics
    Packets dropped:
        Total                      0
    
    Messages received:
        BOOTREQUEST                45
        DHCPDECLINE                0
        DHCPDISCOVER               1
        DHCPINFORM                 39
        DHCPRELEASE                0
        DHCPREQUEST                5
        DHCPLEASEQUERY             0
        DHCPBULKLEASEQUERY         0
    
    Messages sent:
        BOOTREPLY                  6
        DHCPOFFER                  1
        DHCPACK                    3
        DHCPNAK                    2
        DHCPFORCERENEW             0
        DHCPLEASEUNASSIGNED        0
        DHCPLEASEUNKNOWN           0
        DHCPLEASEACTIVE            0
        DHCPLEASEQUERYDONE         0
    

    Release History Table

    Release
    Description
    Starting with Junos OS Release 15.1X49-D60 and Junos OS Release 17.3R1, the legacy DHCPD (DHCP daemon) configuration on all SRX Series devices is being deprecated. and only the new JDHCP CLI is supported.

    Modified: 2017-07-05