How to Configure an IPv4 Address on a Cisco IOS XR Interface
This is the command for configuring an IPv4 address on a Cisco IOS XR interface. Run it in interface configuration mode.
The ipv4 address command on IOS XR accepts either prefix-length notation or subnet-mask notation.
interface [INTERFACE_NAME]
ipv4 address [IP_ADDRESS]/[PREFIX_LENGTH]interface [INTERFACE_NAME]
ipv4 address [IP_ADDRESS] [SUBNET_MASK]| Field | Value |
|---|---|
| [INTERFACE_NAME] | Specify the target interface name (e.g. GigabitEthernet0/0/0/0) |
| [IP_ADDRESS] | The IPv4 address to configure |
| [PREFIX_LENGTH] | The prefix length in CIDR notation (e.g. /24) |
| [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 XR Interface Configuration (shutdown/no shutdown) and Verification.
show running-config always normalizes and stores it in subnet-mask notation (ipv4 address <address> <mask>). To confirm that you entered it in prefix-length notation, check the Internet address field in show interfaces instead — that field displays it in prefix-length notation.Verification on Real Hardware
We set up a test environment with three routers (XR1-XR3, Cisco IOS XRd) connected to the same segment via a switch (SW), and configured a different IPv4 address on each.
Example: Prefix-Length Notation (XR1)
On XR1’s GigabitEthernet0/0/0/0, we configure 192.168.0.1/24 using prefix-length notation.
interface GigabitEthernet0/0/0/0
ipv4 address 192.168.0.1/24RP/0/RP0/CPU0:XR1#configure
RP/0/RP0/CPU0:XR1(config)#interface GigabitEthernet0/0/0/0
RP/0/RP0/CPU0:XR1(config-if)#ipv4 address 192.168.0.1/24
RP/0/RP0/CPU0:XR1(config-if)#commit
Sun Aug 16 09:18:11.298 UTC
RP/0/RP0/CPU0:XR1(config-if)#end
RP/0/RP0/CPU0:XR1#Example: Subnet-Mask Notation (XR2)
On XR2’s GigabitEthernet0/0/0/0, we configure 192.168.0.2 255.255.255.0 using subnet-mask notation.
interface GigabitEthernet0/0/0/0
ipv4 address 192.168.0.2 255.255.255.0RP/0/RP0/CPU0:XR2#configure
RP/0/RP0/CPU0:XR2(config)#interface GigabitEthernet0/0/0/0
RP/0/RP0/CPU0:XR2(config-if)#ipv4 address 192.168.0.2 255.255.255.0
RP/0/RP0/CPU0:XR2(config-if)#commit
Sun Aug 16 09:18:42.598 UTC
RP/0/RP0/CPU0:XR2(config-if)#end
RP/0/RP0/CPU0:XR2#XR3 is configured the same way, using prefix-length notation for 192.168.0.3/24.
How It Appears in show running-config
Regardless of which notation was used to enter it, show running-config displays it in the same subnet-mask notation.
RP/0/RP0/CPU0:XR1#show running-config interface GigabitEthernet0/0/0/0
interface GigabitEthernet0/0/0/0
description to Ethernet0/0.SW
ipv4 address 192.168.0.1 255.255.255.0
!
RP/0/RP0/CPU0:XR1#RP/0/RP0/CPU0:XR2#show running-config interface GigabitEthernet0/0/0/0
interface GigabitEthernet0/0/0/0
description to Ethernet0/1.SW
ipv4 address 192.168.0.2 255.255.255.0
!
RP/0/RP0/CPU0:XR2#RP/0/RP0/CPU0:XR3#show running-config interface GigabitEthernet0/0/0/0
interface GigabitEthernet0/0/0/0
description to Ethernet0/2.SW
ipv4 address 192.168.0.3 255.255.255.0
!
RP/0/RP0/CPU0:XR3#XR1 was entered as ipv4 address 192.168.0.1/24 (prefix-length notation) and XR2 as ipv4 address 192.168.0.2 255.255.255.0 (subnet-mask notation), but show running-config shows both normalized to the same notation.
Checking with show interfaces / show ipv4 interface brief
The Internet address field in show interfaces displays it in prefix-length notation — the opposite of show running-config.
RP/0/RP0/CPU0:XR1#show interfaces GigabitEthernet0/0/0/0
GigabitEthernet0/0/0/0 is up, line protocol is up
Interface state transitions: 1
Hardware is GigabitEthernet, address is 5254.008d.e711 (bia 5254.008d.e711)
Description: to Ethernet0/0.SW
Internet address is 192.168.0.1/24
MTU 1514 bytes, BW 1000000 Kbit (Max: 1000000 Kbit)
-- snip --
RP/0/RP0/CPU0:XR1#To check the IPv4 addresses of all interfaces at a glance, show ipv4 interface brief is convenient.
RP/0/RP0/CPU0:XR1#show ipv4 interface brief
Interface IP-Address Status Protocol Vrf-Name
Loopback0 unassigned Shutdown Down default
MgmtEth0/RP0/CPU0/0 unassigned Shutdown Down default
GigabitEthernet0/0/0/0 192.168.0.1 Up Up default
GigabitEthernet0/0/0/1 unassigned Shutdown Down default
GigabitEthernet0/0/0/2 unassigned Shutdown Down default
RP/0/RP0/CPU0:XR1#Connectivity Check
We ran ping from XR1 to XR2 and XR3 to verify reachability within the same segment.
RP/0/RP0/CPU0:XR1#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 = 6/15/51 ms
RP/0/RP0/CPU0:XR1#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 = 6/10/26 ms
RP/0/RP0/CPU0:XR1#Both pings succeeded at a 100% success rate, confirming that XR1, XR2, and XR3 can reach each other correctly within the same segment.
Verification Configs
Download XR1 config (r1_ipv4-address.cfg)
Download XR2 config (r2_ipv4-address.cfg)
Download XR3 config (r3_ipv4-address.cfg)
Test Environment and show Output
Download XR1 show output (r1_ipv4-address_show.txt)
Download XR2 show output (r2_ipv4-address_show.txt)
Download XR3 show output (r3_ipv4-address_show.txt)