IOS, IOS XE and IOS XR: How Each Cisco Platform Picks the BGP Router-ID

One Field, Two Rule Sets

The BGP Router-ID is defined once by the protocol. It is a 32-bit BGP Identifier, written like an IPv4 address, sent in the OPEN message and unique inside the autonomous system. What the protocol does not define is how a router should choose that value when the engineer does not configure it. Each operating system decides that for itself, and Cisco's two main routing platforms decide it differently.

That difference matters more than it seems. A service provider core often mixes IOS XE on smaller PEs with IOS XR on reflectors and large edge routers, and the CCIE Service Provider lab mixes them on purpose. An engineer who assumes XR behaves like IOS will predict the wrong Router-ID, and through it the wrong ORIGINATOR_ID and the wrong best path.

Start with the platform most engineers learn first. Classic IOS and IOS XE use the same rules. The configured value from "#bgp router-id" wins. Without it, the router takes the highest IPv4 address on an up loopback interface. Without any usable loopback, it takes the highest IPv4 address on an up physical interface.

R1(config)#interface Loopback0
R1(config-if)#ip address 10.0.0.1 255.255.255.255
R1(config-if)#interface Loopback1
R1(config-if)#ip address 10.0.0.99 255.255.255.255
R1(config-if)#interface GigabitEthernet1
R1(config-if)#ip address 192.168.100.1 255.255.255.0
R1(config-if)#router bgp 65000
R1(config-router)#neighbor 10.0.0.14 remote-as 65000
R1(config-router)#neighbor 10.0.0.14 update-source Loopback0
R1#show ip bgp summary
BGP router identifier 10.0.0.99, local AS number 65000
BGP table version is 1, main routing table version 1

Neighbor        V           AS MsgRcvd MsgSent   TblVer  InQ OutQ Up/Down  State/PfxRcd
10.0.0.14       4        65000       6       5        1    0    0 00:02:40        0

The physical address 192.168.100.1 is numerically higher, but loopbacks are always preferred, so the highest loopback, 10.0.0.99, wins.

IOS XE adds two features that matter in provider networks. The first is per-VRF Router-IDs, set with "#bgp router-id vrf auto-assign" globally or with "#bgp router-id" inside a VRF address family. The second is a clear error when no IPv4 address exists at all, which is common on IPv6-only routers.

R6(config)#router bgp 65006
%BGP-3-NORTRID: BGP could not pick a router-id. Please configure manually.

IOS XR follows a different set of rules, and the first surprise is that it never uses a physical interface for the BGP Router-ID. Its order is this. The configured value from "#bgp router-id" under "#router bgp" wins. Without it, if the router booted with loopbacks already present in the saved configuration, it takes the highest IPv4 address among those loopbacks. Without that, it takes the primary IPv4 address of the first loopback that was configured. If there is no loopback and no configured value, there is nothing to choose from, and BGP cannot fall back to an interface address.

XR also keeps its Router-ID. Once chosen, the value stays even if a better candidate appears later, and it is only chosen again when the current one becomes invalid. Cisco documents this explicitly for XR.

A short lab shows both rules. XR1 boots with no loopbacks. The engineer configures Loopback0 first, then BGP, and later adds Loopback1 with a higher address.

RP/0/RP0/CPU0:XR1(config)#interface Loopback0
RP/0/RP0/CPU0:XR1(config-if)#ipv4 address 10.0.0.21 255.255.255.255
RP/0/RP0/CPU0:XR1(config-if)#router bgp 65000
RP/0/RP0/CPU0:XR1(config-bgp)#address-family ipv4 unicast
RP/0/RP0/CPU0:XR1(config-bgp-af)#exit
RP/0/RP0/CPU0:XR1(config-bgp)#neighbor 10.0.0.14
RP/0/RP0/CPU0:XR1(config-bgp-nbr)#remote-as 65000
RP/0/RP0/CPU0:XR1(config-bgp-nbr)#update-source Loopback0
RP/0/RP0/CPU0:XR1(config-bgp-nbr)#address-family ipv4 unicast
RP/0/RP0/CPU0:XR1(config-bgp-nbr-af)#commit
RP/0/RP0/CPU0:XR1(config-bgp-nbr-af)#interface Loopback1
RP/0/RP0/CPU0:XR1(config-if)#ipv4 address 10.0.0.99 255.255.255.255
RP/0/RP0/CPU0:XR1(config-if)#commit
RP/0/RP0/CPU0:XR1#show bgp summary | include identifier
Wed Nov 11 14:02:18.441 UTC
BGP router identifier 10.0.0.21, local AS number 65000

