Tuesday, 18 February 2025

What is BGP Allowas-in Feature? How to configure BGP Allowas-in? GNS3

 BGP Allowas-in is a configuration option in Border Gateway Protocol (BGP) routing that allows a router to accept routes with its own AS (Autonomous System) number in the AS_PATH attribute.
There's a risk of creating routing loops if not managed properly. It should be used cautiously and with a clear understanding of network topology.

  • Purpose: Normally, BGP prevents loops by rejecting routes that contain the local AS number in the AS_PATH. However, in scenarios like multi-homed environments or when dealing with MPLS VPNs, you should allow routes to come back into your AS through different paths.

  • Functionality: When you configure allowas-in, you specify how many times your AS number is allowed to appear in the AS_PATH. This number can be set between 1 to 10, although this varies by router vendor and model. For example, setting allowas-in 2 would allow routes with up to two instances of your AS number in the path.

Usage Scenario:
  1. Multi-homed Networks: If you have connections to the same ISP in different locations, allowas-in can prevent unnecessary route blackholing by allowing these routes back into your network.
  2. MPLS VPNs: In scenarios where customer routes are sent through a service provider network and back, allowas-in ensures these routes are not dropped.

Configuration Example (Cisco IOS-like syntax):

plaintext
router bgp 65100
 neighbor 12.1.1.2 remote-as 65200
 neighbor 12.1.1.2 allowas-in 2
end

To allow the re-advertisement of all prefixes that contain duplicate ASNs, use the neighbor allowas-in command in router configuration mode in Router


Risks:

  • There's a risk of creating routing loops if not managed properly. It should be used cautiously and with a clear understanding of network topology.
  • It can also lead to suboptimal routing if not configured correctly.

Best Practices:
  • Use sparingly and only where necessary.
  • Monitor BGP updates closely when employing this feature.
  • Combine with route-maps or other BGP policies to control which routes are accepted.
This configuration can significantly affect network reachability and BGP convergence, so it should be deployed with a good understanding of BGP dynamics and network design.
 
let's see the configuration:-

Topology:-




Goal- allow the same AS routes installed in router 1 and router 5 routing table. 
  • configure the IP addresses as per the topology
  • configure EBGP IBGP protocols
  • verify the 10.0.0.0/8 in the router 5 routing table
  • verify the 50.0.0.0/8 in the router 1 routing table
  • configure BGP allowas-in feature on routers 1 and 5
  • ensure route 10.1.1.1 and 50.1.1.1 in router 1 and 5 routing table.
  • in the end, ensure the connectivity with ping traceroute commands





R1(config)#interface ethernet 5/0
R1(config-if)#ip address 10.1.1.1 255.0.0.0
R1(config-if)#no shutdown
R1(config-if)#exit

R1(config)#interface serial 4/0
R1(config-if)#ip address 12.1.1.1 255.0.0.0
R1(config-if)#no shutdown
R1(config-if)#exit


R2(config)#interface ethernet 5/0
R2(config-if)#ip address 20.1.1.1 255.0.0.0
R2(config-if)#no shutdown
R2(config-if)#exit

R2(config)#interface serial 4/0
R2(config-if)#ip address 12.1.1.2 255.0.0.0
R2(config-if)#no shutdown
R2(config-if)#exit

R2(config)#interface serial 4/1
R2(config-if)#ip address 23.1.1.1 255.0.0.0
R2(config-if)#no shutdown
R2(config-if)#exit


R3(config)#interface ethernet 5/0
R3(config-if)#ip address 30.1.1.1 255.0.0.0
R3(config-if)#no shutdown
R3(config-if)#exit

R3(config)#interface serial 4/0
R3(config-if)#ip address 34.1.1.1 255.0.0.0
R3(config-if)#no shutdown
R3(config-if)#exit

R3(config)#interface serial 4/1
R3(config-if)#ip address 23.1.1.2 255.0.0.0
R3(config-if)#no shutdown
R3(config-if)#exit


