Use the ip address interface configuration command to set an IP address. To remove an IP address, use the no form of this command.
Syntax
ip address ip-address {mask | prefix-length}
no ip address [ip-address]
ip-addressIP address
maskThe IP address network mask
prefix-lengthSpecifies the number of bits that comprise the IP address prefix. The prefix length must be preceded by a forward slash (/) (Range: 0-32).
Default Configuration
This command has no default configuration.
Command Mode
Interface Configuration (VLAN) Mode
User Guidelines
An IP address cannot be configured for a range of interfaces (interface range ethernet command).
Examples
The following example configures VLAN 1 with the IP address 131.108.1.27 and subnet mask 255.255.255.0.
Console (config)# interface vlan 1
Console (config-if)# ip address 131.108.1.27 255.255.255.0
ip address-dhcp
Use the ip address-dhcp interface configuration command to acquire an IP address on an interface from the Dynamic Host Configuration Protocol (DHCP) server. To deconfigure any acquired address, use the no form of this command.
The no ip address-dhcp command deconfigures any IP address that was acquired, thus sending a DHCPRELEASE message.
Syntax
ip address-dhcp [hostnamehost-name]
no ip address-dhcp
hostnameSpecifies the host name.
host-nameDHCP host name. This name need not be the same as the host name entered in Global Configuration Mode.
Default Configuration
This command has no default configuration.
Command Mode
Interface Configuration (VLAN)
User Guidelines
The ip address-dhcp command allows any interface to dynamically learn its IP address by using the DHCP protocol.
Some DHCP servers require that the DHCPDISCOVER message have a specific host name. The most typical usage of the ip address-dhcphostnamehost-name command is when host-name is the host name provided by the system administrator.
If a 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 the ip address-dhcp command is used with or without the optional keyword, the DHCP option 12 field (host name option) is included in the DISCOVER message. By default, the specified DHCP host name is the device globally configured host name.
Examples
The following example acquires an IP address on an ethernet interface from DHCP.
Console (config)# interface ethernet 1/e8
Console (config-if)# ip address-dhcp
ip default-gateway
Use the ip default-gateway global configuration command to define default gateways. To remove a default gateway, use the no form of this command.
Syntax
ip default-gateway ip-address1 [ip-address2...]
no ip default-gateway [ip-address]
ip-addressDefault gateway IP address.
Default Configuration
No default gateway is defined.
Command Mode
Global Configuration Mode
User Guidelines
Multiple gateways can be configured, but only one can be active.
Examples
The following example defines a default gateway with the IP address 196.210.10.1.
Console (config)# ip default-gateway 196.210.10.1
show ip interface
Use the show ip interface privileged EXEC command to display a list of IP interfaces configured on the device.
Syntax
show ip interface [ethernetinterface-number | vlan vlan-id | port-channel number]
ethernet interfaceAn ethernet port. The full syntax is: unit/port.
The following example displays VLAN 1 configuration.
Console# show ip interface vlan 1
Internet address is 10.7.1.192/24
Directed broadcast forwarding is disabled
Proxy ARP is disabled (Global configuration)
arp
Use the arp global configuration command to add a static entry in the Address Resolution Protocol (ARP) cache. To remove an entry from the ARP cache, use the no form of this command.
no arp ip_addr {ethernetinterface-number | vlan vlan-id | port-channel number}
ip_addrIP address or IP alias to map to the specified MAC address.
hw_addrMAC address to map to the specified IP address or IP alias.
ethernetinterface-numberEthernet port number.
vlan vlan-idVLAN number.
port-channel numberPort-channel number.
Default Configuration
This command has no default configuration.
Command Mode
Global Configuration Mode
User Guidelines
The software uses ARP cache entries to translate 32-bit IP addresses into 48-bit hardware addresses. Because most hosts support dynamic resolution, static ARP cache entries do not need to be specified.
Examples
The following example adds an IP address and MAC address to the ARP table.
Use the arp timeout global configuration command to configure how long an entry remains in the ARP cache. To restore the default value, use the no form of this command.
Note: The ARP entry is deleted between the period of the "timeout value" and twice the "timeout value". For example, if the timeout value is 20 seconds, the ARP value is deleted during the period of 20 to 40 seconds.
Syntax
arp timeout seconds
no arp timeout seconds
secondsTime (in seconds) that an entry remains in the ARP cache. It is recommended not to set the time less than 3600 seconds. A value of zero means that entries are never cleared from the cache (Range: 0-40000000).
Default Configuration
The default timeout is 60000 seconds.
Command Mode
Global Configuration Mode
User Guidelines
There are no user guidelines for this command.
Examples
The following example configures ARP timeout to 12000 seconds.
Console# arp timeout 12000
clear arp-cache
Use the clear arp-cache privileged EXEC command to delete all dynamic entries from the ARP cache.
Syntax
clear arp-cache
Default Configuration
This command has no default configuration.
Command Mode
Privileged EXEC Mode
User Guidelines
There are no user guidelines for this command.
Examples
The following example deletes all dynamic entries from the ARP cache.
Console# clear arp-cache
show arp
Use the show arp privileged EXEC command to display entries in the ARP table.
Syntax
show arp
Default Configuration
This command has no default configuration.
Command Mode
Privileged EXEC Mode
User Guidelines
There are no user guidelines for this command.
Examples
The following example displays entries in the ARP table.