Previous section   Next section

Recipe 20.5 Defining DHCP Configuration Options

20.5.1 Problem

You want to dynamically deliver configuration parameters to client workstations.

20.5.2 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 24.10.1.1 172.25.1.3 
Router1(dhcp-config)#option 31 hex 01
Router1(dhcp-config)#lease 2
Router1(dhcp-config)#end
Router1#

20.5.3 Discussion

The strength of DHCP is its ability to configure client workstations from a centralized location using DHCP options. It greatly reduces support 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, 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.

Table 20-2. The RFC 2132 equivalent option numbers to Cisco's DHCP commands

Custom name

RFC 2132 option number

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 names 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)#end
Router1#

The router will then translate the manual entry to its user-friendly equivalent in its running configuration file. It can be a little confusing when you look at the router configuration and it isn't what you typed, but both forms are completely equivalent.

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 use multiple default routers only if you have many routers, but are not running HSRP. This is not a design that we would generally endorse. For more information about HSRP, 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)#end
Router1#

The DHCP lease period is the only option that cannot be inherited from parent DHCP pools. This means that you must explicitly define a lease period for each pool. The router will use the default lease period of one day for any pool that doesn't have its own value.

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.

20.5.4 See Also

Recipe 20.4; Chapter 22; RFC 2132


  Previous section   Next section
Top