思科内部资料BGP-基础实验

更新时间:2024-05-23 18:13:01 阅读量: 综合文库 文档下载

说明:文章内容仅供预览,部分内容可能不全。下载后的文档,内容与下面显示的完全一致。下载之前请确认下面内容是否您想要的,是否完整无缺。

BGP

目录

BGP基础实验 ................................................................................................................................... 2 BGP 路由聚合 ................................................................................................................................ 55 BGP 默认路由 ................................................................................................................................ 73 BGP 路由过滤 ................................................................................................................................ 75 BGP条件路由 ................................................................................................................................. 82 BGP Peer Group .............................................................................................................................. 87 BGP Community .............................................................................................................................. 98 BGP Reflector(BGP反射器) .......................................................................................................... 125 BGP Confederation(BGP联邦) ...................................................................................................... 143 BGP 后门路由 .............................................................................................................................. 161 BGP Dampening ............................................................................................................................ 172 BGP重分布进IGP ........................................................................................................................ 184

第1页共191页

BGP基础实验

说明:

上图中所有路由器都配有Loopback地址,地址分别为:

R1 Loopback 0 1.1.1.1/32 Loopback 11 11.1.1.1/24 R2 Loopback 0 2.2.2.2/32 Loopback 22 22.2.2.2/24 R3 Loopback 0 3.3.3.3/32 Loopback 33 33.3.3.3/24 R4 Loopback 0 4.4.4.4/32 Loopback 44 44.4.4.4/24

所有路由器之间运行OSPF,并将Loopback 0的地址发布到OSPF中,保证全网Loopback 0之间是可以通信的,以此来作为BGP的连接地址。

1.IGP使全网Loopback 0互通

第2页共191页

说明:使用OSPF保证Loopback 0之间的通信,从而建立BGP连接。

(1)配置各路由器的OSPF R1:

r1(config)#router ospf 1

r1(config-router)#router-id 1.1.1.1

r1(config-router)#network 12.1.1.1 0.0.0.0 area 0 r1(config-router)#network 13.1.1.1 0.0.0.0 area 0 r1(config-router)#network 1.1.1.1 0.0.0.0 area 0 R2:

r2(config)#router ospf 1

r2(config-router)#router-id 2.2.2.2

r2(config-router)#network 12.1.1.2 0.0.0.0 area 0 r2(config-router)#network 24.1.1.2 0.0.0.0 area 0 r2(config-router)#network 2.2.2.2 0.0.0.0 area 0 R3:

r3(config)#router ospf 1

r3(config-router)#router-id 3.3.3.3

r3(config-router)#network 13.1.1.3 0.0.0.0 area 0 r3(config-router)#network 34.1.1.3 0.0.0.0 area 0

第3页共191页

r3(config-router)#network 3.3.3.3 0.0.0.0 area 0 R4:

r4(config)#router ospf 1

r4(config-router)#router-id 4.4.4.4

r4(config-router)#network 24.1.1.4 0.0.0.0 area 0 r4(config-router)#network 34.1.1.4 0.0.0.0 area 0 r4(config-router)#network 4.4.4.4 0.0.0.0 area 0

说明:发布各路由器的直连网段与Loopback 0到OSPF中。

2.检查IGP连接

(1)检查R1上的OSPF邻居 r1#show ip ospf neighbor

Neighbor ID Pri State Dead Time Address Interface

3.3.3.3 1 FULL/BDR 00:00:34 13.1.1.3 FastEthernet0/1

2.2.2.2 1 FULL/BDR 00:00:38 12.1.1.2 FastEthernet0/0 r1#

说明:R1与R2和R3的OSPF邻居正常。

第4页共191页

(2)检查R4上的OSPF邻居 r4#show ip ospf neighbor

Neighbor ID Pri State Dead Time Address Interface

3.3.3.3 1 FULL/DR 00:00:34 34.1.1.3 FastEthernet0/0

2.2.2.2 1 FULL/DR 00:00:29 24.1.1.2 FastEthernet0/1 r4#

说明:R4与R2和R3的OSPF邻居正常。

(3)在R1上查看全网的loopback 0 通信情况 r1#ping 2.2.2.2 source loopback 0

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 2.2.2.2, timeout is 2 seconds: Packet sent with a source address of 1.1.1.1 !!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 1/2/4 ms r1#

r1#ping 3.3.3.3 source loopback 0

第5页共191页

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 3.3.3.3, timeout is 2 seconds: Packet sent with a source address of 1.1.1.1 !!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 1/2/4 ms r1#ping 4.4.4.4 source loopback 0

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 4.4.4.4, timeout is 2 seconds: Packet sent with a source address of 1.1.1.1 !!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 1/2/4 ms r1#

