Re: DHCP ad hoc (MAC<=>IP)



check to see if your router supports the following feature

Download this chapter
Configuring the Cisco IOS DHCP Server

Table Of Contents
Configuring the Cisco IOS DHCP Server

Contents

Prerequisites for Configuring the DHCP Server

Information About the Cisco IOS DHCP Server

Overview of the DHCP Server

DHCP Server Address Allocation Using Option 82

How to Configure the Cisco IOS DHCP Server

Configuring a DHCP Database Agent or Disabling Conflict Logging

Excluding IP Addresses

Configuring a DHCP Address Pool

Configuring Manual Bindings

Configuring DHCP Static Mapping

Customizing DHCP Server Operation

Configuring a Remote Router to Import DHCP Server Options from a
Central DHCP Server

Configuring DHCP Address Allocation Using Option 82

Configuring a Static Route with the Next-Hop Dynamically Obtained
Through DHCP

Clearing DHCP Server Variables

Configuration Examples for the Cisco IOS DHCP Server

DHCP Database Agent Configuration: Example

DHCP Address Pool Configuration: Example

Excluding IP Addresses: Example

Manual Bindings Configuration: Example

Static Mapping Configuration: Example

Option to Ignore all BOOTP Requests: Example

DHCP Server Options Import: Example

DHCP Address Allocation Using Option 82: Example

Static Routes Using a DHCP Default Gateway: Example

Additional References

Related Documents

Standards

MIBs

RFCs

Technical Assistance

Feature Information for the Cisco IOS DHCP Server



Configuring the Cisco IOS DHCP Server

--------------------------------------------------------------------------------

Cisco routers running Cisco IOS software include Dynamic Host
Configuration Protocol (DHCP) server and relay agent software. The
Cisco IOS DHCP server is a full DHCP server implementation that assigns
and manages IP addresses from specified address pools within the router
to DHCP clients. The DHCP server can be configured to assign additional
parameters such as the IP address of the domain name system (DNS)
server and the default router.

This module describes the concepts and the tasks needed to configure
the Cisco IOS DHCP server.

Module History

This module was first published on May 2, 2005, and last updated on
January 10, 2006.

Finding Feature Information in This Module

Your Cisco IOS software release may not support all features. To find
information about feature support and configuration, use the "Feature
Information for the Cisco IOS DHCP Server" section.

Contents
· Prerequisites for Configuring the DHCP Server

· Information About the Cisco IOS DHCP Server

· How to Configure the Cisco IOS DHCP Server

· Configuration Examples for the Cisco IOS DHCP Server

· Additional References

· Feature Information for the Cisco IOS DHCP Server

Prerequisites for Configuring the DHCP Server
Before you configure the Cisco IOS DHCP server, you should understand
the concepts documented in the "DHCP Overview" module.

The Cisco IOS DHCP server and relay agent are enabled by default. You
can verify if they have been disabled by checking your configuration
file. If they have been disabled, the no service dhcp command will
appear in the configuration file. Use the service dhcp command to
reenable the functionality if necessary.

The Cisco IOS DHCP relay agent will be enabled on an interface only
when the ip helper-address is configured. This command enables the DHCP
broadcast to be forwarded to the configured DHCP server.

Information About the Cisco IOS DHCP Server
Before you configure the DHCP server, you should understand the
following concepts:

· Overview of the DHCP Server

· DHCP Server Address Allocation Using Option 82

Overview of the DHCP Server
The Cisco IOS DHCP server accepts address assignment requests and
renewals and assigns the addresses from predefined groups of addresses
contained within DHCP address pools. These address pools can also be
configured to supply additional information to the requesting client
such as the IP address of the DNS server, the default router, and other
configuration parameters. The Cisco IOS DHCP server can accept
broadcasts from locally attached LAN segments or from DHCP requests
that have been forwarded by other DHCP relay agents within the network.


DHCP Server Address Allocation Using Option 82
The Cisco IOS DHCP server can allocate dynamic IP addresses based on
the relay information option (option 82) information sent by the relay
agent.

Automatic DHCP address allocation is typically based on an IP address,
whether it be the gateway address (giaddr field of the DHCP packet) or
the incoming interface IP address. In some networks, it is necessary to
use additional information to further determine which IP addresses to
allocate. By using option 82, the Cisco IOS relay agent has long been
able to include additional information about itself when forwarding
client-originated DHCP packets to a DHCP server. The Cisco IOS DHCP
server can also use option 82 as a means to provide additional
information to properly allocate IP addresses to DHCP clients.

