设为首页收藏本站language 语言切换
查看: 1881|回复: 2
收起左侧

CCNP-35 BGP 5

[复制链接]
发表于 2013-6-22 15:05:15 | 显示全部楼层 |阅读模式
CCNP-35 BGP 5实验拓扑:
200712111197380089953.jpg
实验要求:按照拓扑将4台路由器分别配置在AS 100/200中,R1与R2 R3成为EBGP PEER,R4与R2 R3成为IBGP PEER,在R4上起loopback接口,配置完成后在R1上观察BGP路由表,看看R4的loopback接口的网络是通过哪台路由器学习到的,然后通过修改weight属性,使之从另外一台路由器学习R4的loopback网络。
试验目的:掌握BGP选路时weight属性的用法和配置方法。



实验配置:
R1
R1(config)#int f0/0
R1(config-if)#ip add 172.16.1.1 255.255.255.0
R1(config-if)#no shu
R1(config-if)#exit
R1(config)#int f1/0
R1(config-if)#ip add 172.16.4.1 255.255.255.0
R1(config-if)#no shu
R1(config-if)#exit
R1(config)#int loop0
R1(config-if)#ip add 1.1.1.1 255.255.255.0
R1(config-if)#exit
R1(config)#router bgp 100
R1(config-router)#neighbor 172.16.1.2 remote-as 200
R1(config-router)#neighbor 172.16.4.2 remote-as 200
R1(config-router)#exit

R2
R2(config)#int f0/0
R2(config-if)#ip add 172.16.1.2 255.255.255.0
R2(config-if)#no shu
R2(config-if)#exit
R2(config)#int f1/0
R2(config-if)#ip add 172.16.2.1 255.255.255.0
R2(config-if)#no shu
R2(config-if)#exit
R2(config)#int loop0
R2(config-if)#ip add 2.2.2.2 255.255.255.0
R2(config-if)#exit
R2(config)#router ospf 100
R2(config-router)#router-id 2.2.2.2
R2(config-router)#network 0.0.0.0 0.0.0.0 a 0
R2(config-router)#exit
R2(config)#router bgp 200
R2(config-router)#neighbor 4.4.4.4 remote-as 200
R2(config-router)#neighbor 4.4.4.4 update-source loopback 0
R2(config-router)#neighbor 3.3.3.3 remote-as 200
R2(config-router)#neighbor 3.3.3.3 update-source loopback 0
R2(config-router)#neighbor 172.16.1.1 remote-as 100
R2(config-router)#exit

R3
R3(config)#int f0/0
R3(config-if)#ip add 172.16.3.2 255.255.255.0
R3(config-if)#no shu
R3(config-if)#exit
R3(config)#int f1/0
R3(config-if)#no shu
R3(config-if)#exit
R3(config)#int loop0
R3(config-if)#ip add 3.3.3.3 255.255.255.0
R3(config-if)#exit
R3(config)#router ospf 100
R3(config-router)#router-id 3.3.3.3
R3(config-router)#network 0.0.0.0 0.0.0.0 a 0
R3(config-router)#exit
R3(config)#router bgp 200
R3(config-router)#neighbor 2.2.2.2 remote-as 200
R3(config-router)#neighbor 2.2.2.2 update-source loopback 0
R3(config-router)#neighbor 4.4.4.4 remote-as 200
R3(config-router)#neighbor 4.4.4.4 update-source loopback 0
R3(config-router)#neighbor 172.16.4.1 remote-as 100
R3(config-router)#exit

