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

IPv4 address in the format A . B . C . D or A . B . C . D / length .
Mask for the associated IP subnet.
(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

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.


This example shows how to configure the IP address as the primary address and 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
switch(config-if )# ip address secondary

Related Commands

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.