To acquire an IP
address on an interface from the DHCP, use the
ip
address
dhcp command in interface configuration mode. To
remove any address that was acquired, use the
no form of this
command.
ip address dhcp [client-id interface-type number] [hostname hostname]
no ip address dhcp [client-id interface-type number] [hostname hostname]
Syntax Description
client-id
|
(Optional) Specifies the client identifier. By default, the client identifier
is an ASCII value. The
client-id
interface-type
number option sets the client identifier to the
hexadecimal MAC address of the named interface.
|
interface-type
|
(Optional) Interface type. For more information, use the question mark (?)
online help function.
|
number
|
(Optional) Interface or subinterface number. For more information about the
numbering syntax for your networking device, use the question mark (?) online
help function.
|
hostname
|
(Optional) Specifies the hostname.
|
hostname
|
(Optional) Name of the host to be placed in the DHCP option 12 field. This name
need not be the same as the hostname entered in global configuration mode.
|
Command Default
The hostname is the
globally configured hostname of the device. The client identifier is an ASCII
value.
Command Modes
Interface
configuration (config-if)
Command History
Release
|
Modification
|
12.1(2)T
|
This
command was introduced.
|
12.1(3)T
|
This
command was modified. The
client-id keyword and
interface-type
number argument were added.
|
12.2(3)
|
This
command was modified. The
hostname keyword and
hostname argument were added. The behavior of the
client-id
interface-type
number option
changed. See the “Usage Guidelines” section for details.
|
12.2(8)T
|
This
command was modified. The command was expanded for use on PPP over ATM (PPPoA)
interfaces and certain ATM interfaces.
|
12.2(33)SRA
|
This
command was integrated into Cisco IOS Release 12.2(33)SRA.
|
12.2SX
|
This
command is supported in the Cisco IOS Release 12.2SX train. Support in a
specific 12.2SX release of this train depends on your feature set, platform,
and platform hardware.
|
15.1(3)T
|
This
command was modified. Support was provided on the tunnel interface.
|
Usage Guidelines
Note |
Prior to Cisco
IOS Release 12.2(8)T, the
ip
address
dhcp command could be used only on Ethernet
interfaces.
|
The
ip
address
dhcp command allows any interface to dynamically
learn its IP address by using the DHCP protocol. It is especially useful on
Ethernet interfaces that dynamically connect to an Internet service provider
(ISP). Once assigned a dynamic address, the interface can be used with the Port
Address Translation (PAT) of Cisco IOS Network Address Translation (NAT) to
provide Internet access to a privately addressed network attached to the
device.
The
ip
address
dhcp command also works with ATM point-to-point
interfaces and will accept any encapsulation type. However, for ATM multipoint
interfaces you must specify Inverse ARP via the
protocol
ip
inarp interface configuration command and use only
the aa15snap encapsulation type.
Some ISPs require
that the DHCPDISCOVER message have a specific hostname and client identifier
that is the MAC address of the interface. The most typical usage of the
ip
address
dhcp
client-id
interface-type
number
hostname
hostname
command is when
interface-type is the Ethernet interface where the
command is configured and
interface-type
number is the hostname provided by the ISP.
A client
identifier (DHCP option 61) can be a hexadecimal or an ASCII value. By default,
the client identifier is an ASCII value. The
client-id
interface-type
number option overrides the default and forces the
use of the hexadecimal MAC address of the named interface.
Note |
Between Cisco
IOS Releases 12.1(3)T and 12.2(3), the
client-id
optional keyword allows the change of the fixed ASCII value for the client
identifier. After Release 12.2(3), the optional
client-id
keyword forces the use of the hexadecimal MAC address of the named interface as
the client identifier.
|
If a Cisco device
is configured to obtain its IP address from a DHCP server, it sends a
DHCPDISCOVER message to provide information about itself to the DHCP server on
the network.
If you use the
ip
address
dhcp command with or without any of the optional
keywords, the DHCP option 12 field (hostname option) is included in the
DISCOVER message. By default, the hostname specified in option 12 will be the
globally configured hostname of the device. However, you can use the
ip
address
dhcp
hostname
hostname
command to place a different name in the DHCP option 12 field than the globally
configured hostname of the device.
The
no
ip
address
dhcp command removes any IP address that was
acquired, thus sending a DHCPRELEASE message.
You might need to
experiment with different configurations to determine the one required by your
DHCP server. The table below shows the possible configuration methods and the
information placed in the DISCOVER message for each method.
Table 1. Configuration Method and
Resulting Contents of the DISCOVER Message
Configuration Method
|
Contents
of DISCOVER Messages
|
ip
address
dhcp
|
The
DISCOVER message contains “cisco-
mac-address
-Eth1” in the client ID field. The
mac-address
is the MAC address of the Ethernet 1 interface and contains the default
hostname of the device in the option 12 field.
|
ip
address
dhcp
hostname
hostname
|
The
DISCOVER message contains “cisco-
mac-address
-Eth1” in the client ID field. The
mac-address
is the MAC address of the Ethernet 1 interface, and contains
hostname in
the option 12 field.
|
ip
address
dhcp
client-id
ethernet
1
|
The
DISCOVER message contains the MAC address of the Ethernet 1 interface in the
client ID field and contains the default hostname of the device in the option
12 field.
|
ip
address
dhcp
client-id
ethernet
1
hostname
hostname
|
The
DISCOVER message contains the MAC address of the Ethernet 1 interface in the
client ID field and contains
hostname in
the option 12 field.
|
Examples
In the examples
that follow, the command
ip
address
dhcp is entered for Ethernet interface 1. The
DISCOVER message sent by a device configured as shown in the following example
would contain “cisco-
mac-address
-Eth1” in the client-ID field, and the value abc in the option 12 field.
hostname abc
!
interface GigabitEthernet 1/0/1
ip address dhcp
The DISCOVER
message sent by a device configured as shown in the following example would
contain “cisco- mac-address -Eth1” in the client-ID field, and the value def in
the option 12 field.
hostname abc
!
interface GigabitEthernet 1/0/1
ip address dhcp hostname def
The DISCOVER
message sent by a device configured as shown in the following example would
contain the MAC address of Ethernet interface 1 in the client-id field, and the
value abc in the option 12 field.
hostname abc
!
interface Ethernet 1
ip address dhcp client-id GigabitEthernet 1/0/1
The DISCOVER
message sent by a device configured as shown in the following example would
contain the MAC address of Ethernet interface 1 in the client-id field, and the
value def in the option 12 field.
hostname abc
!
interface Ethernet 1
ip address dhcp client-id GigabitEthernet 1/0/1 hostname def