top of page
Writer's pictureMukesh Chanderia

Interview Questions BGP

Updated: Jan 16, 2023

Local AS features


The local-AS feature allows a router to appear to be a member of a second autonomous system (AS), in addition to its real AS.


This feature can only be used for true eBGP peers. You cannot use this feature for two peers that are members of different confederation sub-ASs.


BGP Synchronization Rule


BGP will not advertise something that it learns from an IBGP neighbor to an EBGP neighbor if the prefix can’t be validated in its IGP.





Above we see 5 routers and 3 autonomous systems. When we want to get from R1 to R5 we’ll have to cross AS2, this makes AS2 our transit AS.


EBGP has been configured between R1/R2 and also between R4/R5. IBGP is configured between R2/R4 and R3 on top doesn’t run BGP at all.


The routers within AS2 are configured with OSPF, this is required since R2/R4 have to be able to reach each other to establish the IBGP session.


R1 will advertise a prefix in BGP, AS2 and AS3 will learn about this prefix.



BGP Dampening


BGP Flapping can occur when you have an unstable peer. This occurs when the BGP route disappears and reappears in the routing table.


BGP route dampening can be used to reduce the propagation of unstable routes throughout a network.


Route dampening is a BGP feature designed to minimize the propagation of flapping routes across an internetwork.


router bgp <AS number>

bgp dampening


When a prefix flaps it will be assigned a penalty of 1000 and moved into the dampening state “history”.


Each flap incurs another penalty (of 1000)


If the penalty reaches the suppress-limit, the route is dampened, meaning it won’t be advertised to any neighbors.


The default values for each dampening criteria are stated below:


Penalty :1000

Suppress Limit: 2000

Reuse Limit: 750

Half-Life: 15 Minutes

Maximum Suppress-Limit: 60 Minutes


Once a route has been dampened, the penalty must be reduced to a value lower than the reuse limit in order to be advertised once again.

After a penalty has been assigned and the prefix has become stable again, the half-life timer starts.


When the half-life time has been reached, the penalty will be reduced by half (it decreases exponentially every fifteen minutes).


For example, if the penalty was 3000, then fifteen minutes later, the half-life will have reduced the penalty to 1500.


Another 15minutes will reduce the penalty to 750, and so on. Once the penalty goes below half of the re-use limit (375 in this case), the penalty is completely removed.


The maximum suppress-limit is used to ensure the prefix doesn’t get dampened indefinitely.


Using the default values above, a prefix would become un-suppressed after 60 minutes regardless of penalty.


disable-connected-check


How to create ebgp peer neighbourship between directly connected routers with loopback without using multihop ?


External BGP is having TTL of one i.e. the neighbours must be directly connected. The loopback interface is considered one hope away from router.


So "ebgp-multihop 2" is required to be configured if we want to establish bgp neighbourship through loopback.


Now if we don't want to use "ebgp-multihop 2" then we can use command "disable-connected-check"


router bgp 100


neighbor 2.2.2.2 remote-as 200


neighbor 2.2.2.2 disable-connected-check


neighbor 2.2.2.2 update-source Loopback0



Recursive Lookup


When multiple lookups is required to be performed to route the packet.


BGP can have peers which aren't directly connected.


Suppose a packet is received by router then as per its destination ip router will first determine the next hop & now it would require to figure out the exit interface to reach next hop.


There can be more lookups, until the route with exit interface can be found.


BGP Attribute Types


Well-known mandatory: Must be supported and propagated.

Next-hop

Origin

AS PATH


Well-known discretionary: Must be supported; propagation optional

Local Preference

Atomic Aggregate


Optional transitive: Marked as partial if unsupported by neighbor

Aggregator

Community


Optional non-transitive: Deleted if unsupported by neighbor

Multi-exit discriminator (MED)

Originator ID

Cluster-ID


BGP Path Selection


  1. Weight (highest): Weight is not exchanged between routers & is Cisco proprietary.

  2. Local Preference (highest): It chooses the outbound (in to out) external exit path. It is sent to all internal BGP routers. The default value is 100. Higher value is preferred.

  3. Originate (local originate): BGP router will prefer a route if it's locally originated (means that its next hop IP address is 0.0.0.0 in the BGP table).

  4. AS Path (shortest): BGP prefers the shortest AS path to get to a destination. We can manipulate this by using AS path prepending.

  5. Origin Code [IGP (network command in BGP) < EGP (This protocol is now Not in Use) <Incomplete (redistribution in BGP)]

  6. MED (lowest): Suggestion to neighbors how they should enter your AS. The lowest MED is the preferred path. Only propagated to all routers within the neighbor AS but not passed along any other autonomous systems.

  7. Paths (external preferred over internal): BGP will prefer external paths (external BGP) over internal paths (internal BGP)

  8. Router ID (lowest): If everything is the same then the router ID will be the decision maker or Tie breaker…the router with the lowest router ID will be used for the path.


Loop Prevention in BGP


External BGP: If a router sees its own AS number in the AS path, then it won’t accept it since it’s a loop.


Internal BGP: BGP split-horizon: When a BGP router receives an update from another internal BGP router it will not forward this information to another internal BGP router. This is also known as BGP split–horizon rule.


