ip address

To set a primary or secondary IP address for an interface, use the ip address command. To remove an IP address or disable IP processing, use the no form of this command.

ip address ip-address mask [ secondary ]

no ip address ip-address mask [ secondary ]

Syntax Description

ip-address
IPv4 address in the format A . B . C . D or A . B . C . D / length .
mask
Mask for the associated IP subnet.
secondary
(Optional) Specifies that the configured address is a secondary IP address. If this keyword is omitted, the configured address is the primary IP address.

Command Default

No IP address is defined for the interface.

Command Modes

Interface configuration mode
Subinterface configuration mode

Command History

Release
Modification
5.0(3)N1(1)
This command was introduced.

Usage Guidelines


Note Before you use this command, make sure that you use the no switchport command on the interface to use the Layer 3 features.


An interface can have one primary IP address and one secondary IP address.

You can disable IP processing on a particular interface by removing its IP address with the no ip address command.

The optional secondary keyword allows you to specify a secondary IP address. Secondary addresses are treated like primary addresses, except the system never generates datagrams other than routing updates with secondary source addresses. IP broadcasts and Address Resolution Protocol (ARP) requests are handled, as are interface routes in the IP routing table.


Note When you are routing using the Open Shortest Path First (OSPF) algorithm, ensure that the secondary address of an interface fall into the same OSPF area as the primary addresses.


Examples

This example shows how to configure the IP address 192.168.0.27 as the primary address and 192.168.0.5 as the secondary address for Ethernet interface 1/5:

switch(config)# interface ethernet 1/5
switch(config-if)# no switchport
switch(config-if)# ip address 192.168.0.27 255.255.255.0
switch(config-if )# ip address 192.168.0.5 255.255.255.0 secondary
switch(config-if)#
 

Related Commands

Command
Description
copy running-config startup-config
Saves the configuration change to the startup configuration file.
no switchport
Enables an interface for Layer 3 configuration.
show ip interface
Displays interfaces configured for IPv4.