Friday, March 15, 2013

BGP; Why we need to create static route to advertise a network?


Before BGP advertised its network, it checks the forwarding table for an exact match of network number and mask on router’s routing table.

R1 is expected to advertise network 128.20.0.0/16 and 10.10.10.0/24 to R2 using this configuration
router bgp 1
no auto-summary
network 128.20.0.0 mask 255.255.0.0
network 10.10.10.0 mask 255.255.255.0
However, when we check on R1, it is only 128.20.0.0 network that is being advertised.
R1#sh ip bgp    
BGP table version is 2, local router ID is 192.22.11.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
*> 128.20.0.0       0.0.0.0                  0         32768 i

R1#sh ip route
Codes: C - connected, S - static, R - RIP, M - mobile, B - BGP
       D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area 
       N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
       E1 - OSPF external type 1, E2 - OSPF external type 2
       i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
       ia - IS-IS inter area, * - candidate default, U - per-user static route
       o - ODR, P - periodic downloaded static route

Gateway of last resort is not set

C    128.20.0.0/16 is directly connected, Loopback0
C    192.168.20.0/24 is directly connected, Serial1/0.601
Also in R2, we only see network 128.20.0.0.
R2#sh ip bgp
BGP table version is 19, local router ID is 192.168.20.21
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
*> 128.20.0.0       192.168.20.20            0             0 20 i

R2#sh ip route
Codes: C - connected, S - static, R - RIP, M - mobile, B - BGP
       D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area 
       N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
       E1 - OSPF external type 1, E2 - OSPF external type 2
       i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
       ia - IS-IS inter area, * - candidate default, U - per-user static route
       o - ODR, P - periodic downloaded static route

Gateway of last resort is not set

B    128.20.0.0/16 [20/0] via 192.168.20.20, 00:06:58
C    192.168.20.0/24 is directly connected, Serial1/0.106
Aren’t 10.10.10.0/24 supposed to be advertised like 128.20.0.0/16?
Apparently NOT!
Why network 128.20.0.0/16 is being advertised? It is because network 128.20.0.0/16 has entry on router’s routing table and 10.10.10.0/24 is not.
R1#sh ip route
Codes: C - connected, S - static, R - RIP, M - mobile, B - BGP
       D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area 
       N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
       E1 - OSPF external type 1, E2 - OSPF external type 2
       i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
       ia - IS-IS inter area, * - candidate default, U - per-user static route
       o - ODR, P - periodic downloaded static route

Gateway of last resort is not set

C    128.20.0.0/16 is directly connected, Loopback0
C    192.168.20.0/24 is directly connected, Serial1/0.601
Again, on the first paragraph of this article, it’s stated:
Before BGP advertised its network, it checks the forwarding table for an exact match of network number and mask on router’s routing table.
Therefore, as no entry for 10.10.10.0/24 on the routing table, the network will not be advertised.
The solution is, if we want to include network 10.10.10.0/24 to be advertised, make sure that R1 has a component route for network 10.10.10.0/24 either by learning it through IGP or through static configuration. In the example shown, the static route is configured to null 0.
ip route 10.10.10.0 255.255.255.0 null 0
Now, let’s check the routing table on both R1 and R2.
R1#sh ip bgp
BGP table version is 3, local router ID is 192.22.11.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.10.10.0/24    0.0.0.0                  0         32768 i
*> 128.20.0.0       0.0.0.0                  0         32768 i

R1#sh ip route
Codes: C - connected, S - static, R - RIP, M - mobile, B - BGP
       D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area 
       N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
       E1 - OSPF external type 1, E2 - OSPF external type 2
       i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
       ia - IS-IS inter area, * - candidate default, U - per-user static route
       o - ODR, P - periodic downloaded static route

Gateway of last resort is not set

C    128.20.0.0/16 is directly connected, Loopback0
     10.0.0.0/24 is subnetted, 1 subnets
S       10.10.10.0 is directly connected, Null0


R2#sh ip bgp
BGP table version is 24, local router ID is 192.168.20.21
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.10.10.0/24    192.168.20.20            0             0 20 i
*> 128.20.0.0       192.168.20.20            0             0 20 i

R2#sh ip route
Codes: C - connected, S - static, R - RIP, M - mobile, B - BGP
       D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area 
       N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
       E1 - OSPF external type 1, E2 - OSPF external type 2
       i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
       ia - IS-IS inter area, * - candidate default, U - per-user static route
       o - ODR, P - periodic downloaded static route

Gateway of last resort is not set

B    128.20.0.0/16 [20/0] via 192.168.20.20, 00:01:12
     10.0.0.0/24 is subnetted, 1 subnets
B       10.10.10.0 [20/0] via 192.168.20.20, 00:01:12
NOTE. There is actually another way to do this. You can replace network 128.20.0.0 mask 255.255.0.0 with redistribute connected and replace network 10.10.10.0 mask 255.255.255.0with redistribute static. But still, you need to create a static routing for network 10.10.10.0/16 so that BGP able to see it from the routing table

No comments:

Post a Comment