How to Configure the Cisco IOS DHCP Server
This section contains the following tasks:

· Configuring a DHCP Database Agent or Disabling Conflict Logging
(required)

· Excluding IP Addresses (optional)

· Configuring a DHCP Address Pool (required)

· Configuring Manual Bindings (optional)

· Configuring DHCP Static Mapping (optional)

· Customizing DHCP Server Operation (optional)

· Configuring a Remote Router to Import DHCP Server Options from a
Central DHCP Server (optional)

· Configuring DHCP Address Allocation Using Option 82 (optional)

· Configuring a Static Route with the Next-Hop Dynamically Obtained
Through DHCP (optional)

· Clearing DHCP Server Variables (optional)

Configuring a DHCP Database Agent or Disabling Conflict Logging
Perform this task to configure a DHCP database agent.

Database Agents
A DHCP database agent is any host-for example, an FTP, TFTP, or rcp
server-that stores the DHCP bindings database. You can configure
multiple DHCP database agents and you can configure the interval
between database updates and transfers for each agent.

Automatic bindings are IP addresses that have been automatically mapped
to the MAC addresses of hosts that are found in the DHCP database.
Automatic bindings are stored on a database agent. The bindings are
saved as text records for easy maintenance.

Address Conflicts
An address conflict occurs when two hosts use the same IP address.
During address assignment, DHCP checks for conflicts using ping and
gratuitous ARP. If a conflict is detected, the address is removed from
the pool. The address will not be assigned until the administrator
resolves the conflict.

Restrictions
Cisco strongly recommends using database agents. However, the Cisco IOS
server can run without them. If you choose not to configure a DHCP
database agent, disable the recording of DHCP address conflicts on the
DHCP server by using the no ip dhcp conflict logging command in global
configuration mode. If there is conflict logging but no database agent
configured, bindings are lost across router reboots. Possible false
conflicts can occur causing the address to be removed from the address
pool until the network administrator intervenes.

SUMMARY STEPS
1. enable

2. configure terminal

3. ip dhcp database url [timeout seconds | write-delay seconds]
or
no ip dhcp conflict logging

DETAILED STEPS
Command or Action Purpose
Step 1
enable

Example:
Router> enable
Enables privileged EXEC mode.

·Enter your password if prompted.

Step 2
configure terminal

Example:
Router# configure terminal
Enters global configuration mode.

Step 3
ip dhcp database url [timeout seconds | write-delay seconds]

or

no ip dhcp conflict logging

Example:
Router(config)# ip dhcp database
ftp://user:password@xxxxxxxxxx/router-dhcp timeout 80

or

Example:
Router(config)# no ip dhcp conflict logging
Configures a DHCP server to save automatic bindings on a remote host
called a database agent.

or

Disables DHCP address conflict logging.

·Choose this option only if you do not configure a DHCP database
agent. See the "Restrictions" section for guidelines.


Excluding IP Addresses
Perform this task to specify IP addresses (excluded addresses) that the
DHCP server should not assign to clients.

The IP address configured on the router interface is automatically
excluded from the DHCP address pool. The DHCP server assumes that all
other IP addresses in a DHCP address pool subnet are available for
assigning to DHCP clients.

You need to exclude addresses from the pool if the DHCP server should
not allocate those IP addresses. An example usage scenario is when two
DHCP servers are set up to service the same network segment (subnet)
for redundancy. If the two DHCP servers do not coordinate their
services with each other using a protocol such as DHCP failover, then
each DHCP server must be configured to allocate from a non-overlapping
set of addresses in the shared subnet. See the "Excluding IP Addresses:
Example" for a configuration example.

SUMMARY STEPS
1. enable

2. configure terminal

3. ip dhcp excluded-address low-address [high-address]

DETAILED STEPS
Command or Action Purpose
Step 1
enable

Example:
Router> enable
Enables privileged EXEC mode.

·Enter your password if prompted.

Step 2
configure terminal

Example:
Router# configure terminal
Enters global configuration mode.

Step 3
ip dhcp excluded-address low-address [high-address]

Example:
Router(config)# ip dhcp excluded-address 172.16.1.100 172.16.1.103
Specifies the IP addresses that the DHCP server should not assign to
DHCP clients.


Configuring a DHCP Address Pool
Perform this task to configure a DHCP address pool. On a per-address
pool basis, specify DHCP options for the client as necessary.

DHCP Address Pool Conventions
You can configure a DHCP address pool with a name that is a symbolic
string (such as "engineering") or an integer (such as 0). Configuring a
DHCP address pool also places you in DHCP pool configuration
mode-identified by the (dhcp-config)# prompt-from which you can
configure pool parameters (for example, the IP subnet number and
default router list).