R4(config)#interface ethernet 5/0
R4(config-if)#ip address 40.1.1.1 255.0.0.0
R4(config-if)#no shutdown
R4(config-if)#exit

R4(config)#interface serial 4/0
R4(config-if)#ip address 34.1.1.2 255.0.0.0
R4(config-if)#no shutdown
R4(config-if)#exit

R4(config)#interface serial 4/1
R4(config-if)#ip address 45.1.1.1 255.0.0.0
R4(config-if)#no shutdown
R4(config-if)#exit

R5(config)#interface ethernet 5/0
R5(config-if)#ip address 50.1.1.1 255.0.0.0
R5(config-if)#no shutdown
R5(config-if)#exit

R5(config)#interface serial 4/1
R5(config-if)#ip address 45.1.1.2 255.0.0.0
R5(config-if)#no shutdown
R5(config-if)#exit



R1(config)#router bgp 65100
R1(config-router)#neighbor 12.1.1.2 remote-as 65200
R1(config-router)#network 10.0.0.0 mask 255.0.0.0
R1(config-router)#network 12.0.0.0 mask 255.0.0.0
R1(config-router)#no sync
R1(config-router)#exit

*Feb 18 12:04:32.531: %BGP-5-ADJCHANGE: neighbor 12.1.1.2 Up

R2(config)#router bgp 65200
R2(config-router)#neighbor 12.1.1.1 remote-as 65100
R2(config-router)#neighbor 23.1.1.2 remote-as 65200
R2(config-router)#network 20.0.0.0 mask 255.0.0.0
R2(config-router)#network 12.0.0.0 mask 255.0.0.0
R2(config-router)#network 23.0.0.0 mask 255.0.0.0
R2(config-router)#no sync
R2(config-router)#exit

*Feb 18 12:04:32.687: %BGP-5-ADJCHANGE: neighbor 12.1.1.1 Up
*Feb 18 12:05:30.427: %BGP-5-ADJCHANGE: neighbor 23.1.1.2 Up



R3(config)#router bgp 65200
R3(config-router)#neighbor 34.1.1.2 remote-as 65300
R3(config-router)#neighbor 23.1.1.1 remote-as 65200
R3(config-router)#network 30.0.0.0 mask 255.0.0.0
R3(config-router)#network 34.0.0.0 mask 255.0.0.0
R3(config-router)#network 23.0.0.0 mask 255.0.0.0
R3(config-router)#no sync
R3(config-router)#exit

*Feb 18 12:05:30.535: %BGP-5-ADJCHANGE: neighbor 23.1.1.1 Up
*Feb 18 12:09:19.379: %BGP-5-ADJCHANGE: neighbor 34.1.1.2 Up


R4(config)#router bgp 65300
R4(config-router)#neighbor 34.1.1.1 remote-as 65200
R4(config-router)#neighbor 45.1.1.2 remote-as 65100
R4(config-router)#network 40.0.0.0 mask 255.0.0.0
R4(config-router)#network 34.0.0.0 mask 255.0.0.0
R4(config-router)#network 45.0.0.0 mask 255.0.0.0
R4(config-router)#no sync
R4(config-router)#exit

*Feb 18 12:09:18.955: %BGP-5-ADJCHANGE: neighbor 34.1.1.1 Up
*Feb 18 12:09:56.799: %BGP-5-ADJCHANGE: neighbor 45.1.1.2 Up


R5(config)#router bgp 65100
R5(config-router)#neighbor 45.1.1.1 remote-as 65300
R5(config-router)#network 50.0.0.0 mask 255.0.0.0
R5(config-router)#network 45.0.0.0 mask 255.0.0.0
R5(config-router)#no sync
R5(config-router)#exit

*Feb 18 12:09:56.643: %BGP-5-ADJCHANGE: neighbor 45.1.1.1 Up



R1#show ip bgp
BGP table version is 9, local router ID is 12.1.1.1
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
              r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete

   Network          Next Hop            Metric LocPrf Weight Path
