Related Documentation
- J Series
- DHCP Server, Client, and Relay Agent Overview
- Understanding DHCP Server Operation
- Understanding DHCP Relay Agent Operation
- DHCP Settings and Restrictions Overview
- SRX Series
- DHCP Server, Client, and Relay Agent Overview
- Understanding DHCP Server Operation
- Understanding DHCP Relay Agent Operation
- DHCP Settings and Restrictions Overview
Example: Configuring the Device as a DHCP Server
This example shows how to configure the device as a DHCP server.
Requirements
Before you begin:
- Determine the IP address pools and the lease durations to use for each subnet. See Example: Viewing DHCP Address Pools.
- Obtain the MAC addresses of the clients that require permanent
IP addresses. Determine the IP addresses to use for these clients.
See the Junos OS Security Configuration Guide
. - 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 Junos OS Security Configuration Guide
. - Determine the DHCP options required by the subnets and clients in your network. See Creating User-Defined DHCP Options Not Included in the Default Junos Implementation of the DHCP Server.
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.
GUI Step-by-Step Procedure
To configure the device as a DHCP server:
- In the J-Web interface, select Configure>Services>DHCP>Boot DHCP Relay.
- Next to System, click Configure.
- Next to Services, make sure the check box is selected, and click Configure.
- Next to Dhcp, click Configure.
- Define the IP address pool. Next to Pool, click Add new entry.
- In the Subnet address box, type 192.168.2.0/24.
- Next to Address range, select the check box.
- In the High box, type 192.168.2.254.
- In the Low box, type 192.168.2.2.
- Click OK.
- Define the default and maximum lease times, in seconds. From the Default lease time list, select Enter Specific Value.
- In the Length box, type 1209600.
- From the Maximum lease time list, select Enter Specific Value.
- Next to Maximum lease time, type 2419200.
- Define the domain search suffixes to be used by the clients. Next to Domain search, click Add new entry.
- In the Suffix box, type mycompany.net.
- Click OK.
- Next to Domain search, click Add new entry.
- In the Suffix box, type mylab.net.
- Click OK.
- Define a DNS server. Next to Name server, click Add new entry.
- In the Address box, type 192.168.10.2.
- Click OK.
- Define DHCP option 32, the device solicitation address option. Next to Option, click Add new entry.
- In the Option identifier code box, type 32.
- From the Option type choice list, select Ip address.
- In the Ip address box, type 192.168.2.33.
- Click OK twice.
- Assign a static IP address to a MAC address.Next to Static binding, click Add new entry.
- In the Mac address box, type 01:03:05:07:09:0B.
- Next to Fixed address, click Add new entry.
- In the Address box, type 192.168.2.50.
- Click OK until you return to the Configuration page.
- Click OK to check your configuration and save it as a candidate configuration.
- 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
.
To configure the device as a DHCP server:
- Configure the DHCP server.[edit]user@host# edit system services dhcp
- 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
- 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
- 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
- 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
- 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
- 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.
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:
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
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
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.
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 ...
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
Related Documentation
- J Series
- DHCP Server, Client, and Relay Agent Overview
- Understanding DHCP Server Operation
- Understanding DHCP Relay Agent Operation
- DHCP Settings and Restrictions Overview
- SRX Series
- DHCP Server, Client, and Relay Agent Overview
- Understanding DHCP Server Operation
- Understanding DHCP Relay Agent Operation
- DHCP Settings and Restrictions Overview

