BGP的本地优先级属性和MED属性实验
目的是通过实验加深对BGP的理解
今天我们来看的是BGP的两个属性
一个local_preference属性本地优先级(多出口,谁大谁优先,as之内)
一个MED属性(多入口,as之间,越小越优先)
先上图
配置思路
先将每个物理段配好
保证在RTD上ping路由器RTB的loopback接口能通
然后根据如图建立IBGP对等体关系和EBGP对等体关系
然后是用network命令将loopback网段发布到BGP
和通过import将各自的直连路由发布到BGP
最后修改相应属性
一下是配置和过程:
[rta]dis cu
#
version 5.20, Alpha 1011
#
sysname rta
#
ip unreachables enable
#
interface Serial0/2/0
link-protocol ppp
ip address 10.10.10.1 255.255.255.252
#
interface Serial0/2/1
link-protocol ppp
ip address 10.10.20.1 255.255.255.252
#
interface LoopBack0
ip address 1.1.1.1 255.255.255.255
#
bgp 65000
import-route direct
undo synchronization
peer 10.10.20.2 as-number 65001
peer 10.10.10.2 as-number 65001
#
-------------------------------------
[rtb]dis cu
#
version 5.20, Alpha 1011
#
sysname rtb
#
ip unreachables enable
#
interface Serial0/2/1
link-protocol ppp
ip address 192.168.1.2 255.255.255.0
#
interface Serial0/2/2
link-protocol ppp
shutdown
#
interface Serial0/2/3
link-protocol ppp
ip address 10.10.10.2 255.255.255.252
#
interface LoopBack0
ip address 2.2.2.2 255.255.255.255
#
bgp 65001
default med 100
network 3.3.3.3 255.255.255.255
import-route direct
undo synchronization
peer 10.10.10.1 as-number 65000
peer 3.3.3.3 as-number 65001
peer 3.3.3.3 next-hop-local
peer 3.3.3.3 connect-interface LoopBack0
#
ip route-static 3.3.3.3 255.255.255.255 192.168.1.1
ip route-static 4.4.4.4 255.255.255.255 192.168.1.1
ip route-static 192.168.2.0 255.255.255.0 192.168.1.1
------
[rtc]dis cu
#
version 5.20, Alpha 1011
#
sysname rtc
#
ip unreachables enable
#
interface Serial0/2/1
link-protocol ppp
ip address 192.168.1.1 255.255.255.0
#
interface Serial0/2/8
link-protocol ppp
ip address 192.168.2.1 255.255.255.0
#
interface LoopBack0
ip address 3.3.3.3 255.255.255.255
#
bgp 65001
import-route direct
undo synchronization
peer 4.4.4.4 as-number 65001
peer 2.2.2.2 as-number 65001
peer 4.4.4.4 connect-interface LoopBack0
peer 2.2.2.2 connect-interface LoopBack0
#
ip route-static 2.2.2.2 255.255.255.255 192.168.1.2
ip route-static 4.4.4.4 255.255.255.255 192.168.2.2
-----------
[rtd-bgp]dis cu
#
version 5.20, Alpha 1011
#
sysname rtd
#
ip unreachables enable
#
interface Serial0/2/1
link-protocol ppp
ip address 192.168.2.2 255.255.255.0
#
interface Serial0/2/3
link-protocol ppp
ip address 10.10.20.2 255.255.255.252
#
interface LoopBack0
ip address 4.4.4.4 255.255.255.255
#
bgp 65001
default local-preference 300
network 3.3.3.3 255.255.255.255
import-route direct
undo synchronization
peer 10.10.20.1 as-number 65000
peer 3.3.3.3 as-number 65001
peer 3.3.3.3 next-hop-local
peer 3.3.3.3 connect-interface LoopBack0
#
ip route-static 2.2.2.2 255.255.255.255 192.168.2.1
ip route-static 3.3.3.3 255.255.255.255 192.168.2.1
ip route-static 192.168.1.0 255.255.255.0 192.168.2.1
我们来看下BGP的local_preference属性(多出口)
修改RTD路由器的local_preference之前的tracert
-----------
[rtc]tracert -a 3.3.3.3 1.1.1.1
traceroute to 1.1.1.1(1.1.1.1) 30 hops max,40 bytes packet, press CTRL_C to break
1 192.168.1.2 4294967295 ms <1 ms 16 ms
2 1.1.1.1 4 ms 10 ms <1 ms
[rtc]tracert -a 3.3.3.3 1.1.1.1
traceroute to 1.1.1.1(1.1.1.1) 30 hops max,40 bytes packet, press CTRL_C to break
1 192.168.1.2 15 ms 4 ms <1 ms
2 1.1.1.1 20 ms <1 ms <1 ms
修改RTD路由器的local_preference之后
[rtc]tracert -a 3.3.3.3 1.1.1.1
traceroute to 1.1.1.1(1.1.1.1) 30 hops max,40 bytes packet, press CTRL_C to break
1 192.168.2.2 13 ms <1 ms <1 ms
2 1.1.1.1 5 ms <1 ms 4294967290 ms
当然ip routing
当然ip routing-table肯定也是变化的
这个是修改之前的
[rtc-bgp]dis ip routing-table
Routing Tables: Public
Destinations : 18 Routes : 18
Destination/Mask Proto Pre Cost NextHop Interface
1.1.1.1/32 BGP 255 0 2.2.2.2 S0/2/1
这个是是修改之后的
[rtc]dis ip routing-table
Routing Tables: Public
Destinations : 18 Routes : 18
Destination/Mask Proto Pre Cost NextHop Interface
1.1.1.1/32 BGP 255 0 4.4.4.4 S0/2/8
我们再来看下BGP的MED属性(多入口,相当于花销,越小越优先)
修改之前路由是走10.10.10.2
<rta>tracert -a 1.1.1.1 3.3.3.3
traceroute to 3.3.3.3(3.3.3.3) 30 hops max,40 bytes packet, press CTRL_C to break
1 10.10.10.2 4294967295 ms 10 ms 15 ms
2 3.3.3.3 4294967291 ms 16 ms 4 ms
这个是路由表
<rta>dis ip routing-table
Routing Tables: Public
Destinations : 18 Routes : 18
Destination/Mask Proto Pre Cost NextHop Interface
1.1.1.1/32 Direct 0 0 127.0.0.1 InLoop0
2.2.2.2/32 BGP 255 0 10.10.10.2 S0/2/0
3.3.3.3/32 BGP 255 0 10.10.10.2 S0/2/0
这个是BGP的routing-table表
<rta>dis bgp routing-table
Total Number of Routes: 21
BGP Local router ID is 1.1.1.1
Status codes: * - valid, > - best, d - damped,
h - history, i - internal, s - suppressed, S - Stale
Origin : i - IGP, e - EGP, ? - incomplete
Network NextHop MED LocPrf PrefVal Path/Ogn
*> 1.1.1.1/32 0.0.0.0 0 0 ?
*> 2.2.2.2/32 10.10.10.2 0 0 65001?
*> 3.3.3.3/32 10.10.10.2 0 0 65001i
* 10.10.20.2 0 0 65001i
*> 4.4.4.4/32 10.10.20.2 0 0 65001?可以看出现在最优的是RTB这个路由器
那么我们来修改下MED属性
多入口,相当于花销,越小越优先
将RTB的MED设置的大一点就不会走这个路由器了
效果出来了
<rta>tracert -a 1.1.1.1 3.3.3.3
traceroute to 3.3.3.3(3.3.3.3) 30 hops max,40 bytes packet, press CTRL_C to break
1 10.10.20.2 4294967295 ms 15 ms 4294967291 ms
2 3.3.3.3 <1 ms 10 ms 20 ms
--------------
<rta>dis bgp routing-table
Total Number of Routes: 21
BGP Local router ID is 1.1.1.1
Status codes: * - valid, > - best, d - damped,
h - history, i - internal, s - suppressed, S - Stale
Origin : i - IGP, e - EGP, ? - incomplete
Network NextHop MED LocPrf PrefVal Path/Ogn
*> 1.1.1.1/32 0.0.0.0 0 0 ?
*> 2.2.2.2/32 10.10.10.2 100 0 65001?
*> 3.3.3.3/32 10.10.20.2 0 0 65001i
* 10.10.10.2 100 0 65001i
-----------
<rta>dis ip routing-table
Routing Tables: Public
Destinations : 18 Routes : 18
Destination/Mask Proto Pre Cost NextHop Interface
1.1.1.1/32 Direct 0 0 127.0.0.1 InLoop0
2.2.2.2/32 BGP 255 100 10.10.10.2 S0/2/0
3.3.3.3/32 BGP 255 0 10.10.20.2 S0/2/1
去往3.3.3.3 的路由以及选择了下面的RTD路由器
- 下一篇:ospf中的几个特殊区域
- 上一篇:解决L2TP VPAN实验中获取不到IP问题