Global DHCP server options are configured per address family and apply to all
subnets. Access the commands in the DHCP Server Configuration Mode.
To enter the DHCP server global configuration mode, use the following
commands:
switch# configure
switch(config)# dhcp server
switch(config-dhcp-server)#
To disable the DHCP server:
switch(config-dhcp-server)# disabled
Use the following commands to configure the DNS servers. Only two servers can be
configured globally per address family.
switch(config-dhcp-server)# dns server ipv4 192.0.2.4 192.0.2.5
switch(config-dhcp-server)# dns server ipv6 2001:db8:0:10::53 2001:db8:0:10::5353
The following commands configure the domain names for allocated IP
addresses. For example, add a domain with the name
podV4.example.com for DHCPv4 and a domain with the
name podV6.example.com for DHCPv6.
switch(config-dhcp-server)# dns domain name ipv4 podV4.example.com
switch(config-dhcp-server)# dns domain name ipv6 podV6.example.com
The following commands configure lease time for the allocated IP
addresses. For example, configure the lease time as one (1) day.
switch(config-dhcp-server)# lease time ipv4 1 days 0 hours 0 minutes
switch(config-dhcp-server)# lease time ipv6 1 days 0 hours 0 minutes
The following command configures the TFTP Server-Name. The server can be in the form
of either an IPv4 or IPv6 address or a fully qualified domain name. For example,
configure the TFTP server with the IPv4 address, 192.0.2.6 and an TFTP
server with the IPv6 address,
2601:600:cb02:d070:14b7:6ad0:bedb:ef3:
switch(config-dhcp-server)# tftp server option 66 ipv4 192.0.2.6
The following command configures the TFTP Servers.
switch(config-dhcp-server)# tftp server option 150 ipv4 192.0.2.6 192.0.2.7
The following command configures the TFTP Server Bootfile-Name for IPv4 and IPv6:
switch(config-dhcp-server)# tftp server file ipv4 bootfile.conf
switch(config-dhcp-server)# tftp server file ipv6 bootfile.conf
The following command configures Vendor specific option. To enter the Vendor Option
Configuration Mode from the DHCP Server Configuration mode, specify a vendor class
identifier, only available in DHCPv4. For example, Vendor option for clients with vendor
class identifier vendorClassIDA.
switch(config-dhcp-server)# vendor-option ipv4 vendorClassIDA
The following command configures default. If you do not configure the
default, the DHCP Server sends the configured Vendor option to
clients requesting a Vendor option with a vendor class identifier that does not match
any configured Vendor option.
switch(config-dhcp-server)# vendor-option ipv4 default
The following command configures suboptions for the Vendor. The
configuration sends the resulting Vendor option in a hexadecimal
format to the desired client. The output displays aVendor option
with a suboption with IPv4 address 192.0.2.8, for clients with the
vendor class identifier vendorClassIDA, resulting
in Vendor option 1:4:c0:0:2:8.
Sub option number is 1
Length of the Data is 4
Data is c0:0:2:8
dhcp server
vendor-option ipv4 vendorClassIDA
sub-option 1 type ipv4-address data 192.0.2.8
The following command configures the Vendor option with IPv4 addresses 192.0.2.8 and
192.0.2.9, for clients with the vendor class identifier
vendorClassIDA, resulting in the Vendor option
fe:8:c0:0:2:8:c0:0:2:9.
switch(config-dhcp-server)# vendor-option ipv4 vendorClassIDA sub-option 254 type array ipv4-address data 192.0.2.8 192.0.2.9
The following command configures Vendor option with a string “vendor”,
for all clients whose vendor class identifier does not match any
configured Vendor option, resulting in Vendor option
1e:3:46:4f:4f..
switch(config-dhcp-server)# vendor-option ipv4 default sub-option 30 type string data "vendor"
The following command sets up Vendor option holding two suboptions, suboption 1 holds
the IPv4 address 192.0.2.8, and suboption 2 holds a string “vendor”, for all clients
whose vendor class identifier does not match any configured Vendor option, resulting in
Vendor option 1:4:c0:0:2:8:2:3:46:4f:4f.
switch(config-dhcp-server)# vendor-option ipv4 default sub-option 1 type ipv4-address data 192.0.2.8 sub-option 2 type string data “vendor"
Configuring DHCP Server Subnets
DHCP Server settings can also be configured per subnet and
overrides the DHCP Server global mode configurations. There can be
multiple subnets configured, but they must not overlap. EOS disables
overlapping subnets.
The following command enters DHCP Server subnet mode under the
IPv4 address family.
switch# config
switch(config)# dhcp server
switch(config-dhcp-server)# subnet 192.0.2.0/32
The following command configures the name of the subnet. For example, name subnetv4
for DHCPv4.
switch(config-dhcp-subnet-ipv4)# name subnetv4
The following command configures range of IP addresses of the subnet. The
range must be within the subnet mask, otherwise the subnet becomes
disabled.
switch(config-dhcp-subnet-ipv4)# range 192.0.2.100 192.0.2.199
The following command configures the DNS servers for a subnet. Configure
up to 2 servers per subnet.
switch(config-dhcp-subnet-ipv4-range)# dns server 192.0.2.1 192.0.2.10
The following command configures the lease time for allocated IP addresses of the
subnet.
switch(config-dhcp-subnet-ipv4)# lease time ipv4 3 days 0 hours 0 minutes
The following command configures the default-gateway for a subnet.
switch(config-dhcp-server)# subnet 192.0.2.0/32
switch(config-dhcp-subnet-ipv4)# default-gateway 192.0.2.3
The following command configures the TFTP Server-Name for a subnet. The server can be
in the form of either an IPv4 address or a fully qualified domain name, but can only
be configured for
DHCPv4.
switch(config-dhcp-subnet-ipv4)# tftp server option 66 subnet-tftp.example.com
The following command configures a list of TFTP servers. The server can only be in
the form of an IP address, but can only be configured for
DHCPv4.
switch(config-dhcp-subnet-ipv4)# tftp server option 150 192.0.2.6 192.0.2.7
The following command configures the TFTP server Bootfile-Name for a subnet, but can
only be configured for
DHCPv4.
switch(config-dhcp-subnet-ipv4)# tftp server file subnet-bootfile.conf
Example DHCP Server Subnets
Configurationswitch# config
switch(config)# dhcp server
switch(config-dhcp-server)# subnet 192.0.2.0/32
switch(config-dhcp-subnet-ipv4)# name subnetv4
switch(config-dhcp-subnet-ipv4)# range 192.0.2.100 192.0.2.199
switch(config-dhcp-subnet-ipv4-range)# dns server 192.0.2.1 192.0.2.10
switch(config-dhcp-subnet-ipv4)# lease time ipv4 3 days 0 hours 0 minutes
switch(config-dhcp-server)# subnet 192.0.2.0/32
switch(config-dhcp-subnet-ipv4)# default-gateway 192.0.2.3
switch(config-dhcp-subnet-ipv4)# tftp server option 66 subnet-tftp.example.com
switch(config-dhcp-subnet-ipv4)# tftp server option 150 192.0.2.6 192.0.2.7
switch(config-dhcp-subnet-ipv4)# tftp server file subnet-bootfile.conf
The following command configures a static IP address for exclusive use by a client.
Enter the DHCP Server Subnet Configuration Mode,
(config-dhcp-mac-address-ipv4) from and specify the client MAC
Address. The IP address must not be used by another client. Only DHCPv4 addresses
allowed for this configuration.
switch(config-dhcp-subnet-ipv4)# reservations
switch(config-dhcp-sub-v4-reserve)# mac-address 1a1b.1c1d.1e1f
switch(config-dhcp-sub-v4-rsrv-mac-address)# ipv4-address 192.0.2.0