How to Configure an IPv4 Address on a Cisco IOS XE Interface
This is the command for configuring an IPv4 address on an interface on Cisco IOS XE. Run it in interface configuration mode.
interface [INTERFACE_NAME]
ip address [IP_ADDRESS] [SUBNET_MASK]| Field | Value |
|---|---|
| [INTERFACE_NAME] | Specify the target interface name (e.g. GigabitEthernet1) |
| [IP_ADDRESS] | The IPv4 address to configure |
| [SUBNET_MASK] | The subnet mask in dotted-decimal notation (e.g. 255.255.255.0) |
For enabling/disabling an interface (shutdown / no shutdown), see IOS XE Interface Configuration (shutdown/no shutdown) and Verification.
ip address command only accepts subnet-mask notation. Specifying prefix-length (CIDR) notation such as 192.168.0.1/24 results in a % Invalid input detected error.Verification on Real Devices
In this verification environment, three devices (XE1–XE3, Cisco IOS XE / CSR1000v) are connected to the same segment via a switch (SW), each configured with a different IPv4 address.
Example: Configuring an IPv4 Address (XE1)
This configures 192.168.0.1 255.255.255.0 on XE1’s GigabitEthernet1.
XE1#config term
Enter configuration commands, one per line. End with CNTL/Z.
XE1(config)#interface GigabitEthernet1
XE1(config-if)#ip address 192.168.0.1 255.255.255.0
XE1(config-if)#end
XE1#XE2 and XE3 are configured the same way, with 192.168.0.2 255.255.255.0 and 192.168.0.3 255.255.255.0 respectively.
Behavior When Specifying Prefix-Length (CIDR) Notation
Attempting to specify prefix-length notation (192.168.0.3/24) on XE3 results in an error, as shown below.
XE3#config term
Enter configuration commands, one per line. End with CNTL/Z.
XE3(config)#interface GigabitEthernet1
XE3(config-if)#ip address 192.168.0.3/24
ip address 192.168.0.3/24
^
% Invalid input detected at '^' marker.
XE3(config-if)#end
XE3#For this reason, XE3 was then reconfigured using subnet-mask notation: 192.168.0.3 255.255.255.0.
How It Appears in show running-config
XE1#show running-config interface GigabitEthernet1
Building configuration...
Current configuration : 151 bytes
!
interface GigabitEthernet1
description to Ethernet0/0.SW
ip address 192.168.0.1 255.255.255.0
negotiation auto
no mop enabled
no mop sysid
end
XE1#XE2#show running-config interface GigabitEthernet1
Building configuration...
Current configuration : 151 bytes
!
interface GigabitEthernet1
description to Ethernet0/1.SW
ip address 192.168.0.2 255.255.255.0
negotiation auto
no mop enabled
no mop sysid
end
XE2#XE3#show running-config interface GigabitEthernet1
Building configuration...
Current configuration : 151 bytes
!
interface GigabitEthernet1
description to Ethernet0/2.SW
ip address 192.168.0.3 255.255.255.0
negotiation auto
no mop enabled
no mop sysid
end
XE3#Checking with show interfaces / show ip interface brief
The Internet address field in show interfaces shows the configured IPv4 address in prefix-length notation.
XE1#show interfaces GigabitEthernet1
GigabitEthernet1 is up, line protocol is up
Hardware is CSR vNIC, address is 5254.0065.3ccf (bia 5254.0065.3ccf)
Description: to Ethernet0/0.SW
Internet address is 192.168.0.1/24
MTU 1500 bytes, BW 1000000 Kbit/sec, DLY 10 usec,
reliability 255/255, txload 1/255, rxload 1/255
Encapsulation ARPA, loopback not set
-- snip --
XE1#To check the IPv4 address of all interfaces at once, show ip interface brief is convenient.
XE1#show ip interface brief
Interface IP-Address OK? Method Status Protocol
GigabitEthernet1 192.168.0.1 YES manual up up
GigabitEthernet2 unassigned YES unset administratively down down
GigabitEthernet3 unassigned YES unset administratively down down
GigabitEthernet4 unassigned YES unset administratively down down
Loopback0 unassigned YES unset administratively down down
XE1#Connectivity Check
Running ping from XE1 to XE2 and XE3 confirms connectivity within the same segment.
XE1#ping 192.168.0.2
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.0.2, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 3/3/5 ms
XE1#ping 192.168.0.3
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.0.3, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 3/4/5 ms
XE1#Both pings return a 100% success rate, confirming that XE1, XE2, and XE3 can correctly reach each other within the same segment.
Verification Config
Download XE1 config (r1_ipv4-address.en.cfg)
Download XE2 config (r2_ipv4-address.en.cfg)
Download XE3 config (r3_ipv4-address.en.cfg)
Verification Environment and show Output
Download XE1 show output (r1_ipv4-address_show.en.txt)
Download XE2 show output (r2_ipv4-address_show.en.txt)
Download XE3 show output (r3_ipv4-address_show.en.txt)