DHCP Address Pool Selection
DHCP defines a process by which the DHCP server knows the IP subnet in
which the DHCP client resides, and it can assign an IP address from a
pool of valid IP addresses in that subnet.

The DHCP server identifies which DHCP address pool to use to service a
client request as follows:

·If the client is not directly connected (the giaddr field of the
DHCPDISCOVER broadcast message is non-zero), the DHCP server matches
the DHCPDISCOVER with a DHCP pool that has the subnet that contains the
IP address in the giaddr field.

·If the client is directly connected (the giaddr field is zero), the
DHCP server matches the DHCPDISCOVER with DHCP pool(s) that contain the
subnet(s) configured on the receiving interface. If the interface has
secondary IP addresses, the subnets associated with the secondary IP
addresses are examined for possible allocation only after the subnet
associated with the primary IP address (on the interface) is exhausted.


Cisco IOS DHCP server software supports advanced capabilites for IP
address allocation. See the "Configuring DHCP Address Allocation Using
Option 82" section for more information.

Prerequisites
Before you configure the DHCP address pool, you need to:

·Identify DHCP options for devices where necessary, including the
following:

-Default boot image name

-Default routers

-Domain Name System (DNS) servers

-NetBIOS name server

·Decide on a NetBIOS node type (b, p, m, or h).

·Decide on a DNS domain name.

Restrictions
You cannot configure manual bindings within the same pool that is
configured with the network DHCP pool configuration command. To
configure manual bindings, see the "Configuring Manual Bindings"
section.

SUMMARY STEPS
1. enable

2. configure terminal

3. ip dhcp pool name

4. network network-number [mask | /prefix-length]

5. domain-name domain

6. dns-server address [address2 ... address8]

7. bootfile filename

8. next-server address [address2 ... address8]

9. netbios-name-server address [address2 ... address8]

10. netbios-node-type type

11. default-router address [address2 ... address8]

12. option code [instance number] {ascii string | hex string |
ip-address}

13. lease {days [hours] [minutes] | infinite}

14. end

15. show ip dhcp binding [address]

16. show ip dhcp conflict [address]

17. show ip dhcp database [url]

18. show ip dhcp server statistics

DETAILED STEPS
Command or Action Purpose
Step 1
enable

Example:
Router> enable
Enables privileged EXEC mode.

·Enter your password if prompted.

Step 2
configure terminal

Example:
Router# configure terminal
Enters global configuration mode.

Step 3
ip dhcp pool name

Example:
Router(config)# ip dhcp pool 1
Creates a name for the DHCP server address pool and enters DHCP pool
configuration mode.

Step 4
network network-number [mask | /prefix-length]

Example:
Router(dhcp-config)# network 172.16.0.0 /16
Specifies the subnet network number and mask of the DHCP address pool.


Step 5
domain-name domain

Example:
Router(dhcp-config)# domain-name cisco.com
Specifies the domain name for the client.

Step 6
dns-server address [address2 ... address8]

Example:
Router(dhcp-config)# dns server 172.16.1.103 172.16.2.103
Specifies the IP address of a DNS server that is available to a DHCP
client.

·One IP address is required; however, you can specify up to eight IP
addresses in one command line.

·Servers should be listed in order of preference.

Step 7
bootfile filename

Example:
Router(dhcp-config)# bootfile xllboot
(Optional) Specifies the name of the default boot image for a DHCP
client.

·The boot file is used to store the boot image for the client. The
boot image is generally the operating system the client uses to load.

Step 8
next-server address [address2 ... address8]

Example:
Router(dhcp-config)# next-server 172.17.1.103 172.17.2.103
(Optional) Configures the next server in the boot process of a DHCP
client.

·If multiple servers are specified, DHCP assigns them to clients in
round-robin order. The first client gets address 1, the next client
gets address 2, and so on.

·If this command is not configured, DHCP uses the server specified by
the ip helper address command as the boot server.

Step 9
netbios-name-server address [address2 ... address8]

Example:
Router(dhcp-config)# netbios-name-server 172.16.1.103 172.16.2.103
(Optional) Specifies the NetBIOS WINS server that is available to a
Microsoft DHCP client.

·One address is required; however, you can specify up to eight
addresses in one command line.

·Servers should be listed in order of preference.

Step 10
netbios-node-type type

Example:
Router(dhcp-config)# netbios-node-type h-node
(Optional) Specifies the NetBIOS node type for a Microsoft DHCP
client.

