0% found this document useful (0 votes)
14 views

BGP Best Path Selection

Uploaded by

Riyaz Admin
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views

BGP Best Path Selection

Uploaded by

Riyaz Admin
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

BGP Best Path Selection:

o BGP sends update packet to a peer with path attributes associated with prefix.
o BGP selects the best path based on a list of attributes.
o BGP attributes are similar to metrics in OSPF and EIGRP.
o BGP use path attributes to pick the best route to a destination.
o BGP store multiple paths to a destination in BGP table.
o BGP only install one best route in the routing table.
o BGP path algorithm decides best path to install in the IP routing table.
o BGP path algorithm decides best path to use for traffic forwarding.
o BGP goes through the following steps to select the best path route.

Priority Attribute Preference


1 Weight Highest
2 Local Preference Highest
3 Originate Local
4 AS Path Shortest
5 Origin Code Lowest
6 MED Lowest
7 EBGP Path Over IBGP Path Prefer eBGP
8 Shortest IGP Path to BGP Next Hop Lowest IGP Metric
9 Oldest Path Received First
10 Router ID Lowest
11 Neighbor IP Address Lowest Neighbor IP

Weight Local Preference Originate AS Path Length Origin Code


1 2 3 4 5

MED EBGP over IBGP Shortest IGP Path to BGP Oldest Path
6 7 8 9

Router ID Neighbor IP Address


10 11
1. Weight:
o Weight is Cisco-Proprietary value.
o Weight is only local on the router.
o Weight is not exchanged between BGP routers.
o Weight is never advertised to other routers.
o The path with the highest weight is preferred.
o Weight for a route originated on the local router is 32768.
o Weight is zero for all other routes.

R1 Configuration R2 Configuration
interface f0/0 interface f0/0
ip add 192.168.12.1 255.255.255.0 ip add 192.168.23.2 255.255.255.0
no shutdown no shutdown
interface f0/1
interface f0/1 ip add 192.168.12.2 255.255.255.0
ip add 192.168.13.1 255.255.255.0 no shutdown
no shutdown interface loopback3
ip add 23.23.23.2 255.255.255.0
R3 Configuration
interface f0/0 interface f0/1
ip add 192.168.23.3 255.255.255.0 ip add 192.168.13.3 255.255.255.0
no shutdown no shutdown
interface loopback3
ip add 23.23.23.3 255.255.255.0

R1 BGP configuration R2 BGP configuration


router bgp 1 router bgp 2
neighbor 192.168.12.2 remote-as 2 neighbor 192.168.12.1 remote-as 1
neighbor 192.168.13.3 remote-as 2 neighbor 192.168.23.3 remote-as 2
network 23.23.23.0 mask 255.255.255.0
R3 BGP Configuration
router bgp 2
neighbor 192.168.13.1 remote-as 1
neighbor 192.168.23.2 remote-as 2
network 23.23.23.0 mask 255.255.255.0

First, let us check BGP weight attribute value for internal and external routes. It is 0 for external
routes and 32768 default for internal routes.

Router R1 decided to use 192.168.12.2 as the next hop. All the BGP attributes are the same so it
came down to the router ID to select a winner.

R1 Weight Configuration
router bgp 1 clear ip bgp *
neighbor 192.168.13.3 weight 500 show ip bgp

After changing the weight, R1 Now selected 192.168.13.3 as the next hop address.
2. Local Preference:
o Local Preference is the second BGP attribute.
o Use local preference to choose the outbound external BGP path.
o Local Preference is sent to all Internal BGP routers in AS.
o Local Preference is not exchanged between external BGP routers.
o Local preference is a Well-Known and Discretionary BGP attribute.
o Local Preference Default value is 100.
o The path with the highest Local Preference is preferred.

3. Originate:
o Originate is the third BGP attribute.
o Prefer the path that the local router originated.
o In the BGP table, Local router originated see next hop 0.0.0.0.
o Routes with weight set to “32768” is considered as local routes.
o Path in the BGP table through Network Command, Aggregation, or Redistribution.
o BGP router will prefer routes that it installed into BGP itself to another router installed.