*> 10.0.0.0         0.0.0.0                  0         32768 i
*  12.0.0.0         12.1.1.2                 0             0 65200 i
*>                  0.0.0.0                  0         32768 i
*> 20.0.0.0         12.1.1.2                 0             0 65200 i
*> 23.0.0.0         12.1.1.2                 0             0 65200 i
*> 30.0.0.0         12.1.1.2                               0 65200 i
*> 34.0.0.0         12.1.1.2                               0 65200 i
*> 40.0.0.0         12.1.1.2                               0 65200 65300 i
*> 45.0.0.0         12.1.1.2                               0 65200 65300 I

(as you can see router 1 does not have a 50.1.1.1/8 network in its routing table because of the loop prevention feature)



R5#show ip bgp
BGP table version is 9, local router ID is 50.1.1.1
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
              r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete

   Network          Next Hop            Metric LocPrf Weight Path
*> 12.0.0.0         45.1.1.1                               0 65300 65200 i
*> 20.0.0.0         45.1.1.1                               0 65300 65200 i
*> 23.0.0.0         45.1.1.1                               0 65300 65200 i
*> 30.0.0.0         45.1.1.1                               0 65300 65200 i
*> 34.0.0.0         45.1.1.1                 0             0 65300 i
*> 40.0.0.0         45.1.1.1                 0             0 65300 i
*  45.0.0.0         45.1.1.1                 0             0 65300 i
*>                  0.0.0.0                  0         32768 i
*> 50.0.0.0         0.0.0.0                  0         32768 i

(as you can see router 5 does not have a 10.1.1.1/8 network in its routing table because of the loop prevention feature both routers are in the same AS 65100)


R1(config)#router bgp 65100
R1(config-router)#neighbor 12.1.1.2 allowas-in
R1(config-router)#exit
R1(config)#end


R5(config)#router bgp 65100
R5(config-router)#neighbor 45.1.1.1 allowas-in
R5(config-router)#exit
R5(config)#end


R1#show ip bgp
BGP table version is 10, local router ID is 12.1.1.1
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
              r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete

   Network          Next Hop            Metric LocPrf Weight Path
*> 10.0.0.0         0.0.0.0                  0         32768 i
*  12.0.0.0         12.1.1.2                 0             0 65200 i
*>                  0.0.0.0                  0         32768 i
*> 20.0.0.0         12.1.1.2                 0             0 65200 i
*> 23.0.0.0         12.1.1.2                 0             0 65200 i
*> 30.0.0.0         12.1.1.2                               0 65200 i
*> 34.0.0.0         12.1.1.2                               0 65200 i
*> 40.0.0.0         12.1.1.2                               0 65200 65300 i
*> 45.0.0.0         12.1.1.2                               0 65200 65300 i
*> 50.0.0.0         12.1.1.2                               0 65200 65300 65100 i


R5#show ip bgp
BGP table version is 10, local router ID is 50.1.1.1
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
              r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete

   Network          Next Hop            Metric LocPrf Weight Path
*> 10.0.0.0         45.1.1.1                               0 65300 65200 65100 i
*> 12.0.0.0         45.1.1.1                               0 65300 65200 i
*> 20.0.0.0         45.1.1.1                               0 65300 65200 i
*> 23.0.0.0         45.1.1.1                               0 65300 65200 i
*> 30.0.0.0         45.1.1.1                               0 65300 65200 i
*> 34.0.0.0         45.1.1.1                 0             0 65300 i
*> 40.0.0.0         45.1.1.1                 0             0 65300 i
*  45.0.0.0         45.1.1.1                 0             0 65300 i
*>                  0.0.0.0                  0         32768 i
*  50.0.0.0         45.1.1.1                               0 65300 65100 i
*>                  0.0.0.0                  0         32768 I

(as you can see after we allows-in feature both the routers installed same AS routes in to their routing table)

R1#ping 50.1.1.1

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 50.1.1.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 132/154/180 ms

R1#traceroute 50.1.1.1

