ip address
Syntax
ip address <IPV4-ADDR>/<MASK> [secondary]
no ip address <IPV4-ADDR>/<MASK> [secondary]
Description
Sets an IPv4 address for the current layer 3 interface.
- Configure an interface as layer 3 using the
routing
command. Two IPv4 addresses can be configured per interface.
The
no
form of this command removes the IPv4 address from the interface.
Command context
config-if
config-loopback-if
config-if-vlan
Parameters
<IPV4-ADDR>
Specifies an IP address in IPv4 format (
x.x.x.x
), wherex
is a decimal number from 0 to 255. You can remove leading zeros. For example, the address192.169.005.100
becomes192.168.5.100
.<MASK>
Specifies the number of bits in the address mask in CIDR format (
x
), wherex
is a decimal number from 0 to 128.secondary
Specifies a secondary IP address.
Authority
Administrators
Examples
Creating a layer 3 interface on port 1/1/1 and setting its IP address to 192.168.100.1 with a mask of 24 bits:
switch(config)# interface 1/1/1 switch(config-if)# routing switch(config-if)# ip address 192.168.100.1/24
Removing the IP address 192.168.100.1 with a mask of 24 bits from interface 1/1/1:
switch(config)# interface 1/1/1 switch(config-if)# no ip address 192.168.100.1/24
Assigning the IP address 192.168.20.1 with a mask of 24 bits to loopback interface 1:
switch(config)# interface loopback 1 switch(config-loopback-if)# ip address 192.168.20.1/24
Assigning the IP address 192.168.199.1 with a mask of 24 bits to VLAN 10:
switch(config)# interface vlan 10 switch(config-loopback-if)# ip address 192.168.199.1/24