DHCP server
For cases where a host requires IPAM (IP Address Management) without an external DHCP server, or where DHCP relay to underlay is not possible, IPAM information can be stored locally on the SR Linux device, which can assign an IP address and other DHCP options to the host using a local DHCP server.
SR Linux supports static IP allocations on both DHCPv4 and DHCPv6 servers. The SR Linux DHCP server can be enabled under regular Layer 3 or IRB subinterfaces. On Layer 3 or IRB subinterfaces, the DHCP server can only be enabled under subinterfaces where DHCP relay is disabled.
When an incoming DHCP Discover or Solicit message is received from a host (DHCP client), and its MAC address matches an entry in the SR Linux DHCP server configuration, the SR Linux DHCP server starts the process of IP address assignment and sends other DHCP options if configured to do so.
For DHCPv4, in addition to IP address allocation, SR Linux can send the following DHCP options to a host:
- router (option 3) – IPv4 address of the gateway for the DHCP client
- dns-server (option 6) – List of up to 4 DNS servers for the DHCP client to use
- hostname (option 12) – The hostname for the DHCP client
- domain-name (option 15) – The domain name the client can use when resolving hostnames via DNS
- interface-mtu (option 26) – The MTU to use on this interface. The MTU is specified as a 16-bit unsigned integer. The minimum legal value for the MTU is 68.
- ntp-server (option 42) – List of up to 4 NTP servers for the DHCP client to use
- lease-time (option 51) – The number of seconds a client can use the IP address before the lease must be renewed
- server-id (option 54) – IP address the DHCP server must match within the network-instance, such as the subinterface primary address or loopback address
- tftp-server-name (option 66) – The FQDN of the TFTP server the client uses to download the bootfile/configuration script
- bootfile-name (option 67) – The name of the configuration file the client uses during booting
- domain-search-list (option 119) – The domain search list the client uses when resolving hostnames with DNS
- static-route (option 121) – Classless Static Route option, which contains one or more static routes, each consisting of a destination descriptor and the IP address of the router to be used to reach that destination
- tftp-server-address (option 150) – List of IP addresses of the TFTP servers the client uses to download the bootfile/configuration script
- next-server – The IP address of the server from which to download a boot image. This is
the
siaddrfield in the DHCP offer message; it directs the client where to download the boot file after receiving an IP address. - custom – One or more custom DHCP options. You can specify the option ID, the encoding type, value, and whether the option is sent to the client if it was not configured in the client request.
For DHCPv6, in addition to IP address allocation, SR Linux can send the following DHCP options to a host:
- dns-server (option 23) - List of up to 4 DNS servers for the DHCP client to use
- domain-search-list (option 24) - The domain search list the client uses when resolving hostnames with DNS
Notes:
- The DHCP server can be enabled under regular Layer 3 or IRB subinterfaces.
- The SR Linux DHCP server supports static IP address allocation only. Dynamic allocation is not supported.
- On Layer 3 subinterfaces, you can enable either DHCP relay or the DHCP server, but not both. DHCP servers can be enabled only on subinterfaces where DHCP relay is disabled.
- It is assumed there is no DHCP relay agent between the DHCP client and the SR Linux DHCP server. Relayed frames are not supported.
- For IPv6, DHCP configuration uses MAC-to-IPv6 address binding. The IPv6 address is assigned to the client based on the client's MAC address, not IAID. The client's MAC address is derived from the client identifier. The recommended client identifier type is DUID type DUID-LLT or DUID-LL.
Configuring the DHCP server
To configure the SR Linux DHCP
server, you enable it on a subinterface and at the system
dhcp-server level configure DHCPv4 and DHCPv6 options and static IP
allocations for the network-instance where DHCP is required.
Enable DHCPv4 and DHCPv6 servers for a subinterface
--{ * candidate shared default }--[ ]--
# info with-context interface ethernet-1/1 subinterface 1
interface ethernet-1/1 {
subinterface 1 {
admin-state enable
ipv4 {
admin-state enable
address 192.14.1.4/27 {
}
dhcp-server {
admin-state enable
}
}
ipv6 {
admin-state enable
address 2001:192:14:1::4/120 {
}
dhcpv6-server {
admin-state enable
}
}
}
}
Configure DHCPv4 and DHCPv6 options
The following example configures DHCPv4 and DHCPv6 options, which are supplied to DHCP clients on the default network-instance:
--{ * candidate shared default }--[ ]--
# info with-context system dhcp-server
system {
dhcp-server {
admin-state enable
network-instance default {
dhcpv4 {
options {
domain-name lan
router 192.168.1.1
dns-server [
192.168.1.53
192.168.1.54
]
ntp-server [
192.168.1.50
]
}
}
dhcpv6 {
options {
dns-server [
2001:192:14:1::4
2001:192:14:1::5
]
}
}
}
}
}
Configure a custom DHCP option
The following example
configures a custom DHCP option to be supplied to DHCP clients on the default
network-instance. In this example, DHCP option 199 supplies the string
pass1, and the option is sent to the client even if it is not
configured in the client request.
-{ + candidate shared default }--[ ]--
# info with-context system dhcp-server network-instance default dhcpv4 options
system {
dhcp-server {
network-instance default {
dhcpv4 {
options {
custom 199 {
value pass1
always-send true
encoding string
}
}
}
}
}
}
Configure IPv4 static IP allocation settings
The following example configures static IP allocation settings for an IPv4 host:
--{ * candidate shared default }--[ ]--
# info with-context detail system dhcp-server network-instance default dhcpv4
system {
dhcp-server {
admin-state enable
network-instance default {
dhcpv4 {
admin-state enable
static-allocation {
host 00:1D:FE:E0:E9:7C {
ip-address 192.168.1.1/24
options {
router 192.168.1.1
dns-server [
192.168.1.53
]
}
}
}
}
}
}
}
Configure IPv4 static allocation with DHCP relay information
The following example uses information received from a DHCP relay agent in the DHCP option 82 circuit-id and remote-id sub-options to assign an IP address to a client.
--{ + candidate shared default }--[ ]--
# info with-context system dhcp-server network-instance green dhcpv4 static-allocation
system {
dhcp-server {
network-instance green {
dhcpv4 {
static-allocation {
relay-information "tor1|green|ethernet-1/1|1:0" remote-id 00:00:64:01:05:05 {
ip-address 100.1.5.135/24
}
}
}
}
}
}
Configure IPv6 static IP allocation settings
The following example configures static IP allocation settings for an IPv6 host:
--{ * candidate shared default }--[ ]--
# info with-context detail system dhcp-server network-instance default dhcpv6
system {
dhcp-server {
admin-state enable
network-instance default {
dhcpv6 {
admin-state enable
static-allocation {
host 92:93:47:30:32:CA {
ip-address 2001:1::192:168:12:1/126
options {
dns-server [
2001:192:14:1::4
]
}
}
}
}
}
}
}