Basic BGP Information

BGP, Border Gateway Protocol, is the routing protocol that connects the internet, and it is versatile enough to be used from small to large environments. This will be a small reference for BGP basic knowledge.

Basics of BGP
Confederations
Route Reflectors
Neighbour Formations
Path Selection
BGP Synchronisation
BGP Summarisation
eBGP Multihop
iBGP & eBGP Next Hop Handling
Peer Groups

Basics of BGP

BGP Is an exterior gateway protocol (EGP). BGP uses on autonomous system numbers to determine one organisation from another. There are both public and private AS numbers.
There are two flavours of BGP, eBGP and iBGP. eBGP is external between different AS numbers, and iBGP is BGP inside the same AS.

BGP Characteristics

– Forms neighbour relationships to a statically configured IP address
– TCP Session established between neighbours on TCP 179
– Advertises address prefix and length, NLRI (Network layer and reachability information). Extra parameters can be added, more than IGPs can
– Advertises a collection of path attributes for path selection (the best route)
Path vector routing protocol. BGP, gives the entire path of each AS to the destination (AS Path)

iBGP Full Mesh

iBGP requires all routers to be connected in a full mesh topology and therefore all routers are neighbours with each other. This is fine for small deployments, however can quickly end up becoming a problem. The formula to understand how many neighbour relationships are needed is a number of routers.

n * (n – 1) /2

n representing the number of routers. The number output is the number of neighbour relationships that are needed for the full mesh.
With 5 routers there are 10 neighbour relationships needed, with 10 routers, there are 45 neighbour relationships.

Confederations

BGP Confederations break up the large full mesh required by iBGP by splitting the single large AS into subautonomous systems (sub-AS). Each sub-AS has a unique sub-AS number assigned to it, which are usually taken from the private AS range of 64,512 and 65,535.

Inside each sub-AS the routers of that sub-AS need to adhere to the full mesh topology principle still. Connections between different sub-AS have an eBGP connections. To avoid routing loops, a sub-AS will use confederation sequences that are like the AS paths. The confederation sequences are usually made up of private AS numbers.

Route Reflectors

A BGP route reflector is designed to remove the limitation of iBGP that requires a full mesh and all BGP routers in the single AS to be neighbours. The route reflector is a single router in the AS that has neighbour relationships to all other routers in the AS.
This router will receive updates (NRLI) from each router and reflect, advertise them to the other routers in the AS. This is much more efficient.

The router reflector isn’t a perfect solution. As the number of iBGP routers increases, a route reflector also becomes difficult to scale. A solution to this is to cluster groups of routers together for hierarchical route reflection.

Neighbour Formations

As BGP uses TCP to form neighbours, there is the three-way handshake needed to start the process off of forming neighbours.

1. To begin with, the routers are in Idle state. Nothing has yet happened.
2. Next, the routers start the TCP three-way handshake, which moves them to the Connected state.
3. Once the TCP session is established, the routers move to the Active state. Active does not mean finished. It means the routers are trying to form a BGP neighbour relationship.
4. An OpenSent state, the open message will contain things like BGP AS number, versions. If everything is OK, BGP will start to send keepalive messages.
5. OpenConfirm state is when the router is waiting for the keepalive messages. Once the keepalives message is received, then it can progress to the Established state.
6. In the Established state, the BGP neighbours can start to send update messages. BGP uses a hold timer for any missed keepalive messages. It is reset when keepalive messages are received.

BGP Messages and Timers

The Open Message is sent during the OpenSent state includes; BGP version, local AS number, hold timer, BGP router ID, optional parameters. The default keepalive is 60 seconds, and hold timer is 180 seconds.

The Update Message contains: NRLI, path attributes and can include withdrawn routes.

The Keepalive Message is what keeps the holdtimer from expiring.

The Notification Message contains an error code, error subcode and information about the error

Basic BGP Configuration

I have created a small two router topology to explore the messages that are sent.

Once configured, the routers will form neighbours. The formation can be seen in the Wireshark capture below. I haven’t added any routes yet, so nothing special is happening.

Formation TCP Stream
Open message from IOU9, that shows the numerous optional parameters
Open message from IOU12
Keepalive message sent from IOU12
Update message from IOU9, empty as there are no routes

Now that the routers have formed their neighbour relationship, they will continue to pass back the keepalive messages to maintain the TCP session and neighbour relationship.

Next is to add some routes to have them send updates to make this useful. I’m simply going to redistribute the connected networks on the routers to see the update messages.

Update message sent from IOU9 to IOU12
Update message from IOU12 to IOU9

Removing the redistribute connected command will remove the routes in an update message containing the withdrawn routes.

Path Selection

There are numerous path attributes, not all of them are used. I will focus on the eight most important. An easy way to remember them is to use a mnemonic device, We Love Oranges, AS Oranges Mean Pure Refreshment.

Weight
Local Preference
Originate
AS Path Length
Origin Type
Multi-Exit Discriminator (MED)
Paths
Router ID

This list is sequential, if the routes are tied on each attribute then they move to the next attribute.