The first configured loopback was chosen, and adding a higher loopback did not change it. Now reload. This time the router boots with both loopbacks already in the saved configuration, so the highest one wins.

RP/0/RP0/CPU0:XR1#show bgp summary
Wed Nov 11 14:21:05.902 UTC
BGP router identifier 10.0.0.99, local AS number 65000
BGP generic scan interval 60 secs
Non-stop routing is enabled
BGP table state: Active
Table ID: 0xe0000000   RD version: 4
BGP main routing table version 4
BGP NSR Initial initsync version 2 (Reached)
BGP NSR/ISSU Sync-Group versions 0/0
BGP scan interval 60 secs

BGP is operating in STANDALONE mode.


Process       RcvTblVer   bRIB/RIB   LabelVer  ImportVer  SendTblVer  StandbyVer
Speaker               4          4          4          4           4           0

Neighbor        Spk    AS MsgRcvd MsgSent   TblVer  InQ OutQ  Up/Down  St/PfxRcd
10.0.0.14         0 65000       8       6        4    0    0 00:03:12          0

The same configuration produced two different Router-IDs, depending only on whether the loopbacks existed before or after the router booted. That is the most surprising XR behaviour for engineers coming from IOS.

Comparing the Platforms

Because the XR rules are so unlike the IOS ones, it is easy to mix them up, and even published material does. A widely used BGP troubleshooting book says IOS XR picks the lowest up loopback address. It gets the IOS rule right and then reverses the comparison for XR. The lab above shows the real behaviour: after a boot with saved loopbacks, XR picks the highest. It is a good reminder that platform-specific details in printed books go stale or are simply wrong, and that the Cisco configuration guide for your release and your own lab output have the final word.

The same caution is why NX-OS is left out of this post. I have not found a current Cisco document that clearly states its selection direction, and a guess dressed up as a rule is worse than no rule.

With both rule sets laid out, the differences are easiest to see in one table.

Topic IOS and IOS XE IOS XR
Configured value "#bgp router-id" under the BGP process "#bgp router-id" under "#router bgp"
First automatic choice Highest up loopback IPv4 address Highest loopback IPv4 address, if loopbacks were in the saved config at boot
Second automatic choice Highest up physical IPv4 address Primary IPv4 address of the first configured loopback
Physical interfaces Used when no loopback exists Never used
Keeps the value when a better candidate appears Not documented by Cisco Yes, documented
Per-VRF Router-ID "#bgp router-id vrf auto-assign" or per address family "#bgp router-id" under the VRF in BGP
Changing the value Resets all BGP sessions Resets all BGP sessions

Read down the last row and the table also shows what the two platforms have in common. On both, a new Router-ID means every BGP session restarts. That shared cost is the reason the differences above rarely need to matter in practice.

Setting It Explicitly in Mixed Networks

All of these differences disappear the moment you configure the value by hand, which is why every serious design does. Match it to Loopback0 on both platforms.

R1(config)#router bgp 65000
R1(config-router)#bgp router-id 10.0.0.1
RP/0/RP0/CPU0:XR1(config)#router bgp 65000
RP/0/RP0/CPU0:XR1(config-bgp)#bgp router-id 10.0.0.21
RP/0/RP0/CPU0:XR1(config-bgp)#commit
RP/0/RP0/CPU0:XR1#show bgp summary | include identifier
Wed Nov 11 14:35:47.120 UTC
BGP router identifier 10.0.0.21, local AS number 65000

On XR the change only takes effect at "#commit", so it is easy to stage in a candidate configuration and apply inside the maintenance window. On both platforms the change resets every BGP session.

Setting the value matters even more in a mixed provider network than on a single platform. There, the Router-ID of an XR reflector becomes its cluster ID by default, and the Router-ID of every PE becomes the ORIGINATOR_ID its routes carry through the AS. Those values appear in loop prevention and in the final best path steps on every router in the network. If an XR edge router changes its identifier after a reload because someone added a loopback, routes elsewhere can change their best path, and loop checks can start dropping routes if the new value collides with another router's.

For the exam, learn both rule sets, because a task that asks you to predict a Router-ID is really asking whether you know which platform you are on. For production, configure the value explicitly on every router of every platform, and the rule sets become trivia.