Type escape sequence to abort.
Tracing the route to 50.1.1.1

  1 12.1.1.2 20 msec 32 msec 32 msec
  2 23.1.1.2 [AS 65200] 72 msec 64 msec 64 msec
  3 34.1.1.2 [AS 65200] 96 msec 92 msec 104 msec
  4 45.1.1.2 [AS 65300] 148 msec 116 msec 140 msec


R5#ping 10.1.1.1

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 10.1.1.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 120/148/180 ms

R5#traceroute 10.1.1.1

Type escape sequence to abort.
Tracing the route to 10.1.1.1

  1 45.1.1.1 32 msec 32 msec 32 msec
  2 34.1.1.1 [AS 65300] 64 msec 64 msec 64 msec
  3 23.1.1.1 [AS 65200] 104 msec 96 msec 96 msec
  4 12.1.1.1 [AS 65200] 128 msec 152 msec 132 msec



I hope you like this article if you like it please visit to our YouTube channel

Tuesday, 11 February 2025

What is BGP route dampening? How to configure BGP route Dampening?

 BGP route dampening is a mechanism used in the Border Gateway Protocol (BGP) to mitigate the negative effects of route flapping. Route flapping occurs when a BGP route is repeatedly advertised and withdrawn, causing instability in the network. This instability can lead to increased CPU load on routers, excessive BGP updates, and potential routing loops.

BGP route dampening works by assigning a penalty to a route each time it flaps. If the route continues to flap, the penalty accumulates. Once the penalty exceeds a certain threshold, the route is dampened, meaning it is suppressed and not considered for routing decisions. This prevents the flapping route from causing further disruption to the network.




After some time, the penalty for a dampened route begins to decrease. Once the penalty falls below another threshold, the route is un-dampened and can be used again. This allows the route to recover if the underlying issue causing the flapping has been resolved.

BGP route dampening helps to improve network stability and reduce the load on routers by preventing the propagation of flapping routes. However, it can also lead to temporary loss of connectivity for some destinations if routes are dampened for extended periods. Therefore, it is important to carefully configure the dampening parameters to balance stability and availability.

 

Note-

  • BGP route dampening is designed to reduce route processing load caused by unstable routes. 
  • Each time an eBGP route flaps, it gets 1000 penalty points. we cannot modify this configuration. 
        *Feb  4 13:14:50.315: EvD: charge penalty 1000, new accum. penalty 1000, flap count 1

  • only eBGP routes are dampened.
  • if the penalty exceeds the suppress limit the route is dampened and no longer used but if the route penalty is dropped below the threshold the route is again in use and propagated. 
  • a penalty is applied on the individual path in the BGP table, not on the IP prefix. you can see the unreachable routes in the table marked with h. 
R2#show ip bgp
BGP table version is 20, local router ID is 192.168.4.2
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
              r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete

   Network          Next Hop            Metric LocPrf Weight Path
*>i1.1.1.0/24       192.168.1.1              0    100      0 i
 h 3.3.3.0/24       192.168.3.1              0             0 65300 i
*>i10.0.0.0         192.168.1.1              0    100      0 i
*> 30.0.0.0         192.168.3.1              0             0 65300 i
*> 40.0.0.0         192.168.4.1              0             0 65400 i
* i192.168.1.0      192.168.1.1              0    100      0 i
*>                  0.0.0.0                  0         32768 i
*  192.168.3.0      192.168.3.1              0             0 65300 i
*>                  0.0.0.0                  0         32768 i
*  192.168.4.0      192.168.4.1              0             0 65400 i
*>                  0.0.0.0                  0         32768 i









  • configure the topology as per the diagram
  • configure IP addresses as per the topology
  • configure iBGP and eBGP as per the topology 
  • configure BGP dampening on router 2 AS 65100
  • manually flaps the route loopback 3.3.3.3 in an AS 65300
  • make sure  3.3.3.3/24 in h state in the routing table  and dampened 