R4
R4(config)#int f1/0
R4(config-if)#ip add 172.16.2.2 255.255.255.0
R4(config-if)#no shu
R4(config-if)#exit
R4(config)#int f0/0
R4(config-if)#ip add 172.16.3.1 255.255.255.0
R4(config-if)#no shu
R4(config-if)#exit
R4(config)#int loop0
R4(config-if)#ip add 4.4.4.4 255.255.255.0
R4(config-if)#exit
R4(config)#router ospf 100
R4(config-router)#router-id 4.4.4.4
R4(config-router)#network 0.0.0.0 0.0.0.0 a 0
R4(config-router)#exit
R4(config)#int loop1
R4(config-if)#ip add 10.10.10.10 255.255.255.0
R4(config-if)#exit
R4(config)#int loop2
R4(config-if)#ip add 20.20.20.20 255.255.255.0
R4(config-if)#exit
R4(config)#router bgp 200
R4(config-router)#neighbor 2.2.2.2 remote-as 200
R4(config-router)#neighbor 2.2.2.2 update-source loopback 0
R4(config-router)#neighbor 3.3.3.3 remote-as 200
R4(config-router)#neighbor 3.3.3.3 update-source loopback 0
R4(config-router)#network 10.10.10.0 mask 255.255.255.0
R4(config-router)#network 20.20.20.0 mask 255.255.255.0
R4(config-router)#exit
好了,基本的BGP配置完成了,下面我们到R1show ip bgp查看一下BGP路由表:
R1#show ip bgp
BGP table version is 3, 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.10.10.0/24    172.16.4.2                             0 200 i
*>                  172.16.1.2                             0 200 i
*  20.20.20.0/24    172.16.4.2                             0 200 i
*>                  172.16.1.2                             0 200 i
1020的路由都是从172.16.1.2学到的,也就是从R2学到的,默认的weight0,因为这条路由不是由自己产生的(如果是自己产生的路由,默认为32768,再R4show ip bgp看到的就会是32768)。
下面我们在R1上修改BGPweight属性,使10的路由从R1走,20的路由从R2走:
R1(config)#access-list 10 permit 10.10.10.0 0.0.0.255
R1(config)#access-list 20 permit 20.20.20.0 0.0.0.255
R1(config)#route-map wei_10 permit 10
R1(config-route-map)#match ip add 10
R1(config-route-map)#set weight 65535
R1(config-route-map)#exit
R1(config)#route-map wei_10 permit 20
R1(config-route-map)#set weight 32768
R1(config-route-map)#exit
R1(config)#route-map wei_20 permit 10
R1(config-route-map)#match ip add 20
R1(config-route-map)#set weight 65535
R1(config-route-map)#exit
R1(config)#route-map wei_20 permit 20
R1(config-route-map)#set weight 32768
R1(config-route-map)#exit
R1(config)#router bgp 100
R1(config-router)#neighbor 172.16.1.2 route-map wei_10 in
R1(config-router)#neighbor 172.16.4.2 route-map wei_20 in
R1(config-router)#exit
上面的配置很关键,首先需要定义ACL,用来标记需要使用策略的路由,然后配置策略路由,匹配刚才定义的感兴趣的路由,最后分别应用到两个邻居上,注意方向为inweight属性本地有效),BGP会优先选择weight值大的路径。下面我把有关定义10路由的配置详细讲解一下:
R1(config)#access-list 10 permit 10.10.10.0 0.0.0.255 //定义10.10.10.0/24位感兴趣的路由
R1(config)#route-map wei_10 permit 10 //配置策略路由wei_10,序号为10,允许通过。
R1(config-route-map)#match ip add 10 //匹配ACL 10定义的路由
R1(config-route-map)#set weight 65535 //设置weight65535
R1(config-route-map)#exit
R1(config)#route-map wei_10 permit 20 //配置策略路由wei_10,序号为20,允许通过。
R1(config-route-map)#set weight 32768 //刚才没有匹配ACL 10的路由的weight设置为32768
R1(config-route-map)#exit
R1(config)#router bgp 100
R1(config-router)#neighbor 172.16.1.2 route-map wei_10 in //在邻居172.16.1.2上应用策略路由wei_10




这样配置完成后,我们先在R1clear ip bgp *,然后再来看看R1BGP路由表:
R1#show ip bgp
BGP table version is 3, 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.10.10.0/24    172.16.4.2                         32768 200 i
*>                  172.16.1.2                         65535 200 i
*> 20.20.20.0/24    172.16.4.2                         65535 200 i
*                   172.16.1.2                         32768 200 i
看到了吗?不仅原来默认的weight属性值都发生了变化,并且也改变了20这个路由的下一跳为172.16.4.2,也就是R3了,成功地实现了用weight属性来修改BGP的选路。再来看一下R1的路由表:
R1#show 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, 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

     1.0.0.0/24 is subnetted, 1 subnets
C       1.1.1.0 is directly connected, Loopback0
     20.0.0.0/24 is subnetted, 1 subnets
B       20.20.20.0 [20/0] via 172.16.4.2, 00:00:26
     172.16.0.0/24 is subnetted, 2 subnets
C       172.16.4.0 is directly connected, FastEthernet1/0
C       172.16.1.0 is directly connected, FastEthernet0/0
     10.0.0.0/24 is subnetted, 1 subnets
B       10.10.10.0 [20/0] via 172.16.1.2, 00:00:26



                               
登录/注册后可看大图
该贴已经同步到 qingmosk的微博
发表于 2013-6-28 16:14:22 | 显示全部楼层
感谢分享!
沙发 2013-6-28 16:14:22 回复 收起回复
回复 支持 反对

使用道具 举报

发表于 2013-8-13 22:58:00 | 显示全部楼层
非常不错,学习了
板凳 2013-8-13 22:58:00 回复 收起回复
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 论坛注册

本版积分规则

QQ|Archiver|手机版|小黑屋|sitemap|鸿鹄论坛 ( 京ICP备14027439号 )  

GMT+8, 2025-2-13 01:54 , Processed in 0.067894 second(s), 24 queries , Redis On.  

  Powered by Discuz!

  © 2001-2025 HH010.COM

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