Step 11
default-router address [address2 ... address8]

Example:
Router(dhcp-config)# default-router 172.16.1.100 172.16.1.101
(Optional) Specifies the IP address of the default router for a DHCP
client.

·After a DHCP client has booted, the client begins sending packets to
its default router. The IP address should be on the same subnet as the
client. One IP address is required; however, you can specify up to
eight addresses in one command line.

·Routers should be listed in order of preference; that is, address 1
is the most preferred router.

Step 12
option code [instance number] {ascii string | hex string | ip-address}


Example:
Router(dhcp-config)# option 19 hex 01
(Optional) Configures DHCP server options.

Step 13
lease {days [hours] [minutes]| infinite}

Example:
Router(dhcp-config)# lease 30
(Optional) Specifies the duration of the lease.

·The default is a one-day lease.

·The infinite keyword specifies that the duration of the lease is
unlimited.

Step 14
end

Example:
Router(dhcp-config)# end
Returns to global configuration mode.

Step 15
show ip dhcp binding [address]

Example:
Router# show ip dhcp binding
(Optional) Displays a list of all bindings created on a specific DHCP
server.

·Use the show ip dhcp binding command to display the IP addresses
that have already been assigned. Verify that the address pool has not
been exhausted. If necessary, re-create the pool to create a larger
pool of addresses.

·Use the show ip dhcp binding command to display the lease expiration
date and time of the IP addresss of the host.

Step 16
show ip dhcp conflict [address]

Example:
Router# show ip dhcp conflict
(Optional) Displays a list of all address conflicts.

Step 17
show ip dhcp database [url]

Example:
Router# show ip dhcp database
(Optional) Displays recent activity on the DHCP database.

Step 18
show ip dhcp server statistics

Example:
Router# show ip dhcp server statistics
(Optional) Displays count information about server statistics and
messages sent and received.


Configuring Manual Bindings
Perform this task to configure manual bindings.

Address Bindings
An address binding is a mapping between the IP address and MAC address
of a client. The IP address of a client can be assigned manually by an
administrator or assigned automatically from a pool by a DHCP server.

Manual bindings are IP addresses that have been manually mapped to the
MAC addresses of hosts that are found in the DHCP database. Manual
bindings are stored in NVRAM on the DHCP server. Manual bindings are
just special address pools. There is no limit on the number of manual
bindings, but you can only configure one manual binding per host pool.

Automatic bindings are IP addresses that have been automatically mapped
to the MAC addresses of hosts that are found in the DHCP database.
Automatic bindings are stored on a remote host called a database agent.
The bindings are saved as text records for easy maintenance.

Restrictions
You cannot configure manual bindings within the same pool that is
configured with the network command in DHCP pool configuration mode.
See the "Configuring a DHCP Address Pool" section for information about
DHCP address pools and the network command.

SUMMARY STEPS
1. enable

2. configure terminal

3. ip dhcp pool pool-name

4. host address [mask | /prefix-length]

5. hardware-address hardware-address type
or
client-identifier unique-identifier

6. client-name name

DETAILED STEPS
Command or Action Purpose
Step 1
enable

Example:
Router> enable
Enables privileged EXEC mode.

·Enter your password if prompted.

Step 2
configure terminal

Example:
Router# configure terminal
Enters global configuration mode.

Step 3
ip dhcp pool pool-name

Example:
Router(config)# ip dhcp pool host-pool
Creates a name for the DHCP server address pool and places you in DHCP
pool configuration mode-identified by the (dhcp-config)# prompt.

Step 4
host address [mask | /prefix-length]

Example:
Router(dhcp-config)# host
Specifies the IP address and subnet mask of the client.

·There is no limit on the number of manual bindings but you can only
configure one manual binding per host pool.

Step 5
hardware-address hardware-address type


or

client-identifier unique-identifier


Example:
Router(dhcp-config)# hardware-address b708.1388.f166


or

Router(dhcp-config)# client-identifier 01b7.0813.8811.66
Specifies a hardware address for the client.

or

Specifies the unique identifier for Microsoft DHCP clients.

·Microsoft clients require client identifiers instead of hardware
addresses. The unique identification of the client is specified in
dotted hexadecimal notation, for example, 01b7.0813.8811.66, where 01
represents the Ethernet media type.

Step 6
client-name name

Example:
Router(dhcp-config)# client-name client1
(Optional) Specifies the name of the client using any standard ASCII
character.

·The client name should not include the domain name. For example, the
name mars should not be specified as mars.cisco.com.


