DHCP Local Server
DHCP local server receives DHCP request and reply packets from DHCP clients and then responds with an IP address and other optional configuration information to the client.
Configuring Address Pools for DHCP Dynamic Bindings
For dynamic bindings, set aside a pool of IP addresses that can be assigned to clients. Addresses in a pool must be available to clients on the same subnet.
To configure an address pool, include the following statements at the [edit system services dhcp] hierarchy level:
The pool definition must include the client subnet number and prefix length (in bits). Optionally, the definition can include an address range and a list of excluded addresses.
The address-range statement defines the lowest and highest IP addresses in the pool that are available for dynamic address assignment. This statement is optional. If no range is specified, the pool will use all available addresses within the subnet specified. (Broadcast addresses, interface addresses, and excluded addresses are not available.)
The exclude-address statement specifies addresses within the range that are not used for dynamic address assignment. You can exclude one or more addresses within the range. This statement is optional.
The following is an example of a pool configuration.
For dynamic address assignment, configure an address pool for each client subnet the DHCP server supports. You can configure multiple address pools for a DHCP server, but only one address range per pool is supported.
DHCP maintains the state information for all pools configured. Clients are assigned addresses from pools with subnets that match the interface on which the DHCPDISCOVER packet is received. When more than one pool exists on the same interface, addresses are assigned on a rotating basis from all available pools.
See also
Configuring Manual (Static) DHCP Bindings Between a Fixed IP Address and a Client MAC Address
Static bindings provide configuration information for specific clients. This information can include one or more fixed Internet addresses, the client hostname, and a client identifier.
To configure static bindings, include the following statements at the [edit system services dhcp] hierarchy level:
A static binding defines a mapping between a fixed IP address and the client’s MAC address.
The mac-address variable specifies the MAC address of the client. This is a hardware address that uniquely identifies each client on the network.
The fixed-address statement specifies the fixed IP address assigned to the client. Typically a client has one address assigned, but you can assign more.
The host statement specifies the hostname of the client requesting the DHCP server. The name can include the local domain name. Otherwise, the name is resolved based on the domain-name statement.
The client-identifier statement is used by the DHCP server to index the database of address bindings. The client identifier is either an ASCII string or hexadecimal digits. It can include a type-value pair as specified in RFC 1700, Assigned Numbers. Either a client identifier or the client’s MAC address must be configured to uniquely identify the client on the network.
For each unique client-identifier client-id value, the DHCP server issues a unique lease and IP address from the pool. Previously, when the client provided an incorrect client-identifier client-id value, the DHCP server did not issue a lease.
The following is an example of a static binding configuration:
Specifying DHCP Lease Times for IP Address Assignments
For clients that do not request a specific lease time, the default lease time is one day. You can configure a maximum lease time for IP address assignments or change the default lease time.
To configure lease times, include the maximum-lease-time and default-lease-time statements:
You can include these statements at the following hierarchy levels:
Lease times defined for static bindings and address pools take priority over lease times defined at the [edit system services dhcp] hierarchy level.
The maximum-lease-time statement configures the maximum length of time in seconds for which a client can request and hold a lease. If a client requests a lease longer than the maximum specified, the lease is granted only for the maximum time configured on the server. After a lease expires, the client must request a new lease.
Maximum lease times do not apply to dynamic BOOTP leases. These leases are not specified by the client and can exceed the maximum lease time configured.
The following example shows a configuration for maximum and default lease times:
Configuring a DHCP Boot File and DHCP Boot Server
When a DHCP client starts, it contacts a boot server to download the boot file.
To configure a boot file and boot server, include the boot-file and boot-server statements:
You can include these statements at the following hierarchy levels:
After a client receives a DHCPOFFER
response from a DHCP server, the client can communicate directly
with the boot server (instead of the DHCP server) to download the
boot file. This minimizes network traffic and enables you to specify
separate boot server/file pairs for each client pool or subnetwork.
The boot-file statement configures the name and location of the initial boot file that the DHCP client loads and executes. This file stores the boot image for the client. In most cases, the boot image is the operating system the client uses to load.
The boot-server statement configures the IP address of the TFTP server that contains the client’s initial boot file. You must configure an IP address or a hostname for the server.
You must configure at least one boot file and boot server. Optionally, you can configure multiple boot files and boot servers. For example, you might configure two separate boot servers and files: one for static binding and one for address pools. Boot file configurations for pools or static bindings take precedence over boot file configurations at the [edit system services dhcp] hierarchy level.
The following example specifies a boot file and server for an address pool:
Configuring a Static IP Address as DHCP Server Identifier
The host running the DHCP server must itself use a manually assigned, static IP address. It cannot send a request and receive an IP address from itself or another DHCP server.
To configure a DHCP server identifier, include the server-identifier statement:
You can include this statement at the following hierarchy levels:
The server-identifier statement specifies the IP address of the DHCP server. The host must be a TFTP server that is accessible by all clients served within a range of IP addresses (based on either an address pool or static binding).
The following example shows a DHCP server identifier configured for an address pool:
Configuring a Domain Name and Domain Search List for a DHCP Server Host
To configure the name of the domain in which clients search for a DHCP server host, include the domain-name statement:
You can include this statement at the following hierarchy levels:
The domain-name statement sets the domain name that is appended to hostnames that are not fully qualified. This statement is optional. If you do not configure a domain name, the default is the client’s current domain.
To configure a domain search list, include the domain-search statement:
You can include this statement at the following hierarchy levels:
The domain-search statement sets the order in which clients append domain names when searching for the IP address of a host. You can include one or more domain names in the list. For more information, see RFC 3397, Dynamic Host Configuration Protocol (DHCP) Domain Search Option.
The domain-search statement is optional, if you do not configure a domain search list, the default is the client’s current domain.
Configuring Routers Available to the DHCP Client
After a DHCP client loads the boot image and has booted, the client sends packets to a router.
To configure routers available to the DHCP client, include the router statement:
You can include this statement at the following hierarchy levels:
The router statement specifies a list of IP addresses for routers on the client’s subnet. List routers in order of preference. You must configure at least one router for each client subnet.
The following example shows routers configured at the [edit system services dhcp] hierarchy level:
Creating User-Defined DHCP Options Not Included in the Default Junos Implementation of the DHCP Server
You can configure one or more user-defined options that are not included in the Junos default implementation of the DHCP server. For example, if a client requests a DHCP option that is not included in the DHCP server, you can create a user-defined option that enables the server to respond to the client’s request.
To configure a user-defined DHCP option, include the option statement:
The option statement specifies the following values:
id-number—Any whole number. The ID number is used to index the option and must be unique across a DHCP server.
option-type—Any of the following types: byte, byte-stream, flag, integer, ip-address, short, string, unsigned-integer, unsigned-short.
array—An option can include an array of values.
option-value—Value associated with an option. The option value must be compatible with the option type (for example, an On or Off value for a flag type).
You can include this statement at the following hierarchy levels:
The following example shows user-defined DHCP options:
User-defined options that conflict with DHCP configuration statements are ignored by the server. For example, in the following configuration, the DHCP server ignores the user-defined option 3 router statement and uses the router statement instead:
Example: Complete DHCP Server Configuration
This topic shows a complete DHCP server configuration with address pools, static bindings, and user-defined options.
The following example shows statements at the [edit interfaces] hierarchy level. The interface’s primary
address (10.3.3.1/24
) has a corresponding
address pool (10.3.3.0/24
) defined
at the [edit system services] hierarchy level.
You can configure a DHCP server only on an interface’s primary IP address. The primary address on an interface is the address that is used by default as the local address for broadcast and multicast packets sourced locally and sent out the interface.
Statements at the [edit system services] hierarchy level include the following:
Verifying and Managing the DHCP Server Configuration
To display the client address bindings for the extended DHCP local server, use the following operational commands:
show dhcp server binding
show dhcp server statistics
To clear client address bindings and DHCP local server statistics, use the following operational commands:
clear dhcp server binding
clear dhcp server statistics
For information about using these operations commands, see the Junos System Basics and Services Reference.
Example: Viewing DHCP Bindings
Use the CLI command show system services dhcp binding to view information about DHCP address bindings, lease times, and address conflicts.
The following example shows the binding type and lease expiration times for IP addresses configured on a router that supports a DHCP server:
user@host> show system services dhcp binding
IP Address Hardware Address Type Lease expires at 192.168.1.2 00:a0:12:00:12:ab static never 192.168.1.3 00:a0:12:00:13:02 dynamic 2004-05-03 13:01:42 PDT
Enter an IP address to show binding for a specific IP address:
user@host> show system services dhcp binding
192.168.1.3
DHCP binding information: IP address 192.168.1.3 Hardware address 00:a0:12:00:12:ab Client identifier 61 63 65 64 2d 30 30 3a 61 30 3a 31 32 3a 30 30 aced-00:a0:12:00 3a 31 33 3a 30 32 Lease information: Type dynamic Obtained at 2004-05-02 13:01:42 PDT Expires at 2004-05-03 13:01:42 PDT
Use the detail option to show detailed binding information:
user@host> show system services dhcp binding
detail
DHCP binding information: IP address 192.168.1.3 Hardware address 00:a0:12:00:12:ab Pool 192.168.1.0/24 Interface fe-0/0/0, relayed by 192.168.4.254 Lease information: Type dynamic Obtained at 2004-05-02 13:01:42 PDT Expires at 2004-05-03 13:01:42 PDT DHCP options: name-server foo.mydomain.tld domain-name mydomain.tld option 19 flag off
Example: Viewing DHCP Address Pools
Use the CLI show system services dhcp pool command to view information about DHCP address pools.
The following example show address pools configured on a DHCP server:
user@ host> show system services dhcp pool
Pool name Low address High address Excluded addresses 10.40.1.0/24 10.40.1.1 10.40.1.254 10.40.1.254
Example: Viewing and Clearing DHCP Conflicts
When the DHCP server provides an IP address, the client performs an ARP check to make sure the address is not being used by another client and reports any conflicts back to the server. The server keeps track of addresses with conflicts and removes them from the address pool. Use the CLI command show system services dhcp conflict to show conflicts.
user@host> show system services dhcp conflict
Detection time Detection method Address 2004-08-03 19:04:00 PDT client 192.168.1.5 2004-08-04 04:23:12 PDT ping 192.168.1.8
Use the clear system services dhcp conflicts command to clear the conflicts list and return IP addresses to the pool. The following command shows how to clear an address on the server that has a conflict:
user@host> clear system services dhcp conflict
192.168.1.5
For more information about CLI commands you can use with the DHCP server, see the CLI Explorer.
Configuring Tracing Operations for DHCP Processes
DHCP tracing operations track all DHCP operations and record them to a log file. By default, no DHCP processes are traced. If you include the traceoptions statement at the [edit system services dhcp] hierarchy level, the default tracing behavior is the following:
Important events are logged in a file called
dhcpd
located in the/var/log
directory.When the file
dhcpd
reaches 128 kilobytes (KB), it is renameddhcpd.0
, thendhcpd.1
, and so on, until there are three trace files. Then the oldest trace file (dhcpd.2
is overwritten). For more information about how log files are created, see the System Log Explorer.Log files can be accessed only by the user who configures the tracing operation.
You cannot change the directory in which trace files are located. However, you can customize the other trace file settings by including the following statements at the [edit system services dhcp traceoptions] hierarchy level:
Tasks for configuring DHCP tracing operations are:
Configuring the DHCP Processes Log Filename
By default, the name of the file that records trace
output is dhcpd
. You can specify
a different name by including the file statement at the [edit
system services dhcp traceoptions] hierarchy level:
Configuring the Number and Size of DHCP Processes Log Files
By default, when the trace file reaches 128 kilobytes
(KB) in size, it is renamed filename.0
, then filename.1
, and so on, until there are three trace files.
Then the oldest trace file (filename.2
) is overwritten.
You can configure the limits on the number and size of trace files by including the following statements at the [edit system services dhcp traceoptions] hierarchy level:
For example, set the maximum file size to 2 MB,
and the maximum number of files to 20. When the file that receives
the output of the tracking operation (filename
) reaches 2 MB, filename
is renamed filename.0
, and a new file called filename
is created. When the new filename
reaches 2 MB, filename.0
is renamed filename.1
and filename
is renamed filename.0
. This process repeats
until there are 20 trace files. Then the oldest file (filename.19
) is overwritten
by the newest file (filename.0
).
The number of files can be from 2 through 1000 files. The file size of each file can be from 10KB through 1 gigabyte (GB).
Configuring Access to the DHCP Log File
By default, log files can be accessed only by the user who configures the tracing operation.
To specify that any user can read all log files, include the file world-readable statement at the [edit system services dhcp traceoptions] hierarchy level:
To set the default behavior explicitly, include the file no-world-readable statement at the [edit system services dhcp traceoptions] hierarchy level:
Configuring a Regular Expression for Refining the Output of DHCP Logged Events
By default, the trace operations output includes all lines relevant to the logged events.
You can refine the output by including the match statement at the [edit system services dhcp traceoptions file filename] hierarchy level and specifying a regular expression (regex) to be matched:
Configuring DHCP Trace Operation Events
By default, only important events are logged. You can configure the trace operations to be logged by including the following options at the [edit system services dhcp traceoptions] hierarchy level:
DHCP Processes Tracing Flags
Table 1 describes which operation or event is recorded by each DHCP tracing flag. By default, all flags are disabled.
Table 1: DHCP Processes Tracing Flags
Flag | Operation or Event |
---|---|
all | All operations. |
binding | Binding operations. |
config | Logins to the configuration database. |
conflict | Client-detected conflicts for IP addresses. |
event | Important events. |
ifdb | Interface database operations. |
io | I/O operations. |
lease | Lease operations. |
main | Main loop operations. |
misc | Miscellaneous operations. |
packet | DHCP packets. |
options | DHCP options. |
pool | Address pool operations. |
protocol | Protocol operations. |
rtsock | Routing socket operations. |
scope | Scope operations. |
signal | DHCP signal operations. |
trace | Tracing operations. |
ui | User interface operations. |