说明:全网的loopback 0 通信正常,可以用此地址建立BGP连接。

3.建立BGP邻居

(1)在R1与R2之间建立BGP邻居 r1(config)#router bgp 1

r1(config-router)#bgp router-id 1.1.1.1 r1(config-router)#neighbor 2.2.2.2 remote-as 1

说明:配置R1的Router-ID,并指定邻居为2.2.2.2,邻居AS为1。

第6页共191页

(2)在R1与R2之间建立BGP邻居 r2(config)#router bgp 1

r2(config-router)#bgp router-id 2.2.2.2 r2(config-router)#neighbor 1.1.1.1 remote-as 1

说明:配置R2的Router-ID,并指定邻居为1.1.1.1,邻居AS为1。

(3)查看BGP邻居 r1#show ip bgp summary

BGP router identifier 1.1.1.1, local AS number 1 BGP table version is 1, main routing table version 1

Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd

2.2.2.2 4 1 0 0 0 0 0 never Active r1#

说明:R1无法与R2建立BGP邻居,因为自己目的地址是2.2.2.2,而对方源地

址是12.1.1.2,同样对方目的是1.1.1.1,而自己源是12.1.1.1,源与目的不匹配,所以必须修改。

(4)修改R1的BGP源地址 r1(config)#router bgp 1

r1(config-router)#neighbor 2.2.2.2 update-source loopback 0

第7页共191页

说明:将R1的源地址改为loopback 0,即1.1.1.1,而R2的目标地址也是

1.1.1.1,与R1的源相同。

(5)查看R1的BGP邻居 r1#show ip bgp summary

BGP router identifier 1.1.1.1, local AS number 1 BGP table version is 1, main routing table version 1

Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd

2.2.2.2 4 1 9 9 1 0 0 00:05:43 0 r1#

说明:因为R1的源与R2的目的相匹配,所以双方正常建立BGP邻居。

(6)修改R2的BGP源地址 r2(config)#router bgp 1

r2(config-router)#neighbor 1.1.1.1 update-source loopback 0

说明:虽然R1的源与R2的目的相匹配,已正常建立BGP邻居,但为了统一,也

配置使R2的源与R1的目的相匹配。

4.建立R2与R4的BGP邻居

(1)配置R2的BGP参数

第8页共191页

r2(config)#router bgp 1

r2(config-router)#neighbor 4.4.4.4 remote-as 4

r2(config-router)#neighbor 4.4.4.4 update-source loopback 0

说明:在R2上指定邻居为4.4.4.4,邻居AS为4,并且R2的源为loopback 0,

即2.2.2.2。

(2)配置R4的BGP参数 r4(config)#router bgp 4

r4(config-router)#bgp router-id 4.4.4.4 r4(config-router)#neighbor 2.2.2.2 remote-as 1

r4(config-router)#neighbor 2.2.2.2 update-source loopback 0

说明:配置R4的Router-ID,并指定邻居为2.2.2.2,邻居AS为1,R4的源地

址为4.4.4.4。

(3)查看BGP邻居 r2#sh ip bgp summary

BGP router identifier 2.2.2.2, local AS number 1 BGP table version is 1, main routing table version 1

Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd

1.1.1.1 4 1 12 12 1 0 0 00:08:45 0

4.4.4.4 4 4 0 0 0 0 0 never Idle

第9页共191页

r2#

说明:因为R2与R4之间为eBGP邻居,hello的TTL值默认为1,而R2的源2.2.2.2

到达R4的源4.4.4.4,不止经过了一个网段,所以TTL值必须修改,才能够建立连接。

(4)修改R2与R4的TTL值 r2(config)#router bgp 1

r2(config-router)#neighbor 4.4.4.4 ebgp-multihop

r4(config)#router bgp 4

r4(config-router)#neighbor 2.2.2.2 ebgp-multihop

说明:将R2与R4之间的TTL值改大,默认改为255。

(5)查看BGP邻居 r2#sh ip bgp summary

BGP router identifier 2.2.2.2, local AS number 1 BGP table version is 1, main routing table version 1

Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd

1.1.1.1 4 1 14 14 1 0 0 00:10:27 0

4.4.4.4 4 4 4 4 1 0 0 00:00:16 0

第10页共191页

r2#

说明:由于邻居参数配置,所以邻居已经正常建立。

5.发布BGP路由

(1)查看BGP路由表 R1: r1#sh ip bgp r1# R2: r2#sh ip bgp r2# R4: r4#sh ip bgp r4#