Weight: The path with the highest weight is preferred. This is only locally significant and not affect any other router within the AS. Cisco only, used for outbound path selection
Local Preference: The path with the highest local preference is preferred. This is not locally significant and will affect other routers in the AS. Used for outbound path selection
Originate: A path that originated on the local router is preferred to any paths learnt from a BGP peer. Cisco adds a weight of, 32768 to any prefixes advertised into the local router.
AS Path: The shortest AS path is preferred. Used for inbound path selection
Origin: Where was the path learnt from originally; IGP, INCOMPLETE. IGP via network statement and INCOMPLETE via a redistribution command. IGP is preferred to INCOMPLETE.
Multi-Exit Discriminator (MED): Lowest MED is preferred. Only performed if the first hop AS is identical. If the first hop is different, then this is skipped.
Paths: By default, only a single path is installed into the routing table. This can be changed using the maximum-paths command in Cisco and Arista.
Router ID: Compare the router ID of the peer that the path is learnt from. Lower is preferred.BGP Synchronisation

To get to grips with all these attributes, I am going to share the output from show ip bgp from my VXLAN topology. This has three spine and six leaf switches. This output is taken from leaf1 which has ECMP and multipath configured. There are a lot of networks in the BGP routing table, so I have split this up to get the parts I need, and then the entire table is below.

BGP Synchronisation

BGP synchronisation is by default disabled, and it is unlikely that it will be enabled. Basically it is denying a BGP route advertisement if that network isn’t also learnt on an IGP like OSPF.

I will demonstrate this with the topology below. IOU7 has a loopback interface of 3.3.3.3. This is advertised via the redistribute connected command into BGP. IOU9 learns this and also advertises it to IOU12 via eBGP.
So now all the routers know about 3.3.3.3/32.

When BGP synchronisation is enabled on IOU9 and the BGP session cleared using clear ip bgp * and then re-established, IOU12 will not know about 3.3.3.3

To get this to work again, there ate two options.
1. Disable synchronisation
2. Configure an IGP to permit synchronisation to perform the function it is designed for.

I’ll configure OSPF to fulfil the requirement to get BGP synchronisation working.

Now that IOU9 has learnt about the 3.3.3.3 network over OSPF it will pass it along via eBGP to IOU12

BGP Summarisation

BGP summarisation is route summarisation. This is as in IGP route summarisation the ability to change the subnet mask of the route to include a large set of networks. BGP calls this route summarisation an aggregate.

In the example lab, I will do have 4 /24 networks and advertise them using a single /22 network.
IOU7 has four /24 networks and when redistributed into BGP they are sent over as individual networks to IOU9 that appear in the IOU9 routing table as four /24 networks. These four networks can be summarised into one single /22 network to be advertised.

eBGP Multihop

BGP does not have to only form neighbour relationships with adjacent routers. BGP can form neighbour relationships with routers that are several hops away. For this to happen, BGP relies on the existing routing that it has to reach the neighbour. Remember, BGP forms neighbours to manually set IP addresses using TCP 179. This is known as eBGP multihop.

I’m going to use the exact same topology and allow IOU7 to form a neighbour relationship with IOU12.

Router IOU7 now has two neighbours, IOU9 and IOU12

IOU12 is learning about the 1.1.0.0/22 network via two AS’. IOU12 has picked the best route, which is via IOU7, to install into its routing table. This is due to fewer AS’ in the path. As we can see from the diagram, this is going the exact same way.

As a side note, due to the nature of this topology, IOU12 is receiving updates about its own network 192.200.100.0/30 from IOU7. This is because IOU7 is learning about the 192.200.100.0/30 network from IOU9 that is between the two neighbours. IOU12 is seeing this update and is denying the update due to its own AS number being in the path. This is the loop prevention method of BGP. The update can be seen using the debug command debug ip bgp updates.

iBGP & eBGP Next Hop Handling

iBGP and eBGP handle next hops differently. When the iBGP router advertises a route that it learns over eBGP to an iBGP neighbour, it does not pass along itself as the next hop. This means that if the downstream iBGP router that receives the route, it could be sending traffic to a destination that it does not know about.

I have created an example to show this using the three routers. IOU12 is advertising 192.168.20.0/24 over eBGP to IOU9. IOU9 is then sending that network as an update to IOU7. IOU7 is receiving the next hop as the same address as IOU9, which is 192.200.100.2. However, IOU7 has no record of this address in its routing table. Traffic does not go anywhere.

Look at the 192.168.20.0, the next hop is 192.200.100.2 in IOU7

This is the same BGP update for IOU7, which is what causes the problem.

The fix is to update the router that is receiving the router over eBGP, IOU9. This router will modify the advertisement to use its own IP address as the next hop and not the original.

Peer Groups

A BGP per group has two functions. The first is, it simplifies the configuration by allowing multiple attributes to be part of a group and adding neighbours to that group. Less config per neighbour now. The second function is that the router will check the routing table only once, and updates are sent to all peer group members instead of the updates being sent to each individual peer.

I have reconfigured BGP to be using IOU7 and IOU9 as an ISP type. Both are now connected to IOU12 via eBGP. A peer-group has been configured on IOU12 so the two routers in AS 65001 can be grouped together.

This does not look like a lot of line saving from a configuration point of view, however where there are more peers and more BGP options configured for the peers the savings of configuration can be a lot. If you look at the below output from my Arista VXLAN BGP configuration on spine1, the EVPN peer group has five BGP options configured. These five lines would need to be multiplied per EVPN leaf switch without the peer group.

Leave a Comment

Your email address will not be published. Required fields are marked *