Help us improve your experience.

Let us know what you think.

Do you have time for a two-minute survey?

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.

    Requirements

    Before you begin:

    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 default-lease-time to 1,209,600 and the maximum-lease-time to 2,419,200. You then set the domain search suffixes as mycompany.net and mylab.net. These suffixes specify the domain search list used by a client when resolving hostnames with DNS.

    Then you specify the DNS server IP address as 192.168.10.2. You set the IP address for the device solicitation address option (option 32) as 192.168.2.33. The IP address excluded from the IP address pool is reserved for this option. Finally, you assign a fixed IP address as 192.168.2.50 with the MAC address of the client, 01:03:05:07:09:0B.

    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, and then copy and paste the commands into the CLI at the [edit] hierarchy level.

    set system services dhcp pool 192.168.2.0/24 address-range low 192.168.2.2 high 192.168.2.254 set system services dhcp pool 192.168.2.0/24 default-lease-time 1209600 maximum-lease-time 2419200 set system services dhcp pool 192.168.2.0/24 domain-search mycompany.net set system services dhcp pool 192.168.2.0/24 domain-search mylab.net set system services dhcp pool 192.168.2.0/24 name-server 192.168.10.2 set system services dhcp pool 192.168.2.0/24 option 32 ip-address 192.168.2.33 set system services dhcp static-binding 01:03:05:07:09:0B fixed-address 192.168.2.50

    GUI Step-by-Step Procedure

    To configure the device as a DHCP server:

    1. In the J-Web interface, select Configure>Services>DHCP>Boot DHCP Relay.
    2. Next to System, click Configure.
    3. Next to Services, make sure the check box is selected, and click Configure.
    4. Next to Dhcp, click Configure.
    5. Define the IP address pool. Next to Pool, click Add new entry.
    6. In the Subnet address box, type 192.168.2.0/24.
    7. Next to Address range, select the check box.
    8. In the High box, type 192.168.2.254.
    9. In the Low box, type 192.168.2.2.
    10. Click OK.
    11. Define the default and maximum lease times, in seconds. From the Default lease time list, select Enter Specific Value.
    12. In the Length box, type 1209600.
    13. From the Maximum lease time list, select Enter Specific Value.
    14. Next to Maximum lease time, type 2419200.
    15. Define the domain search suffixes to be used by the clients. Next to Domain search, click Add new entry.
    16. In the Suffix box, type mycompany.net.
    17. Click OK.
    18. Next to Domain search, click Add new entry.
    19. In the Suffix box, type mylab.net.
    20. Click OK.
    21. Define a DNS server. Next to Name server, click Add new entry.
    22. In the Address box, type 192.168.10.2.
    23. Click OK.
    24. Define DHCP option 32, the device solicitation address option. Next to Option, click Add new entry.
    25. In the Option identifier code box, type 32.
    26. From the Option type choice list, select Ip address.
    27. In the Ip address box, type 192.168.2.33.
    28. Click OK twice.
    29. Assign a static IP address to a MAC address.Next to Static binding, click Add new entry.
    30. In the Mac address box, type 01:03:05:07:09:0B.
    31. Next to Fixed address, click Add new entry.
    32. In the Address box, type 192.168.2.50.
    33. Click OK until you return to the Configuration page.
    34. Click OK to check your configuration and save it as a candidate configuration.
    35. If you are done configuring the device, click Commit Options>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 Junos OS CLI User Guide PDF Document.

    To configure the device as a DHCP server:

    1. Configure the DHCP server.
      [edit]user@host# edit system services dhcp
    2. Specify the IP address pool range.
      [edit system services dhcp]user@host# set pool 192.168.2.0/24 address-range low 192.168.2.2 high 192.168.2.254
    3. Define the default and maximum lease times, in seconds.
      [edit system services dhcp]user@host# set pool 192.168.2.0/24 default-lease-time 1209600 maximum-lease-time 2419200
    4. Define the domain search suffixes to be used by the clients.
      [edit system services dhcp]user@host# set pool 192.168.2.0/24 domain-search mycompany.net user@host# set pool 192.168.2.0/24 domain-search mylab.net
    5. Specify the DNS server IP address.
      [edit system services dhcp]user@host# set pool 192.168.2.0/24 name-server 192.168.10.2
    6. Set the device solicitation IP address.
      [edit system services dhcp]user@host# set pool 192.168.2.0/24 option 32 ip-address 192.168.2.33
    7. Assign a fixed IP address with the MAC address of the client.
      [edit system services dhcp]user@host# set 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 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 dhcppool 192.168.2.0/24 {address-range low 192.168.2.2 high 192.168.2.254;maximum-lease-time 2419200;default-lease-time 1209600;name-server {192.168.10.2;}domain-search {mycompany.net;mylab.net;}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 Global DHCP Information

    Purpose

    Verify that the global DHCP Information has been configured for the device.

    Action

    From operational mode, enter the show system services dhcp global command.

    Global settings:
        	BOOTP lease length     	   infinite
      	DHCP lease times:
        	Default lease time         1 day
        	Minimum lease time         1 minute
        	Maximum lease time         infinite
    
    	DHCP options:
        	Name: domain-name, Value: englab.juniper.net
        	Name: name-server, Value: [ 192.168.5.68, 172.17.28.101, 172.17.28.100 ]
    

    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 system services dhcp binding command to display all active bindings in the database.
    • show system services dhcp binding address detail command (where address is the IP address of the client) to display more information about a client.
    • show system services dhcp conflict command to show any potential conflicts with the bindings.

    These commands produce following sample output:

    user@host> show system services dhcp 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 system services dhcp binding 3.3.3.2 detail
        IP address           3.3.3.2
        Hardware address     00:a0:12:00:13:02
        Pool                 3.3.3.0/24
        Interface  fe-0/0/0, relayed by 3.3.3.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: 3.3.3.33
    
    user@host> show system services dhcp conflict
    Detection time Detection method Address
        2004-08-03 19:04:00 PDT ARP 3.3.3.5
        2004-08-04 04:23:12 PDT Ping 4.4.4.8
        2004-08-05 21:06:44 PDT Client 3.3.3.10
    

    Verifying DHCP Server Operation

    Purpose

    Verify that the DHCP server operation has been configured.

    Action

    From operational mode, enter these commands:

    • ping command to verify that a client responds to ping packets containing the destination IP address assigned by the device.
    • ipconfig /all command to display the IP configuration on the client. For example, on a PC running Microsoft Windows, enter ipconfig /all at the command prompt to display the PC's IP configuration.
    user@host> ping 192.168.2.2
    PING 192.168.2.2 (192.168.2.2): 56 data bytes
    64 bytes from 192.168.2.2: icmp_seq=0 ttl=255 time=8.856 ms
    64 bytes from 192.168.2.2: icmp_seq=1 ttl=255 time=11.543 ms
    64 bytes from 192.168.2.2: icmp_seq=2 ttl=255 time=10.315 ms
    ...
    C:\Documents and Settings\user> ipconfig /all
    Windows 2000 IP Configuration          
    
    Host Name . . . . . . . . . . . . : my-pc         
    Primary DNS Suffix  . . . . . . . : mycompany.net        
    Node Type . . . . . . . . . . . . : Hybrid         
    IP Routing Enabled. . . . . . . . : No         
    WINS Proxy Enabled. . . . . . . . : No         
    DNS Suffix Search List. . . . . . : mycompany.net mylab.net  
    
    Ethernet adapter Local Area Connection 2:          
    
    Connection-specific DNS Suffix  . : mycompany.net mylab.net         
    Description . . . . . . . . . . . : 10/100 LAN Fast Ethernet Card        
    Physical Address. . . . . . . . . : 02-04-06-08-0A-0C         
    DHCP Enabled. . . . . . . . . . . : Yes         
    Autoconfiguration Enabled . . . . : Yes         
    IP Address. . . . . . . . . . . . : 192.168.2.2         
    Subnet Mask . . . . . . . . . . . : 255.255.254.0         
    Default Gateway . . . . . . . . . : 192.168.10.3         
    DHCP Server . . . . . . . . . . . : 192.168.2.1         
    DNS Servers . . . . . . . . . . . : 192.168.10.2         
    Primary WINS Server . . . . . . . : 192.168.10.4         
    Secondary WINS Server . . . . . . : 192.168.10.5         
    Lease Obtained. . . . . . . . . . : Monday, January 24, 2005 8:48:59 AM         
    Lease Expires . . . . . . . . . . : Monday, February 7, 2005 8:48:59 AM

    Published: 2012-06-29