设为首页 收藏本站
查看: 1601|回复: 0

[经验分享] BGP 产生默认路由的方式

[复制链接]
累计签到:1 天
连续签到:1 天
发表于 2014-12-10 08:26:01 | 显示全部楼层 |阅读模式
wKioL1SGlVTgEgAnAAFZgQKqDJ0821.jpg

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

1、写默认路由并通告
ip route 0.0.0.0 0.0.0.0 null 0
写一条默认路由,指向空接口,并将其通告至BGP中,这样该路由器会将该默认路由通告给他的所有BGP邻居;
在R4中配置静态路由,并将其通告至BGP中,然后查看路由表情况;
1
2
3
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路由表
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
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邻居R2和R3上查看BGP路由情况如下:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
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通告默认路由:
1
2
R4(config)#router bgp 100
R4(config-router)#neighbor 45.1.1.2 default-originate



R5上查看BGP路由情况:
1
2
3
4
5
6
7
8
9
10
11
12
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命令后:
1
2
R4(config)#router bgp 100
R4(config-router)#default-information originate



在R5上查看是否收到默认路由:
1
2
3
4
5
6
7
8
9
10
11
12
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的路由情况
1
R4(config)#ip route 0.0.0.0 0.0.0.0 null 0



1
2
3
4
5
6
7
8
9
10
11
12
13
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邻居R5和IBGP邻居R2的BGP路由情况;
1
2
R4(config)#router bgp 100
R4(config-router)#redistribute static



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
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



从上可知,R5、R2都收到了默认路由,下一跳是都是R4,证明此条默认路由是R4通告过来的,就此证明default-information originate是通告给所有BGP邻居。
现在将R4上的default-information originate命令no掉,但重分布静态默认路由的配置保持不会,并增加一条静态路由,再次在R4和R5上查看BGP路由情况;
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
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路由情况
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
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邻居。


运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-37680-1-1.html 上篇帖子: 思科设备实现运营商城域网架构ISIS+BGP+IPV6综合实验 下篇帖子: 查看数据包在internet网的那个设备被丢弃
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表