您的位置:首页 > 其它

CCNP-32 BGP 2

2007-12-06 21:03 323 查看

CCNP-32 BGP 2

写在前面:BGP的属性是BGP学习中的重点,要深刻的理解BGP的每个属性和应用范围。

实验拓扑:



实验要求:R1在AS 100中,配置R1与R2 R3成为EBGP PEER,R2与R4 R3成为IBGP PEER,同样R3与R2 R4位IBGP PEER,且都在AS 200中,IGP为OSPF。
试验目的:掌握BGP用属性来决定路由路径和配置的方法。

试验配置:
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)#int loop1
R1(config-if)#ip add 199.99.1.1 255.255.255.0
R1(config-if)#exit
R1(config)#int loop2
R1(config-if)#ip add 199.99.2.1
255.255.255.0
R1(config-if)#no shu
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)#network
199.99.1.0
R1(config-router)#network
199.99.2.0
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)#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
172.16.1.1 remote-as 100
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
4.4.4.4 next-hop-self
R2(config-router)#network
172.16.2.0 mask 255.255.255.0
R2(config-router)#exit

R3:
R3(config)#int f1/0
R3(config-if)#ip add 172.16.4.2
255.255.255.0
R3(config-if)#no shu
R3(config-if)#exit
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 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
172.16.4.1 remote-as 100
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
4.4.4.4 next-hop-self
R3(config-router)#network
172.16.3.0 mask 255.255.255.0
R3(config-router)#exit

R4:
R4(config)#int f0/0
R4(config-if)#ip add 172.16.3.2
255.255.255.0
R4(config-if)#exit
R4(config-if)#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-if)#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)#router bgp 200
R4(config-router)#neighbor
ccnp peer-group
R4(config-router)#neighbor
ccnp remote-as 200
R4(config-router)#neighbor
ccnp update-source loopback 0
R4(config-router)#neighbor
2.2.2.2 peer-group ccnp
R4(config-router)#neighbor
3.3.3.3 peer-group ccnp
R4(config-router)#exit
上面的配置是关于基本的EBGP和IBGP的,这次试验中比上次多出的命令解释如下:
Neighbor x.x.x.x next-hop-self:是用来更改BGP的nest-hop属性的,有关next-hop属性,我的下次试验会做详细讲解;
Neighbor <word> peer-group:配置BGP组,用来把基于相同的策略的BGP邻居放在一起,然后只需要对组进行配置就可以了,大大简化了配置的复杂度。
好了,然后我们在R4上观察BGP路由:
R4#show ip bgp
BGP table version is 13, 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
r>i172.16.2.0/24 2.2.2.2 0 100
0 i
r>i172.16.3.0/24 3.3.3.3 0 100
0 i
*>i199.99.1.0 2.2.2.2 0 100
0 100 i
* i 3.3.3.3 0 100
0 100 i
*>i199.99.2.0 2.2.2.2 0 100
0 100 i
* i 3.3.3.3 0 100
0 100 i
注意用红颜色标记的部分,在R4上可以看到两条到达199.99.1.0/24与199.99.2.0/24的路径,但是这两条路径都选择了走上面,也就是从R2走,这样只有从R2走的路由会被写入路由表(我这里忘记show ip route了),这样的话R3就浪费了,我们可以配置BGP的本地优先级属性来使199.99.2.0/24从R3走,下面是配置过程:
R3(config)#access-list 1
permit 199.99.2.0 0.0.0.255
R3(config)#route-map ccnp
permit 1
R3(config-route-map)#match
ip add 1
R3(config-route-map)#set
local-preference 200
R3(config-route-map)#exit
R3(config)#route-map ccnp
permit 2
R3(config-route-map)#set
local-preference 100
R3(config-route-map)#exit
R3(config)#router bgp 200
R3(config-router)#neighbor
172.16.4.1 route-map ccnp in
R3(config-router)#exit
首先定义一条访问控制列表来匹配这条路由,然后配置策略路由ccnp序号1,匹配ACL 1,设置本地优先级为200(BGP默认本地优先级为100),配置策略路由ccnp序号2,匹配除ACL 1之外其他的路由,设置本地优先级为100,最后在邻居172.16.4.1的in方向上应用。
注意:本地优先属性只在自治系统内部传输,不在自治系统外部传输。
配置好后我们使用clear
ip bgp *来强制重起BGP。然后再到R4上观察BGP路由表:
R4(config)#do show ip bgp
BGP table version is 23, 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
r>i172.16.2.0/24 2.2.2.2 0 100
0 i
r>i172.16.3.0/24 3.3.3.3 0 100
0 i
* i199.99.1.0 3.3.3.3 0 100
0 100 i
*>i 2.2.2.2 0 100
0 100 i
*>i199.99.2.0 3.3.3.3 0 200
0 100 i
* i 2.2.2.2 0 100
0 100 i
与第一次的输出对比一下可以看到,199.99.2.0/24的路径选择发生了变化,选择了从R3走的路由,这样的话写进路由表里的路由的下一跳就是R3了,不在是R2了,但是从199.99.1.0/24走的路由还是选择R2为下一跳。
补充:这里我们使用的命令是neighbor 172.16.4.1
route-map ccnp in,方向是in,还有一种方法是修改方向为out,不过相应的邻居也需要改变,例如:neighbor 172.16.3.1 route-map ccnp out同样也可以达到上面的效果!

实验总结:掌握BGP本地优先属性在BGP路径选择中的作用和配置方法,会配置BGP组来管理一组有相同策略的BGP邻居。

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