wKioL1SGlVTgEgAnAAFZgQKqDJ0821.jpg


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


1、写默认路由并通告

ip route 0.0.0.0 0.0.0.0 null 0

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

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

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

EBGP邻居R5上查看BGP路由表

R5#show ip route bgp
Codes: L - local, 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, H - NHRP, l - LISP
       + - replicated route, % - next hop override
 
Gateway of last resort is 45.1.1.1 to network 0.0.0.0
 
B*    0.0.0.0/0 [20/0] via 45.1.1.1, 00:03:01
      1.0.0.0/32 is subnetted, 1 subnets
B        1.1.1.1 [20/0] via 45.1.1.1, 00:02:33

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

R3#show ip route bgp 
Codes: L - local, 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, H - NHRP, l - LISP
       + - replicated route, % - next hop override
Gateway of last resort is 34.1.1.2 to network 0.0.0.0
B*    0.0.0.0/0 [200/0] via 34.1.1.2, 00:04:01
      1.0.0.0/32 is subnetted, 1 subnets
B        1.1.1.1 [200/0] via 23.1.1.1, 00:03:12
      5.0.0.0/32 is subnetted, 1 subnets
B        5.5.5.5 [200/0] via 34.1.1.2, 00:21:43
      55.0.0.0/32 is subnetted, 1 subnets
B        55.5.5.5 [200/0] via 34.1.1.2, 00:21:44

R2#show ip route bgp
Codes: L - local, 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, H - NHRP, l - LISP
       + - replicated route, % - next hop override
Gateway of last resort is 4.4.4.4 to network 0.0.0.0
B*    0.0.0.0/0 [200/0] via 4.4.4.4, 00:04:44
      1.0.0.0/32 is subnetted, 1 subnets
B        1.1.1.1 [20/0] via 12.1.1.1, 00:03:54
      5.0.0.0/32 is subnetted, 1 subnets
B        5.5.5.5 [200/0] via 4.4.4.4, 00:17:20
      55.0.0.0/32 is subnetted, 1 subnets
B        55.5.5.5 [200/0] via 4.4.4.4, 00:17:20

  2、neighbor X.X.X.X default-originate 

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

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

R5上查看BGP路由情况:

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

3、 default-information originate

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

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

R4(config)#router bgp 100
R4(config-router)#default-information originate

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

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

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

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

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

R4(config)#router bgp 100
R4(config-router)#redistribute static
R5#show ip bgp 
BGP table version is 62, local router ID is 5.5.5.5
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal, 
              r RIB-failure, S Stale, m multipath, b backup-path, f RT-Filter, 
              x best-external, a additional-path, c RIB-compressed, 
Origin codes: i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V valid, I invalid, N Not found
 
     Network          Next Hop            Metric LocPrf Weight Path
 *>  0.0.0.0          45.1.1.1                 0             0 100 ?
 *>  1.1.1.1/32       45.1.1.1                               0 100 10 i
 *>  5.5.5.5/32       0.0.0.0                  0         32768 i
 *>  55.5.5.5/32      0.0.0.0                  0         32768 i
 
R2#show ip bgp
BGP table version is 23, local router ID is 2.2.2.2
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal, 
              r RIB-failure, S Stale, m multipath, b backup-path, f RT-Filter, 
              x best-external, a additional-path, c RIB-compressed, 
Origin codes: i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V valid, I invalid, N Not found
 
     Network          Next Hop            Metric LocPrf Weight Path
 *>i 0.0.0.0          4.4.4.4                  0    100      0 ?
 *>  1.1.1.1/32       12.1.1.1                 0             0 10 i
 *>i 5.5.5.5/32       4.4.4.4                  0    100      0 50 i
 *>i 55.5.5.5/32      4.4.4.4                  0    100      0 50 i

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

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

R4(config)#router bgp 100
R4(config-router)#no default-information originate
R4(config)#ip route 44.1.1.1 255.255.255.255 null 0
R4(config)#ip route 0.0.0.0 0.0.0.0 Null0

R4#show runn | se router bgp
router bgp 100
 bgp log-neighbor-changes
 redistribute static
 neighbor 2.2.2.2 remote-as 100
 neighbor 2.2.2.2 update-source Loopback0
 neighbor 2.2.2.2 next-hop-self
 neighbor 34.1.1.1 remote-as 100
 neighbor 34.1.1.1 next-hop-self
 neighbor 45.1.1.2 remote-as 50

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

R4# show ip bgp
BGP table version is 15, 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, m multipath, b backup-path, f RT-Filter, 
              x best-external, a additional-path, c RIB-compressed, 
Origin codes: i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V valid, I invalid, N Not found
 
     Network          Next Hop            Metric LocPrf Weight Path
 *>i 1.1.1.1/32       2.2.2.2                  0    100      0 10 i
 *>  5.5.5.5/32       45.1.1.2                 0             0 50 i
 *>  44.1.1.1/32      0.0.0.0                  0         32768 ?
 *>  55.5.5.5/32      45.1.1.2                 0             0 50 i 
 
R5#show ip bgp 
BGP table version is 64, local router ID is 5.5.5.5
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal, 
              r RIB-failure, S Stale, m multipath, b backup-path, f RT-Filter, 
              x best-external, a additional-path, c RIB-compressed, 
Origin codes: i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V valid, I invalid, N Not found
 
     Network          Next Hop            Metric LocPrf Weight Path
 *>  1.1.1.1/32       45.1.1.1                               0 100 10 i
 *>  5.5.5.5/32       0.0.0.0                  0         32768 i
 *>  44.1.1.1/32      45.1.1.1                 0             0 100 ?
 *>  55.5.5.5/32      0.0.0.0                  0         32768 i

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

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