A-A+

BGP 产生默认路由的方式

2015年12月29日 路由器高级应用 暂无评论 阅读 2 views 次

拓扑图如上,基本配置略;

1、写默认路由并通告

ip route 0.0.0.0 0.0.0.0 null 0

写一条默认路由,指向空接口,并将其通告至BGP中,这样该路由器会将该默认路由通告给他的所有BGP邻居;

在R4中配置静态路由,并将其通告至BGP中,然后查看路由表情况;

  1. R4(config)#ip route 0.0.0.0 0.0.0.0 null 0  
  2. R4(config)#router bgp 100  
  3. R4(config-router)#network 0.0.0.0 mask 0.0.0.0 //通告默认路由  

在EBGP邻居R5上查看BGP路由表

  1. R5#show ip route bgp  
  2. Codes: L - local, C - connected, S - static, R - RIP, M - mobile, B - BGP  
  3.        D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area   
  4.        N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2  
  5.        E1 - OSPF external type 1, E2 - OSPF external type 2  
  6.        i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2  
  7.        ia - IS-IS inter area, * - candidate default, U - per-user static route  
  8.        o - ODR, P - periodic downloaded static route, H - NHRP, l - LISP  
  9.        + - replicated route, % - next hop override  
  10.     
  11. Gateway of last resort is 45.1.1.1 to network 0.0.0.0  
  12.     
  13. B*    0.0.0.0/0 [20/0] via 45.1.1.1, 00:03:01   
  14.       1.0.0.0/32 is subnetted, 1 subnets  
  15. B        1.1.1.1 [20/0] via 45.1.1.1, 00:02:33  

然后在IBGP邻居R2和R3上查看BGP路由情况如下:

  1. R3#show ip route bgp   
  2. Codes: L - local, C - connected, S - static, R - RIP, M - mobile, B - BGP  
  3.        D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area   
  4.        N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2  
  5.        E1 - OSPF external type 1, E2 - OSPF external type 2  
  6.        i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2  
  7.        ia - IS-IS inter area, * - candidate default, U - per-user static route  
  8.        o - ODR, P - periodic downloaded static route, H - NHRP, l - LISP  
  9.        + - replicated route, % - next hop override  
  10. Gateway of last resort is 34.1.1.2 to network 0.0.0.0  
  11. B*    0.0.0.0/0 [200/0] via 34.1.1.2, 00:04:01  
  12.       1.0.0.0/32 is subnetted, 1 subnets  
  13.   
  14.   
  15. B        1.1.1.1 [200/0] via 23.1.1.1, 00:03:12  
  16.       5.0.0.0/32 is subnetted, 1 subnets  
  17. B        5.5.5.5 [200/0] via 34.1.1.2, 00:21:43  
  18.       55.0.0.0/32 is subnetted, 1 subnets  
  19. B        55.5.5.5 [200/0] via 34.1.1.2, 00:21:44  
  20.    
  21. R2#show ip route bgp  
  22. Codes: L - local, C - connected, S - static, R - RIP, M - mobile, B - BGP  
  23.        D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area   
  24.        N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2  
  25.        E1 - OSPF external type 1, E2 - OSPF external type 2  
  26.        i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2  
  27.        ia - IS-IS inter area, * - candidate default, U - per-user static route   
  28.        o - ODR, P - periodic downloaded static route, H - NHRP, l - LISP  
  29.        + - replicated route, % - next hop override  
  30. Gateway of last resort is 4.4.4.4 to network 0.0.0.0  
  31. B*    0.0.0.0/0 [200/0] via 4.4.4.4, 00:04:44  
  32.       1.0.0.0/32 is subnetted, 1 subnets  
  33. B        1.1.1.1 [20/0] via 12.1.1.1, 00:03:54  
  34.       5.0.0.0/32 is subnetted, 1 subnets  
  35. B        5.5.5.5 [200/0] via 4.4.4.4, 00:17:20  
  36.       55.0.0.0/32 is subnetted, 1 subnets  
  37. B        55.5.5.5 [200/0] via 4.4.4.4, 00:17:20  
  38.   2、neighbor X.X.X.X default-originate   

