一、实验要求:
1、AS1去AS2走R22、AS2去AS1走R43、AS1去AS3走R64、AS2去AS3走R65、AS3去AS2走R56、AS3去AS1走R57、每个选路规则只能使用一次解决以上步骤的选路方法(事先没有规划):1、local-preference2、MED3、Weight4、Origin5、AS-path6、next-hop二、BGP的选路规则:
1、weight,范围0-65535,默认为0或32768,大优;2、Local-preference,范围0-65535,大优;3、本地起源,起源与本地最优先;4、As-path,经过AS的数量越少越忧,并且EBGP邻居可添加AS的数量;5、起源码小忧,i-igp=0,e-egp=1,?-incomplete=2;6、MED,小优;7、EBGP路由优于IBGP路由,联邦EBGP与普通IBGP不能使用该条进行比较,此时联邦EBGP路由与IBGP相同;8、最近的IGP邻居,iIGP的metric最小的优;9、如果配置了maximum-path [ibgp]n,如果存在多条等价路径,会同时加载到路由表;10、最老的路由,前提必须是external路由,联邦内的EBGP路由当做IBGP 处理;11、最小的router-id优;12、多条路径的router-id相同,那么选择cluster-list长度最短的;13、BGP优选来自最低邻居IP地址的路由,BGP neighbor配置的那个IP地址。三、配置:
R1#sho run | s pre
ip prefix-list AS2 seq 5 permit 3.3.3.0/24ip prefix-list AS2 seq 10 permit 4.4.4.0/24route-map AS2 permit 10match ip address prefix-list AS2set local-preference 80 //解决第一步是用的是local-preferenceR1#sho run | s bgp
router bgp 1bgp log-neighbor-changesnetwork 1.1.1.0 mask 255.255.255.0network 1.1.1.1 mask 255.255.255.255neighbor 2.2.2.2 remote-as 1neighbor 2.2.2.2 update-source Loopback0neighbor 2.2.2.2 next-hop-selfneighbor 100.1.13.3 remote-as 2neighbor 100.1.13.3 route-map AS2 inR2#sho run | s pre
ip prefix-list AS3 seq 5 permit 6.6.6.0/24ip prefix-list AS3 seq 10 permit 7.7.7.0/24ip prefix-list AS3 seq 15 permit 5.5.5.0/24route-map AS3 permit 10match ip address prefix-list AS3set weight 10 //解决第三步用的是weightR2#sho run | s bgp
router bgp 1bgp log-neighbor-changesnetwork 2.2.2.0 mask 255.255.255.0neighbor 1.1.1.1 remote-as 1neighbor 1.1.1.1 update-source Loopback0neighbor 1.1.1.1 next-hop-selfneighbor 100.1.24.4 remote-as 2neighbor 100.1.25.5 remote-as 3neighbor 100.1.26.6 remote-as 3neighbor 100.1.26.6 route-map AS3 inR3#sho run | s pre
ip prefix-list AS1 seq 5 permit 1.1.1.0/24ip prefix-list AS1 seq 10 permit 2.2.2.0/24route-map AS1 permit 10match ip address prefix-list AS1set metric 100 //解决第二步用的是MEDR3#sho run | s bgp
router bgp 2bgp log-neighbor-changesnetwork 3.3.3.0 mask 255.255.255.0neighbor 4.4.4.4 remote-as 2neighbor 4.4.4.4 update-source Loopback0neighbor 4.4.4.4 next-hop-selfneighbor 100.1.13.1 remote-as 1neighbor 100.1.13.1 route-map AS1 inR4#sho run | s pre
ip prefix-list AS3 seq 5 permit 5.5.5.0/24ip prefix-list AS3 seq 10 permit 6.6.6.0/24ip prefix-list AS3 seq 15 permit 7.7.7.0/24route-map AS3 permit 10match ip address prefix-list AS3set origin incomplete //解决第四步用的是originR4#sho run | s bgp
router bgp 2bgp log-neighbor-changesnetwork 4.4.4.0 mask 255.255.255.0neighbor 3.3.3.3 remote-as 2neighbor 3.3.3.3 update-source Loopback0neighbor 3.3.3.3 next-hop-selfneighbor 100.1.24.2 remote-as 1neighbor 100.1.45.5 remote-as 3neighbor 100.1.45.5 route-map AS3 inneighbor 100.1.46.6 remote-as 3R5#sho run | s bgp
router bgp 3bgp log-neighbor-changesnetwork 5.5.5.0 mask 255.255.255.0neighbor 6.6.6.6 remote-as 3neighbor 6.6.6.6 update-source Loopback0neighbor 6.6.6.6 next-hop-selfneighbor 7.7.7.7 remote-as 3neighbor 7.7.7.7 update-source Loopback0neighbor 7.7.7.7 next-hop-selfneighbor 100.1.25.2 remote-as 1neighbor 100.1.45.4 remote-as 2R6#sho run | s prefix-list AS1
ip prefix-list AS1 seq 5 permit 1.1.1.0/24ip prefix-list AS1 seq 10 permit 2.2.2.0/24route-map AS1 permit 10match ip address prefix-list AS1set as-path prepend 1 //第五步用的是as-pathR6#sho run | s prefix-list AS2
ip prefix-list AS2 seq 5 permit 3.3.3.0/24ip prefix-list AS2 seq 10 permit 4.4.4.0/24route-map AS2 permit 10match ip address prefix-list AS2set ip next-hop 5.5.5.5 //第六步用的是next-hopR6#SHO run | s bgp
router bgp 3bgp log-neighbor-changesnetwork 6.6.6.0 mask 255.255.255.0neighbor 5.5.5.5 remote-as 3neighbor 5.5.5.5 update-source Loopback0neighbor 5.5.5.5 next-hop-selfneighbor 7.7.7.7 remote-as 3neighbor 7.7.7.7 update-source Loopback0neighbor 7.7.7.7 next-hop-selfneighbor 100.1.26.2 remote-as 1neighbor 100.1.26.2 route-map AS1 inneighbor 100.1.46.4 remote-as 2neighbor 100.1.46.4 route-map AS2 in//在第六步,R6去AS2,没有使用next-hop时,加表并优的是R4,加表不优的是R5,由于使用了next-hop,
加表并优的路由变成R5,所以才会看到BGP表中R6去AS2的优和不优的加表路由都成了R5。但实验结果能过达到要求。R6#traceroute 3.3.3.3 source 6.6.6.6 numeric
Type escape sequence to abort.Tracing the route to 3.3.3.3VRF info: (vrf in name/id, vrf out name/id)1 100.1.56.5 0 msec 1 msec 0 msec2 100.1.45.4 0 msec 1 msec 0 msec3 100.1.34.3 1 msec * 1 msec//测验结果正确,能满足第六步要求R7#sho run | s bgp
router bgp 3bgp log-neighbor-changesnetwork 7.7.7.0 mask 255.255.255.0neighbor 5.5.5.5 remote-as 3neighbor 5.5.5.5 update-source Loopback0neighbor 5.5.5.5 next-hop-selfneighbor 6.6.6.6 remote-as 3neighbor 6.6.6.6 update-source Loopback0neighbor 6.6.6.6 next-hop-self注意:
本实验的第六步选路方案虽实现了要求,但选路方案并不佳。所以,实验前应对实验中所要用到的选路规则进行推演,以便选出最好的选路方案。
精彩评论