BGP Attributes
BGP Attributes
Selection
When your BGP speaker receives a BGP prefix, there are going to be many path
attributes tagged to it, and we know that these are going to be critical when it comes to BGP
doing things like choosing a very best path to a destination. Interestingly, not all of these path
attributes are created equal.
All BGP path attributes fall into one of four main categories.
Optional Transitive:
In this lab we have manipulated the path by using AS path prepend now in this case R3 wants to
reach destination 4.4.4.0/24 then it choose the next hop as 35.1.1.2 as it shortest AS path and
BGP by default uses it. Now suppose we want to change the path we want to traffic to go via
25.1.1.1. When we want to manipulate the path from one AS to another AS then we use AS
path prepend.
R1 Running Configuration:
Simple here neigborship is established with respective peers as per above topology.
R2 Configuration:
Note here that in the BGP the route for prefix 4.4.4.0/24 next hop is 15.1.1.1 which was
originally 25.1.1.2 before applying AS path prepend. Currently output is taken after applying AS
path prepend.
R3 Configuration:
Output taken after applying AS path prepend hence why valid best path is 25.1.1.1.
Output before applying AS path prepend hence why next hop is 35.1.1.2. Because by default it
chooses the shortest AS path.
R4 Configuration:
Now we apply AS Path prepend on that router from which we don’t want traffic from.
Now we have created a route map and created dummy AS number to increase it AS path. After
this we bind this route map with R3 from where we don’t want traffic from. Multiple dummy AS
advertised so router R3 does not take this path to send packets.
Local Preference Attribute:
The BGP Local Preference attribute is used to manipulate the best outbound path and applied
on inbound external routes. Unlike the Weight attribute, Local Preference is passed on to IBGP
peers.
If multiple paths exist, Local Preference BGP informs IBGP routers how to exit the AS i.e. which
path to prefer for outgoing traffic. Local Preference is a 32-bit number and can range from 0 to
4294967295.
▪ Local to an AS.
▪ LOCAL_PREF is set to 100 when heard from neighboring AS.
▪ Used to influence BGP path selection.
▪ Determines best path for outbound traffic.
▪ Path with highest local preference wins.
Here we have implented The BGP Local Preference attribute that is manipulating the best
outbound path and applied on inbound external routes. So in our case we have applied it on R2
router as if destination address is 1.1.1.0/24 this router R2 will be used to forward the traffic
and if destination if 2.2.2.0/24 then R3 will be used to forward the traffic to the destination.
R1 Configuration:
BGP Summary Neigborship:
R3 Configuration:
Neigborship summary for R3:
R4 Configuration:
Neigborship summary for R4:
Result:
Now below shown is the BGP table for R4 before applying local preference on R2.
Local preference is used to control outbound traffic towards another AS and is applied within
that AS from where outbound traffic to another AS will be controlled. The exit point is
determined within that AS so after applying local preference on R2 result is show below as for
destination 1.1.1.0/24 R2 is used for outbound traffic and for destination 2.2.2.0/24 R3 is used
for outbound traffic.
Weight Attribute:
Weight is also one of the most unique attributes, because the value is not passed to other
routers. Weight is a value that is assigned to our prefixes as a locally significant value. Weight is
a simple number in the range of 0 through 65535, and the higher the weight value, the higher
the preference for that path. When the prefix is locally generated, it will get a weight of 32768.
Otherwise, the default weight is 0 for a prefix.
If the administrator wants to prefer one of the paths for whatever reason, they can manipulate
the local Weight value on the preferred path and instantly influence BGP's best path decision
process.
Weight is a Cisco proprietary BGP attributes that can be used to select a certain path. Weight is
the first BGP attribute in the list.
AS we know that BGP by default chooses shortest AS path to determine the shortest best
route now if want to take traffic from particular path we can use Cisco proprietary attribute
Weight.
R1 Configuration:
R2 Configuration:
Results:
Below snap shows that the R1 bgp table indicates that for destination 3.3.3.0/24 next hop or
best path is 11.1.1.2. Now we will change it using BGP weight attribute to manipulate path by
moving traffic to another path i.e. 10.1.1.2
MED Attribute:
BGP MED is an attribute used for traffic engineering and is set by an autonomous system
advertising routes to another peer. It plays an important role in attempting to influence
traffic ingress into an autonomous system. MED is evaluated after the local preference
and AS path attributes.
In below topology we showed that R1 has two paths to reach AS 200 routes of 5.5.5.0/24 after
configuration R1 choosed the path via R2 to reach destination 5.5.5.0/24 we used MED
attribute to manipulate path and route the traffic via R3.
R1 Configuration:
R1 Neigborship:
R2 Configuration:
Here on R2 we have increased the metric so R3 automatically becomes the best valid path to
reach destination 5.5.5.0/24.
R3 Configuration:
Neigborship of R3:
BGP Table for R3:
R5 Configuration:
Neigborship of R5:
Results:
Before MED attribute its shows best path via next hop as 15.1.1.2 i.e. R2
After applying MED on R2 its shows best path via R3 i.e. next hop as 25.1.1.2
BGP Attributes and Path Selection:
Weight:
Prefer the path with the highest weight. This is a value that is local to the router and it’s Cisco
proprietary. The default value is 0 for all routes that are not originated by the local router.
Local Preference:
The local preference is used within an autonomous system and exchanged between iBGP
routers. We prefer the path with the highest local preference. The default value is 100.
Originate:
Prefer the path that the local router originated. In the BGP table, you will see next hop 0.0.0.0.
You can get a path in the BGP table through the BGP network command, aggregation, or
redistribution. A BGP router will prefer routes that it installed into BGP itself over a route that
another router installed in BGP.
AS path length:
Prefer the path with the shortest AS path length. For example, AS path 1 2 3 is preferred over
AS path 1 2 3 4 5.
Origin code:
Prefer the lowest origin code.
IGP
EGP
IGP is lower than EGP and EGP is lower than INCOMPLETE.
MED:
Prefer the path with the lowest MED. The MED is exchanged between autonomous systems.
Oldest Path:
Prefer the path that we received first, in other words, the oldest path.
Router ID:
Prefer the path with the lowest BGP neighbor router ID. The router ID is based on the highest IP
address. If you have a loopback interface, then the IP address on the loopback will be used. The
router ID can also be manually configured.
Neighbor IP address:
Prefer the path with the lowest neighbor IP address. If you have two EBGP routers and two links
in between then the router ID will be the same. In this case, the neighbor IP address is the
tiebreaker.