Defining DHCP Configuration Options
Problem
You want to dynamically deliver configuration parameters to client workstations.
Solution
You can configure a wide variety of DHCP parameters for configuring client workstations:
Router1#configure terminal
Enter configuration commands, one per line. End with CNTL/Z.
Router1(config)#ip dhcp pool ORAserver
Router1(dhcp-config)#host 172.25.1.34 255.255.255.0
Router1(dhcp-config)#client-name bigserver
Router1(dhcp-config)#default-router 172.25.1.1 172.25.1.3
Router1(dhcp-config)#domain-name oreilly.com
Router1(dhcp-config)#dns-server 172.25.1.1 10.1.2.3
Router1(dhcp-config)#netbios-name-server 172.25.1.1
Router1(dhcp-config)#netbios-node-type h-node
Router1(dhcp-config)#option 66 ip 10.1.1.1
Router1(dhcp-config)#option 33 ip 192.0.2.1 172.25.1.3
Router1(dhcp-config)#option 31 hex 01
Router1(dhcp-config)#lease 2
Router1(dhcp-config)#exit
Router1(config)#end
Router1#
Discussion
The strength of DHCP is its ability to configure client workstations from a centralized location using DHCP options. It greatly reduces costs if workstations can dynamically learn all of their configuration options instead of having to send a technician to every desk.
DHCP can assign default routes, domain names, name server addresses, and WINS server addresses, to name just a few. RFC 2132 defines a large number of standard configurable options, and includes provisions for further vendor-specific options. However, in reality most networks only use a small subset of these options. To make configuration easier, Cisco provides human-readable names for several of the most common options, as shown in Table 20-2.
Custom name | RFC 2132 Option # | Description |
---|---|---|
client-name | Option 12 | Hostname (static map only) |
default-router | Option 3 | Default router(s) |
domain-name | Option 15 | Domain name |
dns-server | Option 6 | Name server(s) |
netbios-name-server | Option 44 | WINS server(s) |
netbios-node-type | Option 46 | Netbios node type |
lease | Option 58 | Half of the lease time |
host | Option 1 | Subnet mask (plus IP address) |
However, since it would be impossible to create user-friendly name for every possible DHCP option, Cisco allows you to manually configure any option by its number, using the option command.
You can also use the option command instead of the custom name. For example, Option 6 in RFC 2132 is reserved for name server addresses. Instead of using the Cisco provided user-friendly command dns-server, as we did in the recipe example, we can define it manually:
Router1#configure terminal
Enter configuration commands, one per line. End with CNTL/Z.
Router1(config)#ip dhcp pool 172.25.2.0/24
Router1(dhcp-config)#option 6 ip 172.25.1.1
Router1(dhcp-config)#exit
Router1(config)#end
Router1#
The router will then translate the manual entry to its user-friendly equivalent in its running configuration file. This can sometimes be a little bit confusing when you are looking at the router configuration, and it isn't what you typed. But both forms are completely equivalent.
We note in passing that some options will accept multiple entries. For example, the default router option and the dns-server option will both accept up to eight IP addresses, in order of preference. However, you will rarely require that many possible entries for a single option. For the default-router option in particular, we recommend using defining a single default-router address. If there are several routers on a segment, the default-router would be the HSRP address. You would only use multiple default routers if you have many routers, but are not running HSRP, which is not a design that we would generally endorse. For more information about HSRP, please see Chapter 22.
To make configuration easier, you can create a hierarchy of DHCP pools. Parent DHCP pools are determined by IP address ranges. For instance, in the following example we configure a parent DHCP pool called ROOT, which is used to assign options to the entire classful network range, 172.25.0.0/16. We then configure two other DHCP pools for specific subnets of 172.25.1.0/24 and 172.25.2.0/24. These two child pools will automatically inherit the options defined within the ROOT pool. You can then overwrite some of the inherited options within the child pools, if necessary:
Router1#configure terminal
Enter configuration commands, one per line. End with CNTL/Z.
Router1(config)#ip dhcp pool ROOT
Router1(dhcp-config)#network 172.25.0.0 255.255.0.0
Router1(dhcp-config)#domain-name oreilly.com
Router1(dhcp-config)#dns-server 172.25.1.1 10.1.2.3
Router1(dhcp-config)#lease 2
Router1(dhcp-config)#exit
Router1(dhcp)#ip dhcp pool 172.25.1.0/24
Router1(dhcp-config)#network 172.25.1.0 255.255.255.0
Router1(dhcp-config)#default-router 172.25.1.1
Router1(dhcp-config)#exit
Router1(dhcp)#ip dhcp pool 172.25.2.0/24
Router1(dhcp-config)#network 172.25.2.0 255.255.255.0
Router1(dhcp-config)#default-router 172.25.2.1
Router1(dhcp-config)#lease 0 0 10
Router1(dhcp-config)#exit
Router1(config)#end
Router1#
The example in the Solution section of this recipe also includes several option statements to define parameters that don't have convenient mnemonics:
Router1(dhcp-config)#option 66 ip 10.1.1.1
Router1(dhcp-config)#option 33 ip 192.0.2.1 172.25.1.3
Router1(dhcp-config)#option 31 hex 01
These option codes are defined in RFC 2132. In this case, Option 66 identifies a TFTP server; Option 33 specifies static routes; and Option 31 tells the client to use ICMP Router Discovery Protocol (IRDP).
The static route statement tells the end device to send all traffic destined to the host, 192.0.2.1/32 to the router at 172.25.1.3.
IRDP allows the client workstation to listen for periodic updates from local routers to determine its default gateway. IRDP is discussed in the introduction to Chapter 22. IRDP is also used in IP Mobility, so we include some configuration examples in Chapter 24.