R1(config)#interface loopback 1
R1(config-if)#ip address 1.1.1.1 255.255.255.0
R1(config-if)#no shutdown
R1(config-if)#exit
R1(config)#interface fastethernet 2/0
R1(config-if)#ip address 10.1.1.1 255.0.0.0
R1(config-if)#no keepalive
R1(config-if)#no shutdown
R1(config-if)#exit
R1(config)#interface fastethernet 0/0
R1(config-if)#ip address 192.168.1.1 255.255.255.0
R1(config-if)#no shutdown
R1(config-if)#exit


R2(config)#interface fastethernet 0/0
R2(config-if)#ip address 192.168.1.2 255.255.255.0
R2(config-if)#no shutdown
R2(config-if)#exit
R2(config)#interface serial 4/0
R2(config-if)#ip address 192.168.4.2 255.255.255.0
R2(config-if)#no keepalive
R2(config-if)#no shutdown
R2(config-if)#exit
R2(config)#interface serial 4/1
R2(config-if)#ip address 192.168.3.2 255.255.255.0
R2(config-if)#no shutdown
R2(config-if)#exit



R3(config)#interface loopback 1
R3(config-if)#ip address 3.3.3.3 255.255.255.0
R3(config-if)#no shutdown
R3(config-if)#exit
R3(config)#interface fastethernet 2/0
R3(config-if)#ip address 30.1.1.1 255.0.0.0
R3(config-if)#no keepalive
R3(config-if)#no shutdown
R3(config-if)#exit
R3(config)#interface serial 4/1
R3(config-if)#ip address 192.168.3.1 255.255.255.0
R3(config-if)#no shutdown
R3(config-if)#exit


R4(config)#interface loopback 1
R4(config-if)#ip address 4.4.4.4 255.255.255.0
R4(config-if)#no shutdown
R4(config-if)#exit
R4(config)#interface fastethernet 2/0
R4(config-if)#ip address 40.1.1.1 255.0.0.0
R4(config-if)#no keepalive
R4(config-if)#no shutdown
R4(config-if)#exit
R4(config)#interface serial 4/0
R4(config-if)#ip address 192.168.4.1 255.255.255.0
R4(config-if)#no shutdown
R4(config-if)#exit



R1(config)#router bgp 65100
R1(config-router)#neighbor 192.168.1.2 remote-as 65100
R1(config-router)#network 10.0.0.0
R1(config-router)#network 1.1.1.0 mask 255.255.255.0
R1(config-router)#network 192.168.1.0 mask 255.255.255.0
R1(config-router)#no auto-summary
R1(config-router)#no synchronization
R1(config-router)#exit


R2(config)#router bgp 65100
R2(config-router)#neighbor 192.168.1.1 remote-as 65100
R2(config-router)#neighbor 192.168.4.1 remote-as 65400
R2(config-router)#neighbor 192.168.3.1 remote-as 65300
R2(config-router)#network 192.168.1.0 mask 255.255.255.0
R2(config-router)#network 192.168.3.0 mask 255.255.255.0
R2(config-router)#network 192.168.4.0 mask 255.255.255.0
R2(config-router)#neighbor 192.168.1.1 next-hop-self
R2(config-router)#bgp log-neighbor-changes
R2(config-router)#no synchronization
R2(config-router)#no auto-summary
R2(config-router)#exit


R3(config)#router bgp 65300
R3(config-router)#neighbor 192.168.3.2 remote-as 65100
R3(config-router)#network 3.3.3.0 mask 255.255.255.0
R3(config-router)#network 30.0.0.0
R3(config-router)#network 192.168.3.0 mask 255.255.255.0
R3(config-router)#bgp log-neighbor-changes
R3(config-router)#no synchronization
R3(config-router)#no auto-summary
R3(config-router)#exit

R4(config)#router bgp 65400
R4(config-router)#neighbor 192.168.4.2 remote-as 65100
R4(config-router)#network 40.0.0.0
R4(config-router)#network 4.0.0.0 mask 255.255.255.0
R4(config-router)#network 192.168.4.0 mask 255.255.255.0
R4(config-router)#no auto-summary
R4(config-router)#no synchronization
R4(config-router)#bgp log-neighbor-changes
R4(config-router)#exit


