BGP 產生默認路由的方式

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鄰居。




發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章