4. AS Path:
o AS Path is the fourth BGP attribute.
o AS path is a mandatory attribute, describe path taken on the way to destination.
o BGP prefers the shortest AS path to get to a destination.
o BGP AS Path is a Well-Known mandatory attribute.
o Ordered list of ASNs through which the update has passed.
o The main purpose of the AS Path is to avoid loops.
o AS-Path prepending is to make received prefix "Less Attractive".
o Add own AS number multiple times so the as path becomes longer.
o AS-Path prepending is a way to manipulate the AS-Path attribute of a BGP route.
o AS-Path prepending can be applied to inbound and outbound direction using route-maps.
o AS path 1 2 3 is preferred over AS path 1 2 3 4 5.

5. Origin Code:
o BGP prefer the lowest Origin Code.
o There are three origin codes: IGP, EGP & Incomplete.
o IGP is lower than EGP and EGP is lower than Incomplete.
o IGP (shows up as i) use the network command for BGP.
o EGP (shows up as e) is an old routing protocol no more.
o Incomplete (shows up as ?) means redistributed something into BGP.
o Origin is a Well-known mandatory attribute.
6. MED:
o MED (Multi-Exit Discriminator) is the sixth BGP attribute.
o Multi-Exit Discriminator (MED) is optional non-transitive attribute.
o The lowest MED is the preferred path.
o The MED is exchanged between Autonomous Systems.
o MED is used to advertise the neighbors how to enter the AS.
o MED is propagated to all routers within the neighbor AS.
o MED is not passed along any other Autonomous Systems.
o MED can influence routers in the same AS but not on different AS.

7. EBGP Path Over iBGP Path:


o Prefer eBGP (External BGP) over iBGP (Internal BGP) paths.
o Routes learned via eBGP is more preferred than routes learned via iBGP.
o If both routes are learned via eBGP then chooses the lowest IGP value to the next hop.

8. Shortest IGP Path to BGP Next Hop:


o Prefer the path within the AS with the lowest IGP metric to the BGP next hop.

9. Oldest Path:
o Prefer the path that received first, in other words, the oldest path.
o The oldest route in the routing table is preferred over the new ones.

10. Router ID:


o Prefer the path with the lowest BGP neighbor router ID.
o Lowest router ID will be selected as the best path.
o The router ID is based on the highest IP address.
o If there is loopback interface, then the IP address of loopback will be used.
o The router ID can also be manually configured.

11. Neighbor IP Address:


o Prefer the path with the lowest neighbor IP address.
o If two eBGP routers and two links in between then the router ID will be the same.
o In this case, the neighbor IP address is the tiebreaker.

R1 Configuration R2 Configuration
interface f0/0 interface f0/0
ip add 192.168.12.1 255.255.255.0 ip add 192.168.12.2 255.255.255.0
no shutdown no shutdown
interface f0/1
ip add 192.168.13.1 255.255.255.0 interface f0/1
no shutdown ip add 192.168.24.2 255.255.255.0
interface loopback1 no shutdown
ip add 1.1.1.1 255.255.255.0
R3 Configuration R4 Configuration
interface f0/0 interface f0/0
ip add 192.168.35.3 255.255.255.0 ip add 192.168.24.4 255.255.255.0
no shutdown no shutdown

interface f0/1 interface f0/1


ip add 192.168.13.3 255.255.255.0 ip add 192.168.46.4 255.255.255.0
no shutdown no shutdown
R5 Configuration R6 Configuration
interface f0/0 interface f0/0
ip add 192.168.35.5 255.255.255.0 ip add 192.168.67.6 255.255.255.0
no shutdown no shutdown
interface f0/1
interface f0/1 ip add 192.168.46.6 255.255.255.0
ip add 192.168.57.5 255.255.255.0 no shutdown
no shutdown interface loopback6
ip add 6.6.6.6 255.255.255.0
R7 Configuration
interface f0/0 interface loopback7
ip add 192.168.67.7 255.255.255.0 ip add 7.7.7.7 255.255.255.0
no shutdown
interface f0/1 interface loopback77
ip add 192.168.57.7 255.255.255.0 ip add 77.77.77.77 255.255.255.0
no shutdown

BGP Configuration on All 7 Routers