说明:默认情况下,BGP的路由表为空。

(2)在R1上导入BGP路由表 r1(config)#router bgp 1

第11页共191页

r1(config-router)#network 11.1.1.0 mask 255.255.255.0

说明:将路由11.1.1.0/24导入BGP路由表,命令network后面的网段必须在

IGP表中真实存在,也就是show ip route必须能够看见,且掩码匹配,否则无法导入BGP路由表。

(3)查看R1的BGP路由表 1#sh ip bgp

BGP table version is 2, 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 *> 11.1.1.0/24 0.0.0.0 0 32768 i r1#

说明:因为R1已经通过命令network将11.1.1.0/24导入BGP路由表中,所以

能够看见该路由,由于此路由是自己导入的而并非从邻居学习到的,所以为本地路由,默认Next Hop为0.0.0.0,并且weight值为32768,最后的i表示该路由的origin属性为IGP,就表示是从IGP路由表被导入BGP路由表的。

(4)在R2上导入BGP路由表 r2(config)#route-map loop permit 10

r2(config-route-map)#match interface loopback 22

第12页共191页

r2(config)#router bgp 1

r2(config-router)#redistribute connected route-map loop

说明:R2通过重分布的方法将22.2.2.0/24导入BGP路由表。

(5)查看R2的BGP路由表 r2#sh ip bgp

BGP table version is 2, 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

Origin codes: i - IGP, e - EGP, ? - incomplete

Network Next Hop Metric LocPrf Weight Path * i11.1.1.0/24 1.1.1.1 0 100 0 i *> 22.2.2.0/24 0.0.0.0 0 32768 ? r2#

说明:因为R2是通过重分布的方法将路由导入BGP路由表的,所以为本地路由,

默认Next Hop为0.0.0.0,并且weight值为32768,并且因为是使用重分布的方法,所以该路由的origin属性为incomplete;而路由11.1.1.0/24是从邻居R1学习到的,所以 下一跳为邻居1.1.1.1的地址,前面的i表示是从iBGP邻居学习到的,而后面的i同样表示该路由的origin属性为IGP。

(6)在R4上导入BGP路由表

第13页共191页

r4(config)#router bgp 4

r4(config-router)#network 44.4.4.0 mask 255.255.255.0

说明:通过命令network将路由44.4.4.0/24发布到BGP路由表中。

(7)查看R4的BGP路由表 r4#sh ip bgp

BGP table version is 3, 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

Origin codes: i - IGP, e - EGP, ? - incomplete

Network Next Hop Metric LocPrf Weight Path *> 22.2.2.0/24 2.2.2.2 0 0 1 ? *> 44.4.4.0/24 0.0.0.0 0 32768 i r4#

说明:因为R4是通过命令network将路由导入BGP路由表的,所以为本地路由,

默认Next Hop为0.0.0.0,并且weight值为32768, origin属性为IGP;而路由22.2.2.0/24是从eBGP邻居R2学习到的,所以 下一跳为邻居2.2.2.2的地址,后面的?表示该路由的origin属性为incomplete。

6.保证BGP全网可达

(1)查看R1的BGP路由表 r1#sh ip bgp

第14页共191页

BGP table version is 2, 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 *> 11.1.1.0/24 0.0.0.0 0 32768 i * i22.2.2.0/24 2.2.2.2 0 100 0 ? * i44.4.4.0/24 4.4.4.4 0 100 0 4 i r1#

说明:R1已经学习到三条路由,11.1.1.0/24为自己本地路由,所以路由前面出

现>符号,表示该路由为最优路径,被BGP选中并使用,而22.2.2.0/24和44.4.4.0/24没有>符号,所以并不是最优路由,就不会被BGP使用,被标为最优路径的两个条件中,下一跳可达已经符合,而由于这两条路由前面有i的标记,所以是从iBGP学习到的,因此必须完成iBGP与IGP之间的同步后,才能为最优路由。

(2)在R1上关闭iBGP与IGP之间的同步 r1(config)#router bgp 1

r1(config-router)#no synchronization

(3)再次查看R1的BGP路由表 r1#sh ip bgp

BGP table version is 4, local router ID is 1.1.1.1

第15页共191页

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 *> 11.1.1.0/24 0.0.0.0 0 32768 i *>i22.2.2.0/24 2.2.2.2 0 100 0 ? *>i44.4.4.0/24 4.4.4.4 0 100 0 4 i r1#

说明:由于所有路由的下一跳都可达,并且iBGP与IGP之间的同步已不需要满

足,所以所有路由都成为了最优路由。

(4)查看R4的BGP路由表 r4#sh ip bgp

