Saturday, 1 February 2020

AS pathloop in BGP




Initial configuration on each routers. As below:

R1#sh ip int br | e una
Interface                  IP-Address      OK? Method Status      Protocol
Serial1/0                  11.0.0.2        YES manual up                    up
Serial1/1                  11.0.0.6        YES manual up                    up
Serial1/2                  10.0.0.1        YES manual up                    up
Loopback0               1.1.1.1         YES manual up                    up


R2#sh ip int br | e una
Interface                  IP-Address      OK? Method Status    Protocol
Serial1/0                  10.0.0.2        YES manual up                    up
Serial1/1                  10.0.0.5        YES manual up                    up
Loopback0               2.2.2.2         YES manual up                    up

R3#sh ip int br | e una
Interface                  IP-Address      OK? Method Status       Protocol
Serial1/0                  10.0.0.6        YES manual up                    up
Serial1/1                  10.0.0.9        YES manual up                    up
Loopback0               3.3.3.3         YES manual up                    up
R4#sh ip int br | e una
Interface                  IP-Address      OK? Method Status        Protocol
Serial1/0                  10.0.0.10       YES manual up                    up
Serial1/1                  11.0.0.9        YES manual up                    up
Serial1/2                  11.0.0.13       YES manual up                    up
Loopback0                  4.4.4.4         YES manual up                    up

R5#sh ip int b | e una
Interface                  IP-Address      OK? Method Status        Protocol
Serial1/0                     11.0.0.10       YES manual up                    up
Loopback0                  50.0.0.1        YES manual up                    up
Loopback1                  50.1.1.1        YES manual up                    up
Loopback2                  50.2.2.1        YES manual up                    up
R6#sh ip int b | e una
Interface                  IP-Address      OK? Method Status                Protocol
Serial1/0                    11.0.0.14       YES manual up                    up
Loopback0                  60.0.0.1        YES manual up                    up
Loopback1                  60.1.1.1        YES manual up                    up
Loopback2                  60.2.2.1        YES manual up                    up

R7#sh ip int b | e una
Interface                  IP-Address      OK? Method Status                Protocol
Serial1/0                     11.0.0.1        YES manual up                    up
Loopback0                  70.0.0.1        YES manual up                    up
Loopback1                  70.1.1.1        YES manual up                    up
Loopback2                  70.2.2.1        YES manual up                    up
R8#sh ip int b | e una
Interface                  IP-Address      OK? Method Status                Protocol
Serial1/0                     11.0.0.5        YES manual up                    up
Loopback0                  80.0.0.1        YES manual up                    up
Loopback1                  80.1.1.1        YES manual up                    up
Loopback2                  80.2.2.1        YES manual up                    up

Here as shown in the figure I have created a VRF and MP-BGP.

Now am going to run BGP as PE-CE routing.

R1(config)#router bgp 100
R1(config-router)#address-family ipv4 vrf A
R1(config-router-af)#neighbor 11.0.0.5 remote-as 65031

R7(config)#router bgp 65031
R7(config-router)#neighbor 11.0.0.6 remote-as 100
R7(config-router)#network 70.0.0.0 mask 255.255.255.0

Now check the bgp peer state.
R7#sh ip bgp su | be Ne
Neighbor        V    AS MsgRcvd MsgSent   TblVer  InQ OutQ Up/Down  State/PfxRcd
11.0.0.6        4   100      11      12        2    0    0 00:07:19        0

R1#sh ip bgp vpnv4 vrf A summary | be Ne
Neighbor        V    AS MsgRcvd MsgSent   TblVer  InQ OutQ Up/Down  State/PfxRcd
11.0.0.5        4 65031      13      12        2    0    0 00:08:02        1

As we know 70.0.0.0/24 network we published in BGP R1 receiving it. In BGP we don’t need to redistribute the VPNv4 prefix into BGP since it’s a automatic process.
Therefore lets check o R4.
R4#sh ip bgp vpnv4 vrf A
BGP table version is 3, local router ID is 4.4.4.4
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
Route Distinguisher: 500:5 (default for vrf A)
*>i70.0.0.0/24      1.1.1.1                  0    100      0 65031 i

Ahhh as we guessed we are getting the prefix now lets run BGP between PE-CE router.

R4(config)#router bgp 100
R4(config-router)#address-family ipv4 vrf A
R4(config-router-af)#neighbor 11.0.0.10 remote-as 65031

R5(config)#router bgp 65031
R5(config-router)#neighbor 11.0.0.9 remot 100

Lets check the BGP neighborship

R5#sh ip bgp su | be Ne
Neighbor        V    AS MsgRcvd MsgSent   TblVer  InQ OutQ Up/Down  State/PfxRcd
11.0.0.9        4   100       5       4        1    0    0 00:00:55        0

Cool we formed neighborship between PE-CE routers. Now lets check for the prefix 70.0.0.0/24
R5#sh ip route 70.0.0.0
% Network not in table
R5#sh ip bgp

R5#

Strange we are not getting the prefix but on R4 we have the prefix.
Lets run the debug

R5#debug ip bgp ipv4 unicast updates in
BGP updates debugging is on (inbound) for address family: IPv4 Unicast

BGP(0): 11.0.0.9 rcv UPDATE w/ attr: nexthop 11.0.0.9, origin i, originator 0.0.0.0, path 100 65031, community , extended community
BGP(0): 11.0.0.9 rcv UPDATE about 70.0.0.0/24 -- DENIED due to: AS-PATH contains our own AS;

See, Yes BGP AS-Path attribute detecting the LOOP and R5 not installing the prefix. To overcome this problem we have two options

Option 1:
Allow As-in

R5(config)#router bgp 65031
R5(config-router)#neighbor 11.0.0.9 allowas-in ?
  <1-10>  Number of occurances of AS number
  <cr>
R5(config-router)#neighbor 11.0.0.9 allowas-in 1

R5#sh ip route bgp
     70.0.0.0/24 is subnetted, 1 subnets
B       70.0.0.0 [20/0] via 11.0.0.9, 00:00:31

R5#sh ip bgp
BGP table version is 2, local router ID is 50.2.2.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
*> 70.0.0.0/24      11.0.0.9                               0 100 65031 i

Option 2:
Autonomous System Override
To work on this am going to publish the network 50.0.0.0/24 in BGP on R5.

R5(config)#router bgp 65031
R5(config-router)#network 50.0.0.0 mask 255.255.255.0

R1#sh ip bgp vpnv4 vrf A
BGP table version is 4, 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
Route Distinguisher: 700:7 (default for vrf A)
*>i50.0.0.0/24      4.4.4.4                  0    100      0 65031 i
*> 70.0.0.0/24      11.0.0.5                 0             0 65031 i
R1#

So prefix reached till R1 as we already aware of this problem that R7 will not take this prefix as AS-Path loop. Lets check and confirm it.
R7#sh ip route bgp

R7#

R1(config)#router bgp 100
R1(config-router)#address-family ipv4 vrf A
R1(config-router-af)#neighbor 11.0.0.5 as-override

R7#sh ip route bgp
     50.0.0.0/24 is subnetted, 1 subnets
B       50.0.0.0 [20/0] via 11.0.0.6, 00:01:25

R7#sh ip bgp
BGP table version is 3, local router ID is 70.2.2.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
*> 50.0.0.0/24      11.0.0.6                               0 100 100 i
*> 70.0.0.0/24      0.0.0.0                  0         32768 i

Note: This command will work on PE and see the AS path its duplicated with the SP AS num.

No comments:

Post a Comment