R1 Configuration R2 Configuration
router bgp 123 router bgp 123
neighbor 192.168.12.2 remote-as 123 neighbor 192.168.12.1 remote-as 123
neighbor 192.168.13.3 remote-as 123 neighbor 192.168.24.4 remote-as 4
network 1.1.1.0 mask 255.255.255.0 neighbor 192.168.12.1 next-hop-self
R3 Configuration R4 Configuration
router bgp 123 router bgp 4
neighbor 192.168.13.1 remote-as 123 neighbor 192.168.24.2 remote-as 123
neighbor 192.168.35.5 remote-as 5 neighbor 192.168.46.6 remote-as 6
neighbor 192.168.13.1 next-hop-self
R5 Configuration R6 Configuration
router bgp 5 router bgp 6
neighbor 192.168.35.3 remote-as 123 neighbor 192.168.46.4 remote-as 4
neighbor 192.168.57.7 remote-as 7 neighbor 192.168.67.7 remote-as 7
network 6.6.6.0 mask 255.255.255.0
R7 Configuration
router bgp 7
neighbor 192.168.57.5 remote-as 5
neighbor 192.168.67.6 remote-as 6
network 7.7.7.0 mask 255.255.255.0
network 77.77.77.0 mask 255.255.255.0

R1 Weight Attribute Tune R1 Local Preference Attribute Tune


route-map WT 10 route-map LOCALPREF 10
set weight 800 set local-preference 500

router bgp 123 router bgp 123


neighbor 192.168.13.3 route-map WT in neighbor 192.168.13.3 route-map
LOCALPREF in
R6 Path Attribute Tune
access-list 6 permit 6.6.6.0 0.0.0.255
route-map PAT 10
match ip add 6
set as-path prepend 6 6 6
exit
route-map abc 20
router bgp 6
neighbor 192.168.46.4 route-map PAT out

BGP Attributes:
o BGP is a very flexible and extensible protocol.
o BGP path selection is done through the best path algorithm.
o Best path uses various attributes assigned to each route.
o BGP attributes are similar to metrics in OSPF and EIGRP.
o BGP selects the best path based on a list of attributes.
o BGP use attributes to decide the best route.
o BGP has 0 to 14 attributes for Cisco.
o BGP has 1 to 14 attributes for other venders.
o BGP does not use metrics but use set of attributes.
o BGP has four main types of attributes.
o Well-Known Mandatory.
o Well-Known Discretionary.
o Optional Transitive.
o Optional Non-Transitive.
Well-Known Mandatory:
o As the name suggests it is mandatory and must.
o These attribute must appear in every Update message.
o Must be recognized & supported by all BGP speakers.
o If these attribute are missing a Notification, error is generated.
o If these attribute are missing the session will be closed.
o Well-Known mandatory attributes are AS Path, Next Hop Address, & Origin.

Well-Known Discretionary:
o Must be recognized & supported by all BGP speakers.
o May or may not appear in every BGP Update message.
o Does not have to be included in every BGP update message.
o Well-Known Discretionary attributes are Local Preference & Atomic Aggregate.

Optional Transitive:
o May or may not be supported by all BGP speakers.
o Will be passed on if not recognized by the receiver.
o The attribute should be accepted and passed along to other peers.
o Optional Transitive attributes are Aggregator and Community.
o Transitive, these attributes are across AS boundaries.

Optional Non-Transitive:
o May or may not be supported by all BGP speakers.
o Not required to pass on, may be safely ignored.
o The attribute should be ignored and not passed on to other peers.
o Optional Non-Transitive attributes are MED, Originator ID and Cluster List.
o Non-transitive, these attributes are restricted to the same AS.
Type Code Attribute Name Category
1 Origin Well-Known Mandatory
2 AS Path Well-Known Mandatory
3 Next Hop Well-Known Mandatory
4 Multi Exit Disc (MED) Optional Non-Transitive
5 Local Pref Well-Known Discretionary
6 Atomic Aggregate Well-Known Discretionary
7 Aggregator Optional Transitive
8 Community Optional Transitive
9 Originator ID Optional Non-Transitive
10 Cluster List Optional Non-Transitive

You might also like