What an RD Is in MPLS VPN
An RD (Route Distinguisher) is an 8-byte value prepended to an IPv4 prefix to make it unique. Section 4.1 of RFC 4364 defines a VPN-IPv4 address as an 8-byte RD followed by a 4-byte IPv4 address, 12 bytes in total.
An RD is needed because overlapping customer addresses still have to be distinct prefixes inside BGP. Customer A’s 10.1.1.0/24 and customer B’s 10.1.1.0/24 are the same prefix as far as BGP is concerned, and only one of them would survive. With RDs they become 65001:1:10.1.1.0/24 and 65001:2:10.1.1.0/24, and both can exist.
An RD does not identify a VPN. Section 4.1 of RFC 4364 puts it this way:
An RD is simply a number, and it does not contain any inherent information; it does not identify the origin of the route or the set of VPNs to which the route is to be distributed. The purpose of the RD is solely to allow one to create distinct routes to a common IPv4 address prefix.
What decides which VRF a route goes to is the RT (Route Target), and the lab below demonstrates the difference. The RT itself is covered in MPLS VPN RT.
The RD Types (0, 1, and 2)
An RD is a 2-byte Type followed by a 6-byte Value, and the type decides how those six bytes are split (RFC 4364, section 4.2).
| Type | Value layout | Example | Where it fits |
|---|---|---|---|
| 0 | 2-byte AS number + 4-byte number | 65001:1 | Providers with a two-octet AS number. The most common |
| 1 | 4-byte IP address + 2-byte number | 1.1.1.1:2 | When a router’s address is used to keep values distinct per device |
| 2 | 4-byte AS number + 2-byte number | 4259905537:1 | Providers with a four-octet AS number |
The type makes no functional difference. All that matters is that the value is unique; its contents carry no meaning. Section 4.2 explains that this structure lets every service provider administer its own numbering space without colliding with anyone else’s.
Configuring an RD on IOS XR
On IOS XR the RD is configured under router bgp, per VRF. It does not go under the VRF definition (vrf <name>).
router bgp 65001
vrf CUST-A
rd 65001:1
address-family ipv4 unicast
redistribute static
!
!
!There are three ways to write the value.
| Form | Meaning |
|---|---|
rd <AS number>:<number> | Type 0 (or type 2 with a four-octet AS number) |
rd <IP address>:<number> | Type 1 |
rd auto | Assigns the router ID plus a number counting up from 0 |
Because rd auto uses the router ID, the same VPN ends up with a different RD on each PE. Whether that is a good design is covered in MPLS VPN RD design.
Without an RD the routes of a VRF never reach MP-BGP. Conversely, creating a VRF on its own needs no RD at all (MPLS VPN VRF).
An RD Cannot Be Changed Later
An RD can be neither changed nor removed while the address family of that VRF is active. IOS XR rejects the attempt:
!!% 'BGP' detected the 'warning' condition 'The RD cannot be changed or removed while a VRF address family is active'Changing it therefore means removing the address family, changing the RD, and putting the address family back. And because an IOS XR commit is pseudo-atomic, that sequence cannot be done in a single commit (the final state still has an active address family, so it is rejected for the same reason). Two commits are required.
While the address family is gone, the routes of that VRF disappear from MP-BGP and traffic stops. An RD is not a value to change casually once the service is running; it belongs in the design.
Lab Setup
Eight XRd routers, with customer A and customer B using exactly the same addresses — not only the LANs but the PE-CE links too.
| Node | Role |
|---|---|
| PE1 / PE2 | Hold VRF CUST-A (RD 65001:1) and CUST-B (RD 65001:2). The RTs are 65001:100 and 65001:200 |
| P1 / P2 | Core only (OSPF area 0 + LDP). They run no BGP |
| CE-A1 / CE-B1 | Site 1. Both use LAN 10.1.1.0/24 and 172.16.1.2 towards the PE |
| CE-A2 / CE-B2 | Site 2. Both use LAN 10.1.2.0/24 and 172.16.2.2 towards the PE |
PE-CE routing is static, redistributed into the VRF’s BGP with redistribute static. The RTs never change; only the RDs move.
| STEP | Action | What it shows |
|---|---|---|
| 0 | Initial state | The same 10.1.1.0/24 under two RDs. The P routers hold no VPN routes |
| 1 | Try to change the RD of CUST-B on PE1 | It is rejected |
| 2 | Remove the address family of CUST-B | Customer B’s traffic stops |
| 3 | Set a type 1 RD (1.1.1.1:2) and restore the address family | Traffic recovers. A different RD still reaches the VRF because the RT matches |
| 4 | Remove the address family again | (preparation for rd auto) |
| 5 | Switch to rd auto | Router ID plus 0 is assigned automatically |
The Same Prefix Split by RD (STEP 0)
The BGP table on PE1 is grouped by RD.
Network Next Hop Metric LocPrf Weight Path
Route Distinguisher: 65001:1 (default for vrf CUST-A)
Route Distinguisher Version: 14
*> 10.1.1.0/24 172.16.1.2 0 32768 ?
*>i10.1.2.0/24 2.2.2.2 0 100 0 ?
Route Distinguisher: 65001:2 (default for vrf CUST-B)
Route Distinguisher Version: 15
*> 10.1.1.0/24 172.16.1.2 0 32768 ?
*>i10.1.2.0/24 2.2.2.2 0 100 0 ?
Processed 4 prefixes, 4 paths10.1.1.0/24 and 10.1.2.0/24 each appear twice, and the total is Processed 4 prefixes. To BGP these are four separate prefixes that differ only in their RD. The (default for vrf CUST-A) note says which VRF that RD belongs to.
The P routers in the core run no BGP at all.
RP/0/RP0/CPU0:P1#show bgp vpnv4 unicast
Sun Sep 20 06:27:01.056 UTC
% BGP instance 'default' not activeThe packets show the same thing. In a VPNv4 UPDATE between PE1 and P1, the RD and the label sit inside the MP_REACH_NLRI.
Path Attribute - MP_REACH_NLRI
Flags: 0x90, Optional, Extended-Length, Non-transitive, Complete
1... .... = Optional: Set
.0.. .... = Transitive: Not set
..0. .... = Partial: Not set
...1 .... = Extended-Length: Set
.... 0000 = Unused: 0x0
Type Code: MP_REACH_NLRI (14)
Length: 32
Address family identifier (AFI): IPv4 (1)
Subsequent address family identifier (SAFI): Labeled VPN Unicast (128)
Next hop: RD=0:0 IPv4=2.2.2.2
Route Distinguisher: 0:0
IPv4 Address: 2.2.2.2
Number of Subnetwork points of attachment (SNPA): 0
Network Layer Reachability Information (NLRI)
BGP Prefix
Prefix Length: 112
Label Stack: 24005 (bottom)
Route Distinguisher: 65001:1
MP Reach NLRI IPv4 prefix: 10.1.2.0An RD is part of the NLRI, not a path attribute. It travels as part of the prefix itself rather than as information attached to the route.
Rejected, and Not Changeable Without an Outage (STEP 1 and 2)
In STEP 1, changing the RD of CUST-B on PE1 to 1.1.1.1:2 fails to commit.
RP/0/RP0/CPU0:PE1(config)#show configuration failed
Sun Sep 20 06:31:37.073 UTC
!! SEMANTIC ERRORS: This configuration was rejected by
!! the system due to semantic errors. The individual
!! errors with each failed configuration command can be
!! found below.
router bgp 65001
vrf CUST-B
rd 1.1.1.1:2
!!% 'BGP' detected the 'warning' condition 'The RD cannot be changed or removed while a VRF address family is active'
!
!
endIn STEP 2 the address family is removed, and customer B’s traffic stops.
RP/0/RP0/CPU0:CE-B1#ping 10.1.2.1 source 10.1.1.1 count 50 timeout 1
Sun Sep 20 09:06:57.309 UTC
Type escape sequence to abort.
Sending 50, 100-byte ICMP Echos to 10.1.2.1 timeout is 1 seconds:
..................................................
Success rate is 0 percent (0/50)Customer A is unaffected. Only the VRF that was touched goes down.
A Different RD Still Works if the RT Matches (STEP 3)
STEP 3 sets the type 1 RD 1.1.1.1:2 and restores the address family. Only CUST-B on PE1 was changed; CUST-B on PE2 still uses 65001:2.
Network Next Hop Metric LocPrf Weight Path
Route Distinguisher: 65001:1 (default for vrf CUST-A)
Route Distinguisher Version: 14
*> 10.1.1.0/24 172.16.1.2 0 32768 ?
*>i10.1.2.0/24 2.2.2.2 0 100 0 ?
Route Distinguisher: 65001:2
Route Distinguisher Version: 18
*>i10.1.2.0/24 2.2.2.2 0 100 0 ?
Route Distinguisher: 1.1.1.1:2 (default for vrf CUST-B)
Route Distinguisher Version: 20
*> 10.1.1.0/24 172.16.1.2 0 32768 ?
*>i10.1.2.0/24 2.2.2.2 0 100 0 ?
Processed 5 prefixes, 5 pathsThe routes PE1 advertises carry the new RD (1.1.1.1:2) and the routes it receives from PE2 carry the original one (65001:2); both sit in the same table under different RDs. Customer B’s traffic recovers all the same.
That is because a route is imported when the RT matches, whatever the RD is. Distribution is decided by the RT, not by the RD — exactly what the text from RFC 4364 quoted above says, now visible on a live device.
The RD in the packets changes to the type 1 form as well.
Path Attribute - MP_REACH_NLRI
Flags: 0x90, Optional, Extended-Length, Non-transitive, Complete
1... .... = Optional: Set
.0.. .... = Transitive: Not set
..0. .... = Partial: Not set
...1 .... = Extended-Length: Set
.... 0000 = Unused: 0x0
Type Code: MP_REACH_NLRI (14)
Length: 32
Address family identifier (AFI): IPv4 (1)
Subsequent address family identifier (SAFI): Labeled VPN Unicast (128)
Next hop: RD=0:0 IPv4=1.1.1.1
Route Distinguisher: 0:0
IPv4 Address: 1.1.1.1
Number of Subnetwork points of attachment (SNPA): 0
Network Layer Reachability Information (NLRI)
BGP Prefix
Prefix Length: 112
Label Stack: 24006 (bottom)
Route Distinguisher: 1.1.1.1:2
MP Reach NLRI IPv4 prefix: 10.1.1.0rd auto Counts From Router ID Plus 0 (STEP 5)
STEP 4 removes the address family once more, and STEP 5 switches to rd auto.
Network Next Hop Metric LocPrf Weight Path
Route Distinguisher: 65001:1 (default for vrf CUST-A)
Route Distinguisher Version: 14
*> 10.1.1.0/24 172.16.1.2 0 32768 ?
*>i10.1.2.0/24 2.2.2.2 0 100 0 ?
Route Distinguisher: 65001:2
Route Distinguisher Version: 18
*>i10.1.2.0/24 2.2.2.2 0 100 0 ?
Route Distinguisher: 1.1.1.1:0 (default for vrf CUST-B)
Route Distinguisher Version: 25
*> 10.1.1.0/24 172.16.1.2 0 32768 ?
*>i10.1.2.0/24 2.2.2.2 0 100 0 ?
Processed 5 prefixes, 5 pathsPE1’s router ID is 1.1.1.1 and the numbering starts at 0. Because auto uses the router ID, the same VPN gets a different RD on every PE.
Path Attribute - MP_REACH_NLRI
Flags: 0x90, Optional, Extended-Length, Non-transitive, Complete
1... .... = Optional: Set
.0.. .... = Transitive: Not set
..0. .... = Partial: Not set
...1 .... = Extended-Length: Set
.... 0000 = Unused: 0x0
Type Code: MP_REACH_NLRI (14)
Length: 32
Address family identifier (AFI): IPv4 (1)
Subsequent address family identifier (SAFI): Labeled VPN Unicast (128)
Next hop: RD=0:0 IPv4=1.1.1.1
Route Distinguisher: 0:0
IPv4 Address: 1.1.1.1
Number of Subnetwork points of attachment (SNPA): 0
Network Layer Reachability Information (NLRI)
BGP Prefix
Prefix Length: 112
Label Stack: 24006 (bottom)
Route Distinguisher: 1.1.1.1:0
MP Reach NLRI IPv4 prefix: 10.1.1.0Whether to keep one RD per VRF or to use a different one per PE is a design choice. Splitting them lets a route reflector keep more than one path, at the cost of more routes to hold. That trade-off is covered in MPLS VPN RD design.
Verification Config and show Output
For every STEP, the following files were collected from all eight routers, split per router. The verification config is the ..._run.txt file (the final state is the one from the last STEP).
| File | Content |
|---|---|
..._show.txt | show version, show interface description, show route, plus VPNv4 and VRF commands on the PEs, core commands on the P routers, and routing tables on the CEs |
..._ping.txt | The ping and traceroute results for that STEP |
..._log.txt | show logging limited to that STEP |
..._run.txt | show running-config at that STEP (that is, the verification config) |
..._commit.cfg | The configuration committed in that STEP (only for routers that were changed) |
..._failed.cfg | The rejected configuration and its error (STEP 1 only) |
STEP 0: initial state (CUST-A uses rd 65001:1, CUST-B uses rd 65001:2)
| Router | show | ping | syslog | running-config |
|---|---|---|---|---|
| PE1 | show | ping | log | run |
| PE2 | show | ping | log | run |
| P1 | show | ping | log | run |
| P2 | show | ping | log | run |
| CE-A1 | show | ping | log | run |
| CE-A2 | show | ping | log | run |
| CE-B1 | show | ping | log | run |
| CE-B2 | show | ping | log | run |
STEP 1: the RD change is rejected
| Router | show | ping | syslog | running-config | rejected |
|---|---|---|---|---|---|
| PE1 | show | ping | log | run | failed |
| PE2 | show | ping | log | run | — |
| P1 | show | ping | log | run | — |
| P2 | show | ping | log | run | — |
| CE-A1 | show | ping | log | run | — |
| CE-A2 | show | ping | log | run | — |
| CE-B1 | show | ping | log | run | — |
| CE-B2 | show | ping | log | run | — |
STEP 2: remove the address family of CUST-B (customer B’s traffic stops)
| Router | show | ping | syslog | running-config | committed |
|---|---|---|---|---|---|
| PE1 | show | ping | log | run | commit |
| PE2 | show | ping | log | run | — |
| P1 | show | ping | log | run | — |
| P2 | show | ping | log | run | — |
| CE-A1 | show | ping | log | run | — |
| CE-A2 | show | ping | log | run | — |
| CE-B1 | show | ping | log | run | — |
| CE-B2 | show | ping | log | run | — |
STEP 3: set a type 1 RD and restore the address family
| Router | show | ping | syslog | running-config | committed |
|---|---|---|---|---|---|
| PE1 | show | ping | log | run | commit |
| PE2 | show | ping | log | run | — |
| P1 | show | ping | log | run | — |
| P2 | show | ping | log | run | — |
| CE-A1 | show | ping | log | run | — |
| CE-A2 | show | ping | log | run | — |
| CE-B1 | show | ping | log | run | — |
| CE-B2 | show | ping | log | run | — |
STEP 4: remove the address family again
| Router | show | ping | syslog | running-config | committed |
|---|---|---|---|---|---|
| PE1 | show | ping | log | run | commit |
| PE2 | show | ping | log | run | — |
| P1 | show | ping | log | run | — |
| P2 | show | ping | log | run | — |
| CE-A1 | show | ping | log | run | — |
| CE-A2 | show | ping | log | run | — |
| CE-B1 | show | ping | log | run | — |
| CE-B2 | show | ping | log | run | — |
STEP 5: switch to rd auto (final state)
| Router | show | ping | syslog | running-config | committed |
|---|---|---|---|---|---|
| PE1 | show | ping | log | run | commit |
| PE2 | show | ping | log | run | — |
| P1 | show | ping | log | run | — |
| P2 | show | ping | log | run | — |
| CE-A1 | show | ping | log | run | — |
| CE-A2 | show | ping | log | run | — |
| CE-B1 | show | ping | log | run | — |
| CE-B2 | show | ping | log | run | — |
The packet capture was taken on the PE1-P1 link across all the STEPs.
Download the full capture from the PE1-P1 linkReferences
| RFC | Title | Summary |
|---|---|---|
| RFC 4364 | BGP/MPLS IP Virtual Private Networks (VPNs) | VPN-IPv4 addresses and the RD (4.1), RD types 0, 1 and 2 (4.2), and the RT deciding distribution (4.3.1) |
| RFC 4760 | Multiprotocol Extensions for BGP-4 | The MP_REACH_NLRI that carries VPNv4 prefixes |
Books: Luc De Ghein, MPLS Fundamentals (Cisco Press, 2006), Chapter 7; Mobeen Tahir et al., Cisco IOS XR Fundamentals (Cisco Press, 2009), Chapter 9
Test environment: Cisco IOS XRd 26.1.1 (Cisco Modeling Labs)