This is the reason why internal BGP routers have to be configured as full-mesh.


The full mesh configuration of ibgp peers will increase bandwidth consumption as same update will be reaching from different routers and will also consume more memory.


Route reflectors (RR) & BGP confederations can be configured to get rid of the full-mesh of IBGP peers.


R2(config) # router bgp 123

R2(config-router) # neighbor 192.168.12.1 remote-as 123

R2(config-router) # neighbor 192.168.12.1 route-reflector-client


BGP address-family


BGP has multi-protocol capability i.e. in a single session, it is capable of carrying information about different routed protocols (IPv4 Unicast, IPv4 Multicast, IPv6 Unicast, IPv6 Multicast & VPNv4) which is commonly known as "address families".


Some means is required to tell BGP which address families should be exchanged with a particular neighbor.


Defining a neighbor under a particular address family means that we want to exchange routes from the particular address family with that neighbor.


For backward compatibility with older BGP versions which aren't multiprotocol-capable, the BGP automatically assigns all defined neighbors to an invisible address-family ipv4 section.

To change this default behavior simply enter the BGP configuration and issue the command "bgp upgrade-cli" & by doing so BGP configuration will be fully converted to the address family style of configuration.


The behavior or operations of BGP do not change with this new style of configuration, only the configuration format is changed.


"no bgp default ipv4-unicast command" in the BGP configuration, it will prevent BGP from automatically assigning each newly defined neighbor into address-family ipv4 section.


Configure ebgp peers with loopback


Udaipur(config)#router bgp 1

Udaipur(config-router) #neighbor 2.2.2.2 remote-as 2

Udaipur(config-router) #neighbor 2.2.2.2 update-source loopback 0

Udaipur(config-router) #neighbor 2.2.2.2 ebgp-multihop 2


Delhi(config)#router bgp 2

Delhi(config-router) #neighbor 1.1.1.1 remote-as 1

Delhi(config-router) #neighbor 1.1.1.1 update-source loopback 0

Delhi(config-router) #neighbor 1.1.1.1 ebgp-multihop 2


External BGP uses a TTL of 1 for its updates & when we source our updates from the Loopback interfaces, we will exceed a TTL of 1


BGP Configuration Examples


Weight --> Set Priority for incoming traffic


The default value of weight is 0 and the range is from 0 to 65535.


When the prefix is locally generated, it will get a weight of 32768.


To put weight on all routes, advertised by Neighbours


router bgp 12

neighbor 172.16.0.1 weight 200


To put weight on particular route


router bgp 12

neighbor 3.3.3.3 route-map WEIGHT in


access-list 1 permit 44.44.44.0 0.0.0.255


route-map WEIGHT permit 10

match ip address 1

set weight 65535

!

route-map WEIGHT permit 20


Local Preference --> Set Priority for outgoing traffic


A higher local preference is preferred and the default is 100.


To set local preference for all routes for a particular Neighbour


R3(config)# router bgp 1

R3(config-router) # bgp default local-preference 200


To set route for particular route for specific Neighbour


R3(config)# router bgp 1

R3(config)# neighbour 192.168.35.5 route-map PREF in


R3(config)# ip prefix-list network4 4.4.4.0/24

R3(config)# route-map PREF permit 10

R3(config-route-map) # match ip address prefix-list network4

R3(config-route-map) # set local-preference 300


AS Number Prepend


ip prefix-list network4 4.4.4.0/24


route-map ASP permit 10

description ASPREPAND

match ip address prefix-list ASPREPAND

set as-path prepend 10 10 10

route-map ASP permit 20


router bgp 10

address-family ipv4

neighbor 100.121.1.1 route-map ASP out


MED




Router R4


router bgp 65502

network 10.4.0.0 mask 255.255.0.0

network 10.5.0.0 mask 255.255.0.0

neighbor 192.168.20.2 remote-as 65501

neighbor 192.168.20.2 route-map setMED-R2 out

neighbor 192.168.30.3 remote-as 65501

neighbor 192.168.30.3 route-map setMED-R3 out


access-list 1 permit 10.4.0.0 0.0.255.255

access-list 2 permit 10.5.0.0 0.0.255.255


R4 is suggesting that for 10.4.0.0/16, R2 must be used to enter its AS


route-map setMED-R2 permit 10

match ip address 1

set metric 100

!

route-map setMED-R2 permit 20

match ip address 2

set metric 200


And also, for route 10.5.0.0/16, R3 must be used to enter R4's AS


route-map setMED-R3 permit 10

match ip address 1

set metric 200

!

route-map setMED-R3 permit 20

match ip address 2

set metric 100


Enabling the bgp deterministic-med command ensures the comparison of the MED variable when choosing routes advertised by different peers in the same autonomous system.


Enabling the bgp always-compare-med command ensures the comparison of the MED for paths from neighbors in different autonomous systems.


Kindly click HERE to see the original document.



Important Points


If you want to advertise something with BGP, you need to make sure you type the exact subnet mask for the network you want to advertise.


BGP uses TCP port 179 to establish a neighbor’s adjacency.


Internal BGP does not change the next hop IP address.


Administrative distance of external BGP is 20 & of internal is 200.




44 views0 comments

Recent Posts

See All

Comments


bottom of page