BGP table version is 3, 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

Origin codes: i - IGP, e - EGP, ? - incomplete

Network Next Hop Metric LocPrf Weight Path *> 22.2.2.0/24 2.2.2.2 0 0 1 ? *> 44.4.4.0/24 0.0.0.0 0 32768 i

第16页共191页

r4#

说明:R4所有的路由都不需要iBGP与IGP之间的同步,而下一跳都可达,所以

全部被标为最优路由,但是缺少R1发布的路由11.1.1.0/24。

(5)查看R2的BGP路由表 r2#sh ip bgp

BGP table version is 3, 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

Origin codes: i - IGP, e - EGP, ? - incomplete

Network Next Hop Metric LocPrf Weight Path * i11.1.1.0/24 1.1.1.1 0 100 0 i *> 22.2.2.0/24 0.0.0.0 0 32768 ? *> 44.4.4.0/24 4.4.4.4 0 0 4 i r2#

说明:因为11.1.1.0/24是从iBGP学习到的,并且不满足iBGP与IGP之间的同

步,所以该路由没有被标为最优路由,所以就没有发给邻居R4。

(6)在R2上关闭iBGP与IGP之间的同步 r2(config)#router bgp 1

r2(config-router)#no synchronization (7)再次查看R2的BGP路由表

第17页共191页

r2#sh ip bgp

BGP table version is 4, 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

Origin codes: i - IGP, e - EGP, ? - incomplete

Network Next Hop Metric LocPrf Weight Path *>i11.1.1.0/24 1.1.1.1 0 100 0 i *> 22.2.2.0/24 0.0.0.0 0 32768 ? *> 44.4.4.0/24 4.4.4.4 0 0 4 i r2#

说明:由于所有路由的下一跳都可达,并且iBGP与IGP之间的同步已不需要满

足,所以所有路由都成为了最优路由。

(8)查看R4的BGP路由表 r4#sh ip bgp

BGP table version is 4, 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

Origin codes: i - IGP, e - EGP, ? - incomplete

Network Next Hop Metric LocPrf Weight Path

第18页共191页

*> 11.1.1.0/24 2.2.2.2 0 1 i *> 22.2.2.0/24 2.2.2.2 0 0 1 ? *> 44.4.4.0/24 0.0.0.0 0 32768 i r4#

说明:R1,R2,R4都已经拥有了全部的路由。

RIB failure

1.R4创建网段并发布进OSPF

(1)R4创建网段并发布进OSPF r4(config)#int loopback 100

r4(config-if)#ip address 100.1.1.1 255.255.255.0 r4(config-if)#ip ospf network point-to-point

r4(config)#router ospf 1

r4(config-router)#network 100.1.1.1 0.0.0.0 area 0

说明:在R4上创建网段100.1.1.0/24,并将其发布进OSPF

(2)R4将100.1.1.0/24导入BGP路由表 r4(config)#router bgp 4

r4(config-router)#network 100.1.1.0 mask 255.255.255.0

第19页共191页

(3)查看R4的BGP路由表 r4#sh ip bgp

BGP table version is 7, 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

Origin codes: i - IGP, e - EGP, ? - incomplete

Network Next Hop Metric LocPrf Weight Path *> 11.1.1.0/24 2.2.2.2 0 1 i *> 22.2.2.0/24 2.2.2.2 0 0 1 ? *> 44.4.4.0/24 0.0.0.0 0 32768 i *> 100.1.1.0/24 0.0.0.0 0 32768 i r4#

说明:100.1.1.0/24已经被发布进BGP,成为本地路由,所以下一跳为0.0.0.0,

weight值为32768。

2.查看RIB failure

(1)查看R2的BGP路由表 r2#sh ip bgp

BGP table version is 7, local router ID is 2.2.2.2

Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,

第20页共191页

r RIB-failure, S Stale

Origin codes: i - IGP, e - EGP, ? - incomplete

Network Next Hop Metric LocPrf Weight Path *>i11.1.1.0/24 1.1.1.1 0 100 0 i *> 22.2.2.0/24 0.0.0.0 0 32768 ? *> 44.4.4.0/24 4.4.4.4 0 0 4 i *> 100.1.1.0/24 4.4.4.4 0 0 4 i r2#

说明:因为R2从eBGP邻居R4学习到的100.1.1.0/24的AD值为20,并且还从

OSPF学习到一次,AD为110,而OSPF的AD比BGP学习到的AD高,所以BGP中的路由正常。

(2)查看R1的BGP路由表 r1#sh 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 *> 11.1.1.0/24 0.0.0.0 0 32768 i *>i22.2.2.0/24 2.2.2.2 0 100 0 ?