Configuring DHCP Static Mapping
The DHCP-Static Mapping feature enables assignment of static IP
addresses without creating numerous host pools with manual bindings by
using a customer-created text file that the DHCP server reads. The
benefit of this feature is that it eliminates the need for a long
configuration file and reduces the space required in NVRAM to maintain
address pools.

DHCP Database
A DHCP database contains the mappings between a client IP address and
hardware address, referred to as a binding. There are two types of
bindings: manual bindings that map a single hardware address to a
single IP address, and automatic bindings that dynamically map a
hardware address to an IP address from a pool of IP addresses. Manual
(also known as static) bindings can be configured individually directly
on the router or, by using the DHCP-Static Mapping feature, these
static bindings can be read from a separate static mapping text file.
The static mapping text files are read when a router reloads or the
DHCP service restarts. These files are read-only.

The read static bindings are treated just like the manual bindings, in
that they are:

·Retained across DHCPRELEASEs from the clients.

·Not timed out.

·Deleted only upon deletion of the pool.

·Provided appropriate exclusions for the contained addresses, which
are created at the time of the read.

Just like automatic bindings and manual bindings, the static bindings
from the static mapping text file are also displayed by using the show
ip dhcp binding command.

This procedure contains the following tasks:

· Configuring a DHCP Database Agent or Disabling Conflict Logging
(required)

· Configuring the DHCP Server to Read a Static Mapping Text File
(required)

Creating the Static Mapping Text File
Perform this task to create the static mapping text file. You will
input your addresses in the text file, which is stored in the DHCP
database for the DHCP server to read. There is no limit on the number
of addresses in the file. The file format has the following elements:

·Time the file was created

·Database version number

·IP address

·Hardware type

·Hardware address

·Lease expiration

·End-of-file designator

See Table 1 for more details about the format of the text file.

The following is a sample static mapping text file:

*time* Jan 21 2005 03:52 PM

*version* 2

!IP address Type Hardware address Lease
expiration

10.0.0.4 /24 1 0090.bff6.081e
Infinite

10.0.0.5 /28 id 00b7.0813.88f1.66
Infinite

10.0.0.2 /21 1 0090.bff6.081d
Infinite

*end*


Table 1 Static Mapping Text File Field Descriptions
Field Description
*time*
Specifies the time the file was created. This field allows DHCP to
differentiate between newer and older database versions when multiple
agents are configured. The valid format of the time is Mmm dd yyyy
hh:mm AM/PM.

*version* 2
Database version number.

IP address
Static IP address. If the subnet mask is not specified, a natural mask
is assumed depending on the IP address. There must be a space between
the IP address and mask.

Type
Specifies the hardware type. For example, type "1" indicates Ethernet.
The type "id" indicates that the field is a DHCP client identifier.
Legal values can be found online at
http://www.iana.org/assignments/arp-parameters in the "Number Hardware
Type" list.

Hardware address
Specifies the hardware address.

When the type is numeric, it refers to the hardware media. Legal values
can be found online at http://www.iana.org/assignments/arp-parameters
in the "Number Hardware Type" list.

When the type is"id", this means that we are matching on the client
identifier.

For more information about the client identifier, please see RFC 2132,
DHCP Options and BOOTP Vendor Extensions, section 9.14, located at
http://www.ietf.org/rfc/rfc2132.txt

or the client-identifier command reference page located at
http://www.cisco.com/univercd/cc/td/doc/product/software/ios124/124tcr/tiad_r/adr_a1ht.htm#wp1125872


If you are unsure what client identifier to match on, use the debug
dhcp detail command to display the client identifier being sent to the
DHCP server from the client.

Lease Expiration
Specifies the expiration of the lease. "Infinite" specifies that the
duration of the lease is unlimited.

*end*
End of file. DHCP uses the *end* designator to detect file truncation.






Configuring the DHCP Server to Read a Static Mapping Text File
Perform this task to configure the DHCP server to read the static
mapping text file.

Prerequisites
The administrator should create the static mapping text file in the
correct format and configure the address pools before performing this
task.

Before editing the file, you must disable the DHCP server using the no
service dhcp command.

Restrictions
The static bindings must not be deleted when a DHCPRELEASE is received
or must not be timed out by the DHCP timer. The static bindings should
be treated just like manual bindings created by using the ip dhcp pool
command.

SUMMARY STEPS
1. enable

2. configure terminal

3. ip dhcp pool name

4. origin file url

5. end

6. show ip dhcp binding [address]

.



Relevant Pages