BGP Address Family, AFI/SAFI, NLRI Explained
Contents
What is BGP address Family
Multi-Protocol BGP (MP-BGP) is an extension of BGP-4.
MP-BGP is an extension to Border Gateway Protocol (BGP) that allows different types of addresses (known as address families) to be distributed in parallel. Whereas standard BGP (BGP-4) supports only IPv4 unicast addresses, Multiprotocol BGP supports IPv4 and IPv6 addresses and it supports unicast and multicast variants of each.
A BGP router that supports MP-BGP indicates the types of routes it wants to exchange with a peer by including the corresponding AFI (Address Family Identifier) and SAFI (Subsequent Address Family Identifier) values in the MP-BGP capability of its OPEN message.
We can see in the BGP OPEN message, optional parameters fields which include MP-BGP capability followed by AFI and SAFI:
–> A combination of AFI/SAFI represent an address family in MP-BGP.
Address family identifier (AFI): IPv4 (1)
Subsequent address family identifier (SAFI): Unicast (1)
The two peers forming a session do not need to indicate support for the same address families. As long as there is one combination AFI/SAFI in common the session establishes and routes associated with all the common AFI/SAFI can be exchanged between the peers.
Address Family Identifier (AFI):
This field in combination with the Subsequent Address FamilyIdentifier (SAFI) field identifies the set of Network Layer protocols to which the address carried in the Next Hop field must belong, the way in which the address of the next hop is encoded, and the semantics of the Network Layer Reachability Information that follows.
BGP NLRI (Network Layer Reachability Information)
As per RFC4760, MP_REACH_NLRI is used to carry the set of reachable destinations together with the next hop information to be used for forwarding to these destinations.
This is an optional non-transitive attribute that can be used for the following purposes:
- To advertise a feasible route to a peer
- To permit a router to advertise the Network Layer address of the router that should be used as the next hop to the destinations listed in the Network Layer Reachability Information field of the MP_NLRI attribute.
The attribute is encoded as shown below:
+---------------------------------------------------------+
| Address Family Identifier (2 octets) |
+---------------------------------------------------------+
| Subsequent Address Family Identifier (1 octet) |
+---------------------------------------------------------+
| Length of Next Hop Network Address (1 octet) |
+---------------------------------------------------------+
| Network Address of Next Hop (variable) |
+---------------------------------------------------------+
| Reserved (1 octet) |
+---------------------------------------------------------+
| Network Layer Reachability Information (variable) |
+---------------------------------------------------------+
Advertise and Withdraw of NLRI using 2 different Attributes in the BGP UPDATE message:
- To advertise reachable routes of a particular AFI/SAFI a BGP router includes a single MP_REACH_NLRI attribute in the UPDATE message. The MP_REACH_NLRI attribute encodes the AFI, the SAFI, the BGP next-hop and all the reachable NLRI.
- To withdraw routes of a particular AFI/SAFI a BGP router includes a single MP_UNREACH_NLRI attribute in the UPDATE message. The MP_UNREACH_NLRI attribute encodes the AFI, the SAFI and all the withdrawn NLRI.
Example of address family: L2VPN EVPN
The EVPN NLRI is carried in BGP [RFC4271] using BGP Multiprotocol Extensions [RFC4760] with an Address Family Identifier (AFI) of 25 (L2VPN) and a Subsequent Address Family Identifier (SAFI) of 70
(EVPN).
In order for two BGP speakers to exchange labeled EVPN NLRI, they must use BGP Capabilities Advertisements to ensure that they both are capable of properly processing such NLRI.
MAC/IP Advertisement Route
A MAC/IP Advertisement route type specific EVPN NLRI consists of the following:
+---------------------------------------+
| RD (8 octets) |
+---------------------------------------+
|Ethernet Segment Identifier (10 octets)|
+---------------------------------------+
| Ethernet Tag ID (4 octets) |
+---------------------------------------+
| MAC Address Length (1 octet) |
+---------------------------------------+
| MAC Address (6 octets) |
+---------------------------------------+
| IP Address Length (1 octet) |
+---------------------------------------+
| IP Address (0, 4, or 16 octets) |
+---------------------------------------+
| MPLS Label1 (3 octets) |
+---------------------------------------+
| MPLS Label2 (0 or 3 octets) |
+---------------------------------------+
Example of use case from lab for VXLAN EVPN:
More in the following article:
Reference:
RFC documents (https://datatracker.ietf.org/doc/html/rfc4760)
https://infocenter.nokia.com
https://www.youtube.com/watch?v=TDzMiHX5MsQ