第21页共191页

*>i44.4.4.0/24 4.4.4.4 0 100 0 4 i r>i100.1.1.0/24 4.4.4.4 0 100 0 4 i r1#

说明:因为R2从iBGP邻居R2学习到的100.1.1.0/24的AD值为200,并且还

从OSPF学习到一次,AD为110,而OSPF的AD比BGP学习到的AD低,所以BGP中的路由为RIB failure,所以路由前面标记为r。

(3)查看R1的RIB failure表 r1#sh ip bgp rib-failure

Network Next Hop RIB-failure RIB-NH Matches

100.1.1.0/24 4.4.4.4 Higher admin distance n/a r1#

说明:可以看到100.1.1.0/24为RIB failure路由,原因为已经拥有比BGP更

优先的AD值。

BGP选路规则实验

1.使R1,R2,R3,R4全网建立BGP,并且互通

(1)将R3加入BGP中 R1:

r1(config)#router bgp 1

第22页共191页

r1(config-router)#neighbor 3.3.3.3 remote-as 1

r1(config-router)#neighbor 3.3.3.3 update-source loopback 0 R3:

r3(config)#router bgp 1

r3(config-router)#bgp router-id 3.3.3.3 r3(config-router)#neighbor 1.1.1.1 remote-as 1

r3(config-router)#neighbor 1.1.1.1 update-source loopback 0

r3(config-router)#neighbor 4.4.4.4 remote-as 4

r3(config-router)#neighbor 4.4.4.4 update-source loopback 0 r3(config-router)#neighbor 4.4.4.4 ebgp-multihop R4:

r4(config)#router bgp 4

r4(config-router)#neighbor 3.3.3.3 remote-as 1

r4(config-router)#neighbor 3.3.3.3 update-source loopback 0 r4(config-router)#neighbor 3.3.3.3 ebgp-multihop

(2)查看R3的BGP邻居 r3#sh ip bg summary

第23页共191页

BGP router identifier 3.3.3.3, local AS number 1 BGP table version is 4, main routing table version 4 3 network entries using 351 bytes of memory 3 path entries using 156 bytes of memory

3/2 BGP path/bestpath attribute entries using 372 bytes of memory 1 BGP AS-PATH entries using 24 bytes of memory 0 BGP route-map cache entries using 0 bytes of memory 0 BGP filter-list cache entries using 0 bytes of memory BGP using 903 total bytes of memory

BGP activity 3/0 prefixes, 3/0 paths, scan interval 60 secs

Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd

1.1.1.1 4 1 7 7 4 0 0 00:02:08 1

4.4.4.4 4 4 7 5 4 0 0 00:00:08 2 r3#

说明:R3已经与其它路由器建立BGP邻居。

2.改变AS 1内部下一跳

(1)查看R1的BGP路由表 r1#sh ip bgp

第24页共191页

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 *> 11.1.1.0/24 0.0.0.0 0 32768 i *>i22.2.2.0/24 2.2.2.2 0 100 0 ? * i44.4.4.0/24 4.4.4.4 0 100 0 4 i *>i 4.4.4.4 0 100 0 4 i r i100.1.1.0/24 4.4.4.4 0 100 0 4 i r>i 4.4.4.4 0 100 0 4 i r1#

说明:因为R1都是从iBGP收到的路由,所以到达R4的路由44.4.4.0的下一跳

都为4.4.4.4,而没有被R2和R3改变。 (2)改变R2与R3对R1的下一跳为自己 r2(config)#router bgp 1

r2(config-router)#neighbor 1.1.1.1 next-hop-self

r3(config)#router bgp 1

r3(config-router)#neighbor 1.1.1.1 next-hop-self

第25页共191页

(3)再次查看R1的BGP路由表 r1#sh ip bgp

BGP table version is 8, 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 *> 11.1.1.0/24 0.0.0.0 0 32768 i *>i22.2.2.0/24 2.2.2.2 0 100 0 ? * i44.4.4.0/24 3.3.3.3 0 100 0 4 i *>i 2.2.2.2 0 100 0 4 i r i100.1.1.0/24 3.3.3.3 0 100 0 4 i r>i 2.2.2.2 0 100 0 4 i r1#

说明:学习到的路由44.4.4.0/24已经被R2和R3改为自己。

测试选路规则说明:

测试R1通过R2与R3到达R4的网段44.4.4.0/24的选路, 以及测试R4通过R2与R3到达R1的网段11.1.1.0/24的选路,

第26页共191页

要测试的选路顺序为

1.最高Weight值 2.最高LOCAL_PREF值

3.本地发起路由

4.最短AS_PATH 5.最低Origin类型 6.最小MED值 7.eBGP优于iBGP

8.最小IGP metric到达下一跳的路由 9.负载均衡(如果开启的话)

10.如果下一跳都为eBGP,则选择最早学习到的路由(即时间最长的路由) 11.最低Router-ID下一跳

12.最短cluster list(如同AS_PATH)

13.最小下一跳的邻居地址

因为选路顺序为由上至下,当上一个属性已经比较出最优路径,则下一属性被忽略,所以我们实验从下往上修改来进行比较,因为改过下面的属性影响选路之后,只要再改上一条,就能再次影响选路,就能证明,上一条是比下一条优先的。

测试第13条 最小下一跳的邻居地址

说明:因为只有下一跳邻居的Router-ID相同的情况下,才会比较下一跳邻居的

地址大小,所以先将R2与R3的Router-ID改为相同,以测试比较下一跳地址。 (1)修改R3的Router-ID与R2相同

第27页共191页

r3(config)#router bgp 1

r3(config-router)#bgp router-id 2.2.2.2 r3(config-router)#

(2)查看R1到达44.4.4.0/24的选路 r1#sh ip bgp

BGP table version is 8, 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 *> 11.1.1.0/24 0.0.0.0 0 32768 i *>i22.2.2.0/24 2.2.2.2 0 100 0 ? * i44.4.4.0/24 3.3.3.3 0 100 0 4 i *>i 2.2.2.2 0 100 0 4 i r i100.1.1.0/24 3.3.3.3 0 100 0 4 i r>i 2.2.2.2 0 100 0 4 i r1#

说明:R1到达网段44.4.4.0/24选则最小下一跳邻居R2为最优路径。

第28页共191页

测试第12条 最短cluster list

说明:因为比较最短cluster list只在BGP Route Reflector (RR)环境中才有,

所以此步跳过。

测试第11条 最低Router-ID下一跳

说明:选择下一跳有最小Router-ID的邻居为最优路径。

(1)修改R3的Router-ID r3(config)#router bgp 1

r3(config-router)#bgp router-id 1.1.1.3

说明:将R3的Router-ID改为1.1.1.3

(2)查看R1到达44.4.4.0/24的选路 r1#sh ip bgp

BGP table version is 10, 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 *> 11.1.1.0/24 0.0.0.0 0 32768 i

第29页共191页

*>i22.2.2.0/24 2.2.2.2 0 100 0 ? *>i44.4.4.0/24 3.3.3.3 0 100 0 4 i * i 2.2.2.2 0 100 0 4 i r>i100.1.1.0/24 3.3.3.3 0 100 0 4 i r i 2.2.2.2 0 100 0 4 i r1#

说明:因为R2的Router-ID为2.2.2.2,而R3的Router-ID为1.1.1.3,所以

最小Router-ID的R3被选为最优路径。

测试第10条 如果下一跳都为eBGP,则选择最早学习到的路由(即时间最长的路由)

说明:因为只有下一跳都为eBGP,才比较选择最早学习到的路由,所以测试R4

通过R2与R2到达11.1.1.0/24的选路。 (1)查看R4到达11.1.1.0/24的选路 r4#sh ip bgp

BGP table version is 7, 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

Origin codes: i - IGP, e - EGP, ? - incomplete

Network Next Hop Metric LocPrf Weight Path * 11.1.1.0/24 3.3.3.3 0 1 i *> 2.2.2.2 0 1 i

第30页共191页

*> 22.2.2.0/24 2.2.2.2 0 0 1 ? *> 44.4.4.0/24 0.0.0.0 0 32768 i *> 100.1.1.0/24 0.0.0.0 0 32768 i r4#

说明:R4选择R2到达11.1.1.0/24

(2)查看R2与R3的邻居时间 r4#sh ip bg summary

BGP router identifier 4.4.4.4, local AS number 4 BGP table version is 7, main routing table version 7 4 network entries using 404 bytes of memory 5 path entries using 240 bytes of memory

3 BGP path attribute entries using 180 bytes of memory 1 BGP AS-PATH entries using 24 bytes of memory 0 BGP route-map cache entries using 0 bytes of memory 0 BGP filter-list cache entries using 0 bytes of memory BGP using 848 total bytes of memory

BGP activity 5/1 prefixes, 8/3 paths, scan interval 60 secs

Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd

2.2.2.2 4 1 51 49 7 0 0 00:43:27 2

第31页共191页

3.3.3.3 4 1 27 33 7 0 0 00:02:23 1 r4#

说明:因为R2的邻居时间比R3长,所以R2为最优路径。

