今天来介绍一个比较复杂的CCNP知识,以4个路由器组成一个环形网来做为实例。边界网关协议(BGP)选择最佳路径总共有11个步骤,平常我们用的最多的大概是AS PATH路径属性,在没有改变其他路径属性的情况下,经过的AS越少,其路径越优。11个步骤有一个前提就是下一跳可达。如果这个前提不满足后面的路径属性也无从谈起。 拓扑图如下:
下面是4个路由器的具体的配置命令:
r1属于as1,r2属于as3,r3属于as2,r4属于as4.
r1: in e1/1 ip add 192.168.1.1 255.255.255.0 no sh in e1/2 ip add 192.168.2.1 255.255.255.0 no sh in loop 1 ip add 1.1.1.1 255.0.0.0 ip route 3.0.0.0 255.0.0.0 192.168.1.2 router bgp 1 nei 3.3.3.3 remote-as 2 nei 3.3.3.3 update-source loop 1 nei 3.3.3.3 ebgp-mutlihop 2 nei 3.3.3.3 route-map setweight in nei 192.168.2.2 remote-as 3 ip prefix-list gor3 permit 10.0.0.0/8 http://www.luyouqiwang.com/14470/ route-map setweight permit 10 match ip add prefix-list gor3 set weight 200 route-map setweight permit 20 r2: in e1/2 ip add 192.168.2.2 255.255.255.0 no sh in e1/3 ip add 192.168.4.1 255.255.255.0 no sh router bgp 3 nei 192.168.2.1 remote-as 1 nei 192.168.4.2 remote-as 4 r3: in e1/1 ip add 192.168.1.2 255.255.255.0 no sh in e1/0 ip add 192.168.3.1 255.255.255.0 no sh in loop 1 ip add 3.3.3.3 255.0.0.0 ip route 1.0.0.0 255.0.0.0 192.168.1.1 router bgp 2 nei 1.1.1.1 remote-as 1 nei 1.1.1.1 update-source loop 1 nei 1.1.1.1 ebgp-mutlihop 2 nei 192.168.3.2 remote-as 4 r4: in e1/1 ip add 192.168.3.2 255.255.255.0 no sh in e1/2 ip add 192.168.4.2 255.255.255.0 in loop 1 ip add 10.143.132.1 255.0.0.0 router bgp 4 nei 192.168.3.1 remote-as 2 nei 192.168.4.1 remote-as 3 net 10.0.0.0 记住想要使这种改变生效,必须得重置邻居关系,在这里我使用软重置。切忌在生产环境中使用硬重置,这会导致所有邻居关系中断 并重新计算路由,这在有数十万条路由条目的路由器上绝对会是个灾难,没有一个小时以上的时间路由绝对不会收敛。 我们先看看在重置以前选择的最佳路由是经过哪里。 R1#show ip bgp BGP table version is 5, local router ID is 1.1.1.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.0.0.0 3.3.3.3 0 2 4 i *> 192.168.2.2 0 3 4 i 有些东西我得解释一下,第一列的*>代表去往10.0.0.0网段选择的最佳路径是经过下一跳为192.168.2.2的r2路由器。我们看到 weight都为0,并且as path经过的数量都一样,都为2个。而路由表也体现了这一点。 R1#show ip ro 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 1.0.0.0/8 is directly connected, Loopback1 S 3.0.0.0/8 [1/0] via 192.168.1.2 B 10.0.0.0/8 [20/0] via 192.168.2.2, 00:00:49 C 192.168.1.0/24 is directly connected, Ethernet1/1 C 192.168.2.0/24 is directly connected, Ethernet1/2 注意,我软重置邻居关系。这条命令是在特权模式下打的,而不是在配置模式下。 clear ip bgp * soft 现在再看看选择的最佳路由变了。 R1#clear ip bgp * soft R1#show ip bgp BGP table version is 6, local router ID is 1.1.1.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.0.0.0 3.3.3.3 200 2 4 i * 192.168.2.2 0 3 4 i 现在选择的最佳路由为下一跳为3.3.3.3的r3路由器,而这条路由的weight值也变为我在路由映射表中设置的200了。 最后再看看路由表。 R1#show ip ro 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 1.0.0.0/8 is directly connected, Loopback1 S 3.0.0.0/8 [1/0] via 192.168.1.2 B 10.0.0.0/8 [20/0] via 3.3.3.3, 00:02:55 C 192.168.1.0/24 is directly connected, Ethernet1/1 C 192.168.2.0/24 is directly connected, Ethernet1/2 呵呵,可能有点晕。不过这些都是CCNP认证考试的必须熟悉和掌握的基础知识了,多花点时间和精力在上面,一定会有很多收获的。 |
不良信息举报Q:2000617|Archiver|ROS软路由论坛 ROSABC.com 网络方案网络工程交流
GMT+8, 2025-11-4 15:30 , Processed in 0.030483 second(s), 15 queries .
Powered by Discuz! X3.4
Copyright © 2001-2021, Tencent Cloud.