CCNP-34 BGP 4

简介:


CCNP-34 BGP 4

实验拓扑:

实验要求:按照拓扑将 4 台路由器分别配置在 AS 100/200 中, R1 R2 R3 成为 EBGP PEER R4 R2 R3 成为 IBGP PEER ,在 R4 上起 loopback 接口,配置完成后在 R1 上观察 BGP 路由表,看看 R4 loopback 接口的网络是通过哪台路由器学习到的,然后通过修改 MED 属性,使之从另外一台路由器学习 R4 loopback 网络。
试验目的:掌握 BGP 属性中的 MED 属性的作用和配置方法。

实验配置:
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 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 3.3.3.3 remote-as 200
R2(config-router)#neighbor 4.4.4.4 update-source loopback 0
R2(config-router)#neighbor 3.3.3.3 update-source loopback 0
R2(config-router)#exit
R2(config)#ip route 3.3.3.0 255.255.255.0 172.16.2.2
R2(config)#ip route 4.4.4.0 255.255.255.0 172.16.2.2
R2(config)#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)#ip add 172.16.4.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 bgp 200
R3(config-router)#neighbor 172.16.4.1 remote-as 100
R3(config-router)#neighbor 2.2.2.2 remote-as 200
R3(config-router)#neighbor 4.4.4.4 remote-as 200
R3(config-router)#neighbor 2.2.2.2 update-source loopback 0
R3(config-router)#neighbor 4.4.4.4 update-source loopback 0
R3(config-router)#exit
R3(config)#ip route 2.2.2.0 255.255.255.0 172.16.3.1
R3(config)#ip route 4.4.4.0 255.255.255.0 172.16.3.1
R3(config)#exit
 
R4
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 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 loop0
R4(config-if)#ip add 4.4.4.4 255.255.255.0
R4(config-if)#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 3.3.3.3 remote-as 200
R4(config-router)#neighbor 2.2.2.2 update-source loopback 0
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
R4(config)#ip route 2.2.2.0 255.255.255.0 172.16.2.1
R4(config)#ip route 3.3.3.0 255.255.255.0 172.16.3.2
R4(config)#ip route 172.16.1.0 255.255.255.0 172.16.2.1
R4(config)#ip route 172.16.4.0 255.255.255.0 172.16.3.2
R4(config)#exit
 
好了,基本的 BGP 配置完成了,配置静态路由的作用是因为 BGP 的同步特性要求。然后我们在 R1 show 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
可以看到到 10.10.10 .0/24 20.20.20.0/24 的路由都是从 172.16.1.2 学到的,也就是从 R2 学到的,默认的 Metric 0 ,那么为什么不是从 R3 学到的呢?后面我会讲到 BGP 路由选择路径的方法和顺序。
如果这样配置的话, R3 基本上没有什么流量,所有的流量都是通过 R2 走的,下面我们来配置 BGP Metric 属性来把 20.20.20 .0/24 的流量分担到 R3 上:
R2(config)#access-list 10 permit 10.10.10.0 0.0.0.255
R2(config)#route-map med_10 permit 10
R2(config-route-map)#match ip add 10
R2(config-route-map)#set metric 100
R2(config-route-map)#exit
R2(config)#route-map med_10 permit 20
R2(config-route-map)#set metric 200
R2(config-route-map)#exit
R2(config)#router bgp 200
R2(config-router)#neighbor 172.16.1.1 route-map med_10 out
R2(config-router)#exit
 
R3(config)#access-list 20 permit 20.20.20.0 0.0.0.255
R3(config)#route-map med_20 permit 10
R3(config-route-map)#match ip add 20
R3(config-route-map)#set metric 100
R3(config-route-map)#exit
R3(config)#route-map med_20 permit 20
R3(config-route-map)#set metric 200
R3(config-route-map)#exit
R3(config)#router bgp 200
R3(config-router)#neighbor 172.16.4.1 route-map med_20 out
R3(config-router)#exit
首先定义一条访问控制列表来设置感兴趣的路由,然后配置策略路由,匹配之前定义的 ACL ,然后设置 MED 属性, BGP 会优先选择 MED 属性值低的路径,最后把定义好的策略路由应用到 BGP 邻居配置中,方向为 OUT MED 属性只在 EBGP 对等体之间传输)。
都设置好后,我们在 R1 clear ip bgp * 强制重起一下 BGP 的进程,然后再 show 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.1.2             100             0 200 i
*                   172.16.4.2             200             0 200 i
*  20.20.20.0/24    172.16.1.2             200             0 200 i
*>                  172.16.4.2             100             0 200 i
观察一下与刚才有什么不同? Metric 属性值变了,从 172.16.1.2 学到的 10.10.10 .0/24 Metric 变为 100 20.20.20.0/24 Metric 变为 200 ,同样,从 172.16.4.2 学到的 10.10.10.0/24 Metric 变成了 200 20.20.20.0/24 Metric 变成了 100 ,这样的话 R1 上学到的 10.10.10.0/24 的路由就是通过 R2 学到的, 20.20.20.0/24 学到的路由是从 R3 学到的,这样就有效的分担了 R2 上的流量。
再来看一下 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/100] via 172.16.4.2, 00:01:05
     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/100] via 172.16.1.2, 00:01:05

实验总结:掌握在 BGP 路径选择中 MED 属性的作用,并且掌握修改 MED 属性的方法。






















本文转自loveme2351CTO博客,原文链接: http://blog.51cto.com/loveme23/54451  ,如需转载请自行联系原作者

相关文章
|
负载均衡 算法 网络架构
|
网络协议 网络架构
|
网络协议
|
网络协议 网络架构
|
网络协议 网络架构
|
网络协议 网络架构 iOS开发