(3)清除R2的邻居,以刷新邻居时间 r4(config)#router bgp 4

r4(config-router)#neighbor 2.2.2.2 shutdown r4(config-router)#

*Mar 1 01:16:09.823: %BGP-5-ADJCHANGE: neighbor 2.2.2.2 Down Admin. shutdown

r4(config-router)#no neighbor 2.2.2.2 shutdown r4(config-router)#

*Mar 1 01:16:37.452: %BGP-5-ADJCHANGE: neighbor 2.2.2.2 Up r4(config-router)#

说明:将邻居R2断开,再建立,从而刷新邻居的建立时间。

(4)再次查看邻居的建立时间 r4#sh ip bg summary

BGP router identifier 4.4.4.4, local AS number 4 BGP table version is 10, main routing table version 10 4 network entries using 404 bytes of memory 5 path entries using 240 bytes of memory

第32页共191页

3 BGP path attribute entries using 180 bytes of memory 1 BGP AS-PATH entries using 24 bytes of memory 0 BGP route-map cache entries using 0 bytes of memory 0 BGP filter-list cache entries using 0 bytes of memory BGP using 848 total bytes of memory

BGP activity 5/1 prefixes, 10/5 paths, scan interval 60 secs

Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd

2.2.2.2 4 1 57 55 10 0 0 00:00:27 2

3.3.3.3 4 1 28 36 10 0 0 00:03:45 1 r4#

说明:R3的邻居时间比R2长。

(5)再次查看R4到达11.1.1.0/24的选路 r4#sh ip bgp

BGP table version is 10, 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

Origin codes: i - IGP, e - EGP, ? - incomplete

第33页共191页

Network Next Hop Metric LocPrf Weight Path * 11.1.1.0/24 2.2.2.2 0 1 i *> 3.3.3.3 0 1 i *> 22.2.2.0/24 2.2.2.2 0 0 1 ? *> 44.4.4.0/24 0.0.0.0 0 32768 i *> 100.1.1.0/24 0.0.0.0 0 32768 i r4#

说明:因为R3的邻居时间比R2长,所以选择了R3为最优路径。

测试第9条 BGP负载均衡

说明:只有在前面8条属性都相同的话,才能开启BGP的负载功能,前8条属性

任何一条不同,都不能负载。

(1)查看R1到达44.4.4.0/24的选路 r1#sh ip route bgp

22.0.0.0/24 is subnetted, 1 subnets B 22.2.2.0 [200/0] via 2.2.2.2, 00:38:33 44.0.0.0/24 is subnetted, 1 subnets B 44.4.4.0 [200/0] via 3.3.3.3, 00:05:12 r1#

说明:R1到达44.4.0/24只走R3,默认没有负载。

(2)开启BGP负载功能

第34页共191页

r1(config)#router bgp 1

r1(config-router)#maximum-paths ibgp 2

说明:因为两个下一跳都为iBGP,所以开启iBGP的负载功能。

(3)再次查看R1到达44.4.0/24的选路 r1#sh ip route bgp

22.0.0.0/24 is subnetted, 1 subnets B 22.2.2.0 [200/0] via 2.2.2.2, 00:39:16 44.0.0.0/24 is subnetted, 1 subnets B 44.4.4.0 [200/0] via 2.2.2.2, 00:00:18 [200/0] via 3.3.3.3, 00:00:18 r1#

说明:R1到达44.4.4.0/24已经执行负载。

(4)查看R4到达11.1.1.0/24的选路 r4#sh ip route bgp

22.0.0.0/24 is subnetted, 1 subnets B 22.2.2.0 [20/0] via 2.2.2.2, 00:03:03 11.0.0.0/24 is subnetted, 1 subnets B 11.1.1.0 [20/0] via 3.3.3.3, 00:03:31 r4#

说明:R4到达11.1.1.0/24没有负载。

第35页共191页

(5)开启R4到达11.1.1.0/24的负载 r4(config)#router bgp 4

r4(config-router)#maximum-paths 2

说明:因为两个下一跳都为eBGP,所以开启eBGP的负载。

(6)再次查看R4到达11.1.1.0/24的选路 r4#sh ip route bgp

22.0.0.0/24 is subnetted, 1 subnets B 22.2.2.0 [20/0] via 2.2.2.2, 00:03:33 11.0.0.0/24 is subnetted, 1 subnets B 11.1.1.0 [20/0] via 2.2.2.2, 00:00:15 [20/0] via 3.3.3.3, 00:00:15 r4#

说明:R4到达11.1.1.0/24已经执行负载。

测试第8条 最小IGP metric到达下一跳的路由