给邻居通告默认路由,在指定邻居路由器会收到一条默认路由,没有指定的,不会收到默认路由,在R4上配置给R5通告默认路由:

  1. R4(config)#router bgp 100  
  2. R4(config-router)#neighbor 45.1.1.2 default-originate  

R5上查看BGP路由情况:

  1. R5#show ip bgp   
  2. BGP table version is 47, local router ID is 5.5.5.5  
  3. Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,   
  4.               r RIB-failure, S Stale, m multipath, b backup-path, f RT-Filter,   
  5.               x best-external, a additional-path, c RIB-compressed,   
  6. Origin codes: i - IGP, e - EGP, ? - incomplete  
  7. RPKI validation codes: V valid, I invalid, N Not found  
  8.     
  9.      Network          Next Hop            Metric LocPrf Weight Path  
  10.  *>  0.0.0.0          45.1.1.1                               0 100 i  
  11.   
  12.   
  13.  *>  5.5.5.5/32       0.0.0.0                  0         32768 i  
  14.  *>  55.5.5.5/32      0.0.0.0                  0         32768 i  
  15. 3、 default-information originate  

对所有邻居都通告默认路由,但这种方式有一点特殊,下面通过配置分析来解释;

首先我们在R4上配置default-information originate命令后:

R4(config)#router bgp 100

R4(config-router)#default-information originate

在R5上查看是否收到默认路由:

  1. R5#show ip bgp  
  2. BGP table version is 55, local router ID is 5.5.5.5  
  3. Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,   
  4.               r RIB-failure, S Stale, m multipath, b backup-path, f RT-Filter,   
  5.               x best-external, a additional-path, c RIB-compressed,   
  6. Origin codes: i - IGP, e - EGP, ? - incomplete  
  7. RPKI validation codes: V valid, I invalid, N Not found  
  8.     
  9.      Network          Next Hop            Metric LocPrf Weight Path  
  10.  *>  1.1.1.1/32       45.1.1.1                               0 100 10 i  
  11.   
  12.   
  13.  *>  5.5.5.5/32       0.0.0.0                  0         32768 i  
  14.  *>  55.5.5.5/32      0.0.0.0                  0         32768 i  

从上可知,并没有收到默认路由,现在我们在R4上配置一条默认路由并指向空接口,再次查看R5的路由情况

  1. R4(config)#ip route 0.0.0.0 0.0.0.0 null 0  
  2.   
  3. R5#clear ip bgp * soft  
  4. R5#show ip bgp   
  5. BGP table version is 55, local router ID is 5.5.5.5  
  6. Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,   
  7.               r RIB-failure, S Stale, m multipath, b backup-path, f RT-Filter,   
  8.               x best-external, a additional-path, c RIB-compressed,   
  9. Origin codes: i - IGP, e - EGP, ? - incomplete  
  10. RPKI validation codes: V valid, I invalid, N Not found  
  11.     
  12.      Network          Next Hop            Metric LocPrf Weight Path  
  13.  *>  1.1.1.1/32       45.1.1.1                               0 100 10 i   
  14.  *>  5.5.5.5/32       0.0.0.0                  0         32768 i  
  15.  *>  55.5.5.5/32      0.0.0.0                  0         32768 i  

从输出可知,R5还是没有收到默认路由,现将所写的静态默认路由重分布至BGP中,再次查看EBGP邻居R5和IBGP邻居R2的BGP路由情况;

  1. R4(config)#router bgp 100  
  2. R4(config-router)#redistribute static  
  3.   
  4. R5#show ip bgp   
  5. BGP table version is 62, local router ID is 5.5.5.5  
  6. Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,   
  7.               r RIB-failure, S Stale, m multipath, b backup-path, f RT-Filter,   
  8.               x best-external, a additional-path, c RIB-compressed,   
  9. Origin codes: i - IGP, e - EGP, ? - incomplete  
  10. RPKI validation codes: V valid, I invalid, N Not found  
  11.     
  12.      Network          Next Hop            Metric LocPrf Weight Path  
  13.  *>  0.0.0.0          45.1.1.1                 0             0 100 ?  
  14.   
  15.   
  16.  *>  1.1.1.1/32       45.1.1.1                               0 100 10 i  
  17.  *>  5.5.5.5/32       0.0.0.0                  0         32768 i  
  18.  *>  55.5.5.5/32      0.0.0.0                  0         32768 i  
  19.     
  20. R2#show ip bgp  
  21. BGP table version is 23, local router ID is 2.2.2.2  
  22. Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,   
  23.               r RIB-failure, S Stale, m multipath, b backup-path, f RT-Filter,   
  24.               x best-external, a additional-path, c RIB-compressed,   
  25. Origin codes: i - IGP, e - EGP, ? - incomplete  
  26. RPKI validation codes: V valid, I invalid, N Not found  
  27.     
  28.      Network          Next Hop            Metric LocPrf Weight Path  
  29.  *>i 0.0.0.0          4.4.4.4                  0    100      0 ?  
  30.  *>  1.1.1.1/32       12.1.1.1                 0             0 10 i  
  31.  *>i 5.5.5.5/32       4.4.4.4                  0    100      0 50 i   
  32.  *>i 55.5.5.5/32      4.4.4.4                  0    100      0 50 i  