R1#show ip bgp
BGP table version is 11, local router ID is 1.1.1.1
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
              r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete

   Network          Next Hop            Metric LocPrf Weight Path
*> 1.1.1.0/24       0.0.0.0                  0         32768 i
*>i3.3.3.0/24       192.168.1.2              0    100      0 65300 i
*> 10.0.0.0         0.0.0.0                  0         32768 i
*>i30.0.0.0         192.168.1.2              0    100      0 65300 i
*>i40.0.0.0         192.168.1.2              0    100      0 65400 i
* i192.168.1.0      192.168.1.2              0    100      0 i
*>                  0.0.0.0                  0         32768 i
*>i192.168.3.0      192.168.1.2              0    100      0 i
*>i192.168.4.0      192.168.1.2              0    100      0 i



R2(config)#router bgp 65100
R2(config-router)#bgp dampening
R2(config-router)#end

R2#show ip bgp dampening parameters
 dampening 15 750 2000 60 (DEFAULT)
  Half-life time      : 15 mins       Decay Time       : 2320 secs
  Max suppress penalty: 12000         Max suppress time: 60 mins
  Suppress penalty    :  2000         Reuse penalty    : 750

R2(config)#router bgp 65100
R2(config-router)#neighbor 192.168.1.1 advertisement-interval 1


R3(config)#interface loopback 1
R3(config-if)#shutdown
R3(config-if)#no shutdown
R3(config-if)#no shutdown
R3(config-if)#shutdown
R3(config-if)#no shutdown

*Feb  4 13:14:50.315: EvD: charge penalty 1000, new accum. penalty 1000, flap count 1
*Feb  4 13:14:50.319: BGP(0): charge penalty for 3.3.3.0/24 path 65300 with half life-time 15 reuse/suppress 750/2000
*Feb  4 13:14:50.319: BGP(0): flapped 1 times since 00:00:00. New penalty is 1000
*Feb  4 13:14:50.655: EvD: accum. penalty decayed to 1000 after 0 second(s)

R2#show ip bgp dampening flap-statistics
BGP table version is 17, local router ID is 192.168.4.2
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
              r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete

   Network          From            Flaps Duration Reuse    Path
*> 3.3.3.0/24       192.168.3.1     1     00:00:39          65300

R2#show ip bgp 3.3.3.3
BGP routing table entry for 3.3.3.0/24, version 17
Paths: (1 available, best #1, table Default-IP-Routing-Table)
Flag: 0x820
  Advertised to update-groups:
     1          2
  65300
    192.168.3.1 from 192.168.3.1 (3.3.3.3)
      Origin IGP, metric 0, localpref 100, valid, external, best
      Dampinfo: penalty 936, flapped 1 times in 00:01:32

R2#show ip bgp
BGP table version is 20, local router ID is 192.168.4.2
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
              r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete

   Network          Next Hop            Metric LocPrf Weight Path
*>i1.1.1.0/24       192.168.1.1              0    100      0 i
 h 3.3.3.0/24       192.168.3.1              0             0 65300 i
*>i10.0.0.0         192.168.1.1              0    100      0 i
*> 30.0.0.0         192.168.3.1              0             0 65300 i
*> 40.0.0.0         192.168.4.1              0             0 65400 i
* i192.168.1.0      192.168.1.1              0    100      0 i
*>                  0.0.0.0                  0         32768 i
*  192.168.3.0      192.168.3.1              0             0 65300 i
*>                  0.0.0.0                  0         32768 i
*  192.168.4.0      192.168.4.1              0             0 65400 i
*>                  0.0.0.0                  0         32768 i







What is BGP Allowas-in Feature? How to configure BGP Allowas-in? GNS3

  BGP Allowas-in is a configuration option in Border Gateway Protocol (BGP) routing that allows a router to accept routes with its own AS (A...