说明:拥有最小IGP metric到达下一跳的路由为最优路径。

(1)查看R1到达44.4.4.0/24的选路 r1#sh ip bgp

BGP table version is 14, local router ID is 1.1.1.1

第36页共191页

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 *> 11.1.1.0/24 0.0.0.0 0 32768 i *>i22.2.2.0/24 2.2.2.2 0 100 0 ? * i44.4.4.0/24 2.2.2.2 0 100 0 4 i *>i 3.3.3.3 0 100 0 4 i r i100.1.1.0/24 2.2.2.2 0 100 0 4 i r>i 3.3.3.3 0 100 0 4 i r1#

说明:R1选择R3到达44.4.0/24,但并不是因为IGP metric。

(2)查看到达两个下一跳R2与R3的IGP metric值 r1#sh ip route

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, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area

第37页共191页

* - candidate default, U - per-user static route, o - ODR P - periodic downloaded static route

Gateway of last resort is not set

34.0.0.0/24 is subnetted, 1 subnets

O 34.1.1.0 [110/2] via 13.1.1.3, 00:28:17, FastEthernet0/1 1.0.0.0/32 is subnetted, 1 subnets C 1.1.1.1 is directly connected, Loopback0 2.0.0.0/32 is subnetted, 1 subnets

O 2.2.2.2 [110/2] via 12.1.1.2, 00:28:17, FastEthernet0/0 100.0.0.0/24 is subnetted, 1 subnets

O 100.1.1.0 [110/3] via 12.1.1.2, 00:28:17, FastEthernet0/0 [110/3] via 13.1.1.3, 00:28:17, FastEthernet0/1 3.0.0.0/32 is subnetted, 1 subnets

O 3.3.3.3 [110/2] via 13.1.1.3, 00:28:18, FastEthernet0/1 4.0.0.0/32 is subnetted, 1 subnets

O 4.4.4.4 [110/3] via 12.1.1.2, 00:28:18, FastEthernet0/0 [110/3] via 13.1.1.3, 00:28:18, FastEthernet0/1 22.0.0.0/24 is subnetted, 1 subnets B 22.2.2.0 [200/0] via 2.2.2.2, 00:41:12 24.0.0.0/24 is subnetted, 1 subnets

第38页共191页

O 24.1.1.0 [110/2] via 12.1.1.2, 00:28:21, FastEthernet0/0 11.0.0.0/24 is subnetted, 1 subnets

C 11.1.1.0 is directly connected, Loopback11 12.0.0.0/24 is subnetted, 1 subnets

C 12.1.1.0 is directly connected, FastEthernet0/0 13.0.0.0/24 is subnetted, 1 subnets

C 13.1.1.0 is directly connected, FastEthernet0/1 44.0.0.0/24 is subnetted, 1 subnets B 44.4.4.0 [200/0] via 2.2.2.2, 00:02:14 [200/0] via 3.3.3.3, 00:02:14 r1#

说明:到达两个下一跳R2与R3的IGP metric值相同。

(3)改大到达下一跳R3的IGP metric值,使最优路径走R2 r1(config)#int f0/1 r1(config-if)#ip ospf cost 2

(4)再次查看到达两个下一跳R2与R3的IGP metric值 r1#sh ip route

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

第39页共191页

E1 - OSPF external type 1, E2 - OSPF external type 2

i - IS-IS, 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

34.0.0.0/24 is subnetted, 1 subnets

O 34.1.1.0 [110/3] via 13.1.1.3, 00:01:10, FastEthernet0/1 [110/3] via 12.1.1.2, 00:01:10, FastEthernet0/0 1.0.0.0/32 is subnetted, 1 subnets C 1.1.1.1 is directly connected, Loopback0 2.0.0.0/32 is subnetted, 1 subnets

O 2.2.2.2 [110/2] via 12.1.1.2, 00:01:10, FastEthernet0/0 100.0.0.0/24 is subnetted, 1 subnets

O 100.1.1.0 [110/3] via 12.1.1.2, 00:01:10, FastEthernet0/0 3.0.0.0/32 is subnetted, 1 subnets

O 3.3.3.3 [110/3] via 13.1.1.3, 00:01:11, FastEthernet0/1 4.0.0.0/32 is subnetted, 1 subnets

O 4.4.4.4 [110/3] via 12.1.1.2, 00:01:11, FastEthernet0/0 22.0.0.0/24 is subnetted, 1 subnets B 22.2.2.0 [200/0] via 2.2.2.2, 00:43:18

第40页共191页

本文来源:https://www.bwwdw.com/article/8mx7.html

Top