从上可知,R5、R2都收到了默认路由,下一跳是都是R4,证明此条默认路由是R4通告过来的,就此证明default-information originate是通告给所有BGP邻居。

现在将R4上的default-information originate命令no掉,但重分布静态默认路由的配置保持不会,并增加一条静态路由,再次在R4和R5上查看BGP路由情况;

  1. R4(config)#router bgp 100  
  2. R4(config-router)#no default-information originate  
  3. R4(config)#ip route 44.1.1.1 255.255.255.255 null 0  
  4. R4(config)#ip route 0.0.0.0 0.0.0.0 Null0  
  5.    
  6. R4#show runn | se router bgp  
  7. router bgp 100  
  8.  bgp log-neighbor-changes  
  9.  redistribute static  
  10.  neighbor 2.2.2.2 remote-as 100  
  11.  neighbor 2.2.2.2 update-source Loopback0  
  12.  neighbor 2.2.2.2 next-hop-self  
  13.  neighbor 34.1.1.1 remote-as 100  
  14.  neighbor 34.1.1.1 next-hop-self  
  15.  neighbor 45.1.1.2 remote-as 50  

在R4和R5上查看BGP路由情况

  1. R4# show ip bgp  
  2. BGP table version is 15, local router ID is 4.4.4.4  
  3. Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,   
  4.               r RIB-failure, S Stale, m multipath, b backup-path, f RT-Filter,   
  5.               x best-external, a additional-path, c RIB-compressed,   
  6. Origin codes: i - IGP, e - EGP, ? - incomplete  
  7. RPKI validation codes: V valid, I invalid, N Not found  
  8.     
  9.      Network          Next Hop            Metric LocPrf Weight Path  
  10.  *>i 1.1.1.1/32       2.2.2.2                  0    100      0 10 i  
  11.   
  12.   
  13.  *>  5.5.5.5/32       45.1.1.2                 0             0 50 i  
  14.  *>  44.1.1.1/32      0.0.0.0                  0         32768 ?  
  15.  *>  55.5.5.5/32      45.1.1.2                 0             0 50 i   
  16.     
  17. R5#show ip bgp   
  18. BGP table version is 64, local router ID is 5.5.5.5  
  19. Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,   
  20.               r RIB-failure, S Stale, m multipath, b backup-path, f RT-Filter,   
  21.               x best-external, a additional-path, c RIB-compressed,   
  22. Origin codes: i - IGP, e - EGP, ? - incomplete  
  23. RPKI validation codes: V valid, I invalid, N Not found  
  24.     
  25.      Network          Next Hop            Metric LocPrf Weight Path  
  26.  *>  1.1.1.1/32       45.1.1.1                               0 100 10 i  
  27.  *>  5.5.5.5/32       0.0.0.0                  0         32768 i  
  28.  *>  44.1.1.1/32      45.1.1.1                 0             0 100 ?   
  29.  *>  55.5.5.5/32      0.0.0.0                  0         32768 i  

从上面输出可知,并没有默认路由,而收到了44.1.1.1/32的路由,从此可得出的结论:在重分布静态路由至BGP中时,并不会重分布默认路由。

总结:在BGP中配置default-information originate时,必须先创建一条静态的默认路由,并且重分布静态至BGP中,才会产生默认路由,并通告给其它的BGP邻居。

标签:

给我留言