个人总结之――BGP实验

BGP 综合实验
一、实验目的:
1 配置 EBGP IBGP 协议,并观察路由学习和选路情况
 
2 利用 BGP 各种属性( MED LOCAL PREFERANCE WEIGHT and so on )改变路由选录路
MED: 影响如何进入本 AS ,首选小的 MED
LOCAL PREFERANCE :影响如何离开本 AS ,首选大的 LOCPRF
WEIGHT:CISCO 私有: 首选大的 WEIGHT
当路由器有多个离开 AS 的出口时,将根据 weight 来决定选择哪个出口;
当有多台路由器提供了多个出口时,将根据本地优先级来决定选择哪个出口;
 
二、实验拓扑
1 、每台路由器都有一个回环口
2 R2 独自工作在 BGP 2
3 IP 地址分配遵循网段制,如 R2 R1 间使用 21.1.1 .0/24 网段,其中 R1 分配地址就为 21.1.1.1  R2 分配地址为 21.1.1.1 ,以此类推
4、注意在配置 BGP 时,请将各个路由器的回环口指定为 bgp router-id, 否则在起用新的回环口后,同时 clear ip bgp * 的话 可能导致邻居关系无法建立
个人总结之――BGP实验_第1张图片

三、实验配置
1 、在各个路由器上完成基本的端口配置、 IBGP OSPF 协议)配置、 EBGP 配置
R1 配置:
ip cef
interface Loopback0  / 配置回环口 0
 ip address 1.1.1 .1 255.255.255.0
interface FastEthernet0/0 / 配置端口
ip address 13.1.1 .1 255.255.255.0
 no shutdown
interface Serial1/0 / 配置端口
ip address 16.1.1 .1 255.255.255.0
no shutdown
interface Serial1/1 / 配置端口
 ip address 21.1.1 .2 255.255.255.0
no shutdown
 
router ospf 1 / 配置 OSPF 协议
 router-id 1.1.1 .1
network 1.1.1 .1 0.0.0.0 area 0
 network 13.1.1 .1 0.0.0.0 area 0
 network 16.1.1 .1 0.0.0.0 area 0
 
router bgp 2 / 配置 BGP 协议
 network 1.1.1 .0 mask 255.255.255.0
 neighbor 2.2.2 .2 remote-as 1
 neighbor 2.2.2 .2 ebgp-multihop 10
 neighbor 2.2.2 .2 update-source Loopback0
 neighbor 3.3.3 .3 remote-as 2
 neighbor 3.3.3 .3 update-source Loopback0
 neighbor 3.3.3 .3 next-hop-self
 neighbor 6.6.6 .6 remote-as 2
 neighbor 6.6.6 .6 update-source Loopback0
 neighbor 6.6.6 .6 next-hop-self
 no auto-summary
ip route 2.2.2 .0 255.255.255.0 21.1.1.1 / 配置静态路由,使 R1 可跟 R2 的回环口建立 TCP 连接
 
R2 配置:
ip cef
interface Loopback0
 ip address 2.2.2 .2 255.255.255.0
interface Serial1/0
 ip address 21.1.1 .1 255.255.255.0
 no shutdown
interface Serial1/1
 ip address 23.1.1 .1 255.255.255.0
 no shutdown
router bgp 1
network 2.2.2 .0 mask 255.255.255.0
 neighbor 1.1.1 .1 remote-as 2
 neighbor 1.1.1 .1 ebgp-multihop 10
 neighbor 1.1.1 .1 update-source Loopback0
 neighbor 3.3.3 .3 remote-as 2
 neighbor 3.3.3 .3 ebgp-multihop 10
 neighbor 3.3.3 .3 update-source Loopback0
ip route 1.1.1 .0 255.255.255.0 21.1.1.2
ip route 3.3.3 .0 255.255.255.0 23.1.1.2
 
R3 配置:
interface Loopback0
 ip address 3.3.3 .3 255.255.255.0
interface FastEthernet0/0
 ip address 13.1.1 .2 255.255.255.0
 no shutdown
interface Serial1/1
 ip address 36.1.1.1 255.255.255.0
 no shutdown
interface Serial1/2
 ip address 23.1.1 .2 255.255.255.0
no shutdown
router ospf 1
 router-id 3.3.3 .3
