Skip to main content
Version: 7.26

Route Distinguisher and Route Target

BGP VPN services use two values to keep the routes of different customers apart:

  • The route distinguisher (RD) makes a customer prefix unique in BGP, so that customers can use the same address ranges.
  • The route target (RT) decides which VRF or VPN instance imports a route.

RouterOS uses them in L3VPN (/routing/bgp/vpn), EVPN (/routing/bgp/evpn) and BGP VPLS (/routing/bgp/vpls):

MenuRoute distinguisherRoute targets
/routing/bgp/vpnroute-distinguisherimport.route-targets, export.route-targets
/routing/bgp/evpnrdimport.route-targets, export.route-targets
/routing/bgp/vplsrdimport-route-targets, export-route-targets

Route distinguisher​

A route distinguisher is a 64-bit (8-byte) value that is added in front of a customer prefix. The result is a VPN route, for example a VPNv4 route. Two customers that use the same subnet export two different VPN routes when their VRFs have different route distinguishers. RouterOS shows a VPN route as <prefix>&, for example 192.168.10.0/24&65000:1.

The route distinguisher only makes routes unique. It does not decide which VRF imports a route: route targets do. When two VRFs on one PE export the same prefix with the same route distinguisher, they produce the same VPN route, and BGP peers receive only one of them: the prefix of the other VRF is lost. Use a separate route distinguisher for each VRF on a PE.

An RD consists of three parts (RFC 4364):

  • Type (2 bytes).
  • Administrator subfield: an AS number or an IPv4 address.
  • Assigned number subfield: a value chosen by the administrator.

Three RD types are defined:

TypeAdministratorAssigned numberWritten in RouterOSExamples
02-byte AS number4-byte number<AS>:<number>, AS 0-6553565000:1, 65000:70000
1IPv4 address2-byte number<IPv4 address>:<number>192.0.2.1:5
24-byte AS number2-byte number<AS>:<number>, AS above 65535, or <AS>L:<number>4200000001:1, 65000L:1

RouterOS chooses the type from the administrator subfield:

  • An AS number up to 65535 gives a type 0 RD. 65000:1 is type 0, and its assigned number has 4 bytes, so 65000:70000 is valid.
  • An AS number above 65535 gives a type 2 RD. 70000:1 is type 2, and its assigned number has 2 bytes (0-65535), so 70000:65536 is not a valid RD.
  • To use a type 2 RD with an AS number up to 65535, add L to the AS number: 65000L:1. RouterOS shows a received type 2 RD with such an AS number in the same form. 65000:1 and 65000L:1 are two different route distinguishers.
  • An IPv4 address gives a type 1 RD, with a 2-byte assigned number.

Route targets​

A route target is a BGP extended community that controls the import and export of routing information between routing instances. A VRF or VPN instance adds its export route targets to the routes it exports. It imports the routes whose route target is in its import list, whatever their route distinguisher. An EVPN entry without route targets sets them automatically, see EVPN.

Route targets are written like route distinguishers, and the same rules decide the extended community type (RFC 4360, RFC 5668). The route target sub-type is 0x02 in all three:

Written in RouterOSExtended communityExamples
<AS>:<number>, AS 0-655352-octet AS-specific, 4-byte number65000:100, 65000:70000
<IPv4 address>:<number>IPv4-address-specific, 2-byte number192.0.2.1:100
<AS>:<number>, AS above 65535, or <AS>L:<number>4-octet AS-specific, 2-byte number4200000001:100, 65000L:100

An invalid route target, for example 70000:65536, is refused with the error invalid prefix route distinguisher value.

The routing table shows the route targets of a route in bgp.ext-communities with the rt: prefix, for example rt:65000:100. RouterOS keeps received VPN routes (afi=vpnv4) also when no VRF on the router imports their route targets.

Example: two customers with the same subnet​

PE1 connects two customers that both use 192.168.10.0/24: customer A on ether5 and customer B on ether6. Each customer gets a VRF with its own route distinguisher and route target. PE1 already has the BGP instance bgp1 (AS 65000) and a VPNv4 session with PE2. See VRF for a complete L3VPN configuration, including MPLS.

On PE1, add the VRF of customer A:

/ip/vrf
add name=cust-a interfaces=ether5
/ip/address
add address=192.168.10.1/24 interface=ether5
/routing/bgp/vpn
add name=cust-a instance=bgp1 vrf=cust-a \
route-distinguisher=65000:1 label-allocation-policy=per-vrf \
export.redistribute=connected export.route-targets=65000:100 \
import.route-targets=65000:100

Then add the VRF of customer B, with the same subnet:

/ip/vrf
add name=cust-b interfaces=ether6
/ip/address
add address=192.168.10.1/24 interface=ether6
/routing/bgp/vpn
add name=cust-b instance=bgp1 vrf=cust-b \
route-distinguisher=65000:2 label-allocation-policy=per-vrf \
export.redistribute=connected export.route-targets=65000:200 \
import.route-targets=65000:200

PE2 receives two VPNv4 routes for the same subnet, one for each route distinguisher:

[admin@MikroTik] > /routing/route/print where afi=vpnv4
Flags: A - ACTIVE; b - BGP
Columns: DST-ADDRESS, GATEWAY, AFI, ROUTING-TABLE, DISTANCE, SCOPE,
TARGET-SCOPE, IMMEDIATE-GW
DST-ADDRESS GATEWAY AFI ROUT DIS SC TA IMMEDIATE-GW
Ab 192.168.10.0/24&65000:1 10.0.0.1 vpnv4 main 200 40 30 10.0.0.1%ether2
Ab 192.168.10.0/24&65000:2 10.0.0.1 vpnv4 main 200 40 30 10.0.0.1%ether2

The detail view shows the route target of each route in .ext-communities:

[admin@MikroTik] > /routing/route/print detail where afi=vpnv4
Flags: A - ACTIVE; b - BGP
Ab afi=vpnv4 contribution=active dst-address=192.168.10.0/24&65000:1
routing-table=main label=16 gateway=10.0.0.1 immediate-gw=10.0.0.1%ether2
distance=200 scope=40 target-scope=30 belongs-to="bgp-VPNv4-10.0.0.1"
bgp.session=to-pe1-1 .ext-communities=rt:65000:100 .local-pref=100
.origin=incomplete debug.fwp-ptr=0x20282300

Ab afi=vpnv4 contribution=active dst-address=192.168.10.0/24&65000:2
routing-table=main label=17 gateway=10.0.0.1 immediate-gw=10.0.0.1%ether2
distance=200 scope=40 target-scope=30 belongs-to="bgp-VPNv4-10.0.0.1"
bgp.session=to-pe1-1 .ext-communities=rt:65000:200 .local-pref=100
.origin=incomplete debug.fwp-ptr=0x20282300

If both VRFs on PE1 used the route distinguisher 65000:1, they would export the same VPN route, and PE2 would receive only one route for 192.168.10.0/24.

For a customer network connected to more than one PE, see Route distinguisher per site or per customer on the VRF page.