您的位置:首页 > 其它

个人总结之――BGP实验

2010-08-04 17:28 447 查看
[align=center]BGP[/b]综合实验[/b][/b][/align]
一、实验目的:
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 *的话 可能导致邻居关系无法建立



三、实验配置
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

[align=center] [/align]
[align=center] [/align]
[align=center] [/align]
[align=center] [/align]
[align=center] [/align]
[align=center]修改LOCPRF 和WEIGHT来影响选路[/align]
在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

本文出自 “gjianchang的博客” 博客,请务必保留此出处http://gjianchang.blog.51cto.com/780026/367443
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: