Supported Platforms
Related Documentation
- EX Series, QFabric System, QFX Series standalone switches
- Configuring a DHCP Client (CLI Procedure)
- EX Series
- Configuring a DHCP SIP Server (CLI Procedure)
- QFX Series standalone switches
- Understanding DHCP Services for Switches
Configuring a Switch as a DHCP Server (CLI Procedure)
![]() | Note: This topic applies to Junos OS for EX Series switches and QFX Series switches with support for the Enhanced Layer 2 Software (ELS) configuration style. If your switch runs software that does not support ELS, see Configuring a DHCP Server on Switches (CLI Procedure). For ELS details, see Getting Started with Enhanced Layer 2 Software. |
A Dynamic Host Configuration Protocol (DHCP) server provides a framework to pass configuration information to client hosts on a TCP/IP network. A switch acting as a DHCP server can dynamically allocate IP addresses and other configuration parameters, minimizing the overhead that is required to add clients to the network.
A DHCP configuration consists of two components—an optional reconfiguration of default settings on DHCP clients and the configuration of a DHCP server. This topic covers configuration of the switch as a local DHCP server using DHCP for IPv4 (DHCPv4). For information about DHCPv6 local server, see DHCPv6 Local Server Overview.
This topic describes the following task:
Configuring the Switch as a Local DHCP Server
To configure a switch as a local DHCP server, you must configure a DHCP address pool and indicate IP addresses for the pool. The switch, operating as the DHCP server, dynamically distributes the IP addresses from this pool. The switch can dynamically assign additional configuration parameters, such as default gateway, to provide the client with information about the network.
Multiple address pools can be configured for a DHCP server. DHCP maintains the state information about all configured pools. Clients are assigned addresses from pools with subnets that match the interface on which the DHCPDISCOVER packet sent by the client is received on the server. When more than one pool exists on the same interface, addresses are assigned on a rotating basis from all available pools.
You must ensure that you do not assign addresses that are already in use in the network to the address pools. The DHCP server does not check whether the addresses are already in use in the network before it assigns them to clients.
- Configure a Layer 3 interface with an IP address on which
the DHCP server will be reachable:[edit]user@switch# set interfaces interface-name unit unit-number family family address address/prefix-lengthuser@switch# set vlans vlan-name vlan-id vlan-id user@switch# set vlans vlan-name l3-interface irb-name user@switch# set interfaces irb-name l3-interface irb-name family family address address/prefix-length
For example:
[edit]user@switch# set interfaces ge-0/0/1 unit 0 family inet address 40.1.1.2/24 user@switch# set vlans server vlan-id 301 user@switch# set vlans server l3-interface irb.301 user@switch# set interfaces irb.301 family inet address 50.1.1.2/24 - Configure the DHCP server for the Layer 3 interface:[edit]user@switch# set system services dhcp-local-server group-name interface interface-name
For example:
[edit]user@switch# set system services dhcp-local-server group server1 interface ge-0/0/1user@switch# set system services dhcp-local-server group server1 interface irb.301 - 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@switch# set access address-assignment pool pool-name family family network address/prefix-length
For example:
[edit]user@switch# set access address-assignment pool pool1 family inet network 20.1.1.0/24 - (Optional) 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@switch# set access address-assignment pool pool-name family family range range-name low low-IP-addressuser@switch# set access address-assignment pool pool-name family family range range-name high high-IP-address
For example:
[edit]user@switch# set access address-assignment pool pool1 family inet range range1 low 20.1.1.101 user@switch# set access address-assignment pool pool1 family inet range range1 high 20.1.1.110 - (Optional) Configure one or more routers as the default
gateway on the client’s subnet:[edit]user@switch# set access address-assignment pool pool-name family family dhcp-attributes router gateway-ip-address
For example:
[edit]user@switch# set access address-assignment pool pool1 family inet dhcp-attributes router 20.1.1.254 - (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@switch# set access address-assignment pool pool-name family family dhcp-attributes server-identifier ip-address
For example:
[edit]user@switch# set access address-assignment pool pool1 family inet dhcp-attributes server-identifier 20.1.1.254 - (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@switch# set access address-assignment pool pool-name family family dhcp-attributes maximum-lease-time seconds
For example:
[edit]user@switch# set access address-assignment pool pool1 family inet dhcp-attributes maximum-lease-time 43,200 - (Optional) Specify user-defined options to be included
in DHCP packets:[edit]user@switch# set access address-assignment pool pool-name family family dhcp-attributes option option-id-number option-type option-value
For example:
[edit]user@switch# set access address-assignment pool pool1 family inet dhcp-attributes option 98 string test98
Related Documentation
- EX Series, QFabric System, QFX Series standalone switches
- Configuring a DHCP Client (CLI Procedure)
- EX Series
- Configuring a DHCP SIP Server (CLI Procedure)
- QFX Series standalone switches
- Understanding DHCP Services for Switches
Modified: 2016-01-07
Supported Platforms
Related Documentation
- EX Series, QFabric System, QFX Series standalone switches
- Configuring a DHCP Client (CLI Procedure)
- EX Series
- Configuring a DHCP SIP Server (CLI Procedure)
- QFX Series standalone switches
- Understanding DHCP Services for Switches