network 3.3.3 .3 0.0.0.0 area 0
 network 13.1.1 .2 0.0.0.0 area 0
 network 36.1.1.1 0.0.0 .0 area 0
router bgp 2
network 3.3.3 .0 mask 255.255.255.0
 neighbor 1.1.1 .1 remote-as 2
 neighbor 1.1.1 .1 update-source Loopback0
 neighbor 1.1.1 .1 next-hop-self
 neighbor 2.2.2 .2 remote-as 1
 neighbor 2.2.2 .2 ebgp-multihop 10
 neighbor 2.2.2 .2 update-source Loopback0
 neighbor 6.6.6 .6 remote-as 2
 neighbor 6.6.6 .6 update-source Loopback0
ip route 2.2.2 .0 255.255.255.0 23.1.1.1
 
 
 
 
 
 
修改 LOCPRF WEIGHT 来影响选路
R2 上查看 BGP 路由表( show ip bgp
 

 
 

可以观察到,去往 6.6.6 .0 网络, R2 选择了往 R1 走,即下一跳为 1.1.1.1 ,为了使去往 6.6.6.0 网络选择 R3 为下一条
我们在 R2 上使用路由映射修改 LocPrf 来影响选路,配置如下:
R2(config)access-list 1 permit 6.6.6 .0 0.0.0.255
R2(config)#route-map local-preference permit 10
R2(config-route-map)#match ip add 1
R2(config-route-map)#set loca-preference 200
R2(config-route-map)#exit
R2(config)#route-map local-preference permit 20
R2(config-route-map)#exit
R2(config)#router bgp 1
R2(config-router)#neighbor 3.3.3 .3 route-map local-preference in
R2#clear ip bgp * soft in
在建立邻居关系时同时实施该路由影射后,再次查看 R2 BGP 路由表:
 
可以看到,来自 3.3.3 .3 的关于 6.6.6.0 网络的路由信息的本地优先级改为 200 ,而其他本地优先级保持不变,同时, R2 根据本地优先级高来选择下一跳为 3.3.3.3
 
同样可以使用 weight 来影响选路,配置如下:
R2(config)access-list 1 permit 6.6.6 .0 0.0.0.255
R2(config)#route-map weight permit 10
R2(config-route-map)#match ip add 1
R2(config-route-map)#set weight 300
R2(config-route-map)#exit
R2(config)#route-map local-preference permit 20
R2(config-route-map)#exit
R2(config)#router bgp 1
R2(config-router)#neighbor 3.3.3 .3 route-map weight in
R2#clear ip bgp * soft in
 
同样可以看到,修改 weight 后,影响选路
 
                    
 
                       修改MED来影响选路
 
R4 R5 上配置回环口 1 ,地址为: 45.45.45.45/24 ,同时在 BGP 中宣告出去,当网络稳定后,在 R6 上看到的 BGP 路有表为:
 
 
可以看到,默认情况下, R6 去往 45.45.45.0 网络的下一跳为 4.4.4 .4 MED 值均为 0 (默认情况下, EBGP 邻居间的 MED 0
R4 R5 上分别实施路由影射修改 MED 值,从而影响 R6 的选路,配置如下:
R4(config)#access-list 1 permit 45.45.45.0 255.255.255.0
R4(config)#route-map med per 10
R4(config-route-map)#match ip address 1
R4(config-route-map)#set metric 500
R4(config-route-map)#route-map med per 20
R4(config-route-map)#exit
R4(config)#router bgp 3
R4(config-router)#nei 6.6.6 .6 route-map med out
 
R5(config)#access-list 1 permit 45.45.45.0 255.255.255.0
R5(config)#route-map med per 10
R5(config-route-map)#match ip address 1
R5(config-route-map)#set metric 400
R5(config-route-map)#route-map med per 20
R5(config-route-map)#exit
R5(config)#router bgp 3
R5(config-router)#nei 6.6.6 .6 route-map med out
 
R6 上使用 clear ip bgp * 命令重置 BGP 邻居后,再次查看 BGP 路由表,如下
 
 
可以看到, MED 值由默认的 0 改变了,同时影响了选路,选择 MED 小的
 
END
 
 
 

你可能感兴趣的:(网络,职场,Cisco,休闲,BGP)