使用route-map 配置BGP本地优先级

一、实验目的:
1、掌握基于 route-map的本地优先配置方法。
2、使用 route-map配置可以定置基于目标网络的本地优先级。
二、拓扑图:
使用route-map 配置BGP本地优先级_第1张图片
三、配置BGP基本的配置:
1
、配置各路由器的IP地址和BGP协议。配置完之后,查看一下R3R4的路由表:
R3#sh ip route
………………
Gateway of last resort is not set
 
     172.16.0.0/24 is subnetted, 1 subnets
B       172.16.1.0 [20/0] via 192.168.1.1, 01:13:17
     10.0.0.0/24 is subnetted, 1 subnets
C       10.1.1.0 is directly connected, Serial1/1
     130.130.0.0/24 is subnetted, 1 subnets
B       130.130.1.0 [20/0] via 192.168.1.1, 01:13:17  (选择了EBGP路由作为下一跳)
C    192.168.1.0/24 is directly connected, Serial1/0
B    192.168.2.0/24 [200/0] via 10.1.1.2, 01:11:39
     150.150.0.0/24 is subnetted, 1 subnets
B       150.150.1.0 [20/0] via 192.168.1.1, 01:13:17
R3#
 
R4#sh ip route
………………
Gateway of last resort is not set
 
     172.16.0.0/24 is subnetted, 1 subnets
B       172.16.1.0 [20/0] via 192.168.2.2, 01:22:55
     10.0.0.0/24 is subnetted, 1 subnets
C       10.1.1.0 is directly connected, Serial1/0
     130.130.0.0/24 is subnetted, 1 subnets
B       130.130.1.0 [20/0] via 192.168.2.2, 01:22:55 
B    192.168.1.0/24 [200/0] via 10.1.1.1, 01:24:12
C    192.168.2.0/24 is directly connected, FastEthernet0/0
     150.150.0.0/24 is subnetted, 1 subnets
B       150.150.1.0 [20/0] via 192.168.2.2, 01:22:55  (都选择了EBGP路由作为下一跳)
 
2 、从上述情况看到了:EBGP对等体通告的路由优于IBGP对等体通告的路由。因为R3R4都选择了EBGP作为自己的下一跳。
四、分析路径取向:
1
、在上一篇关于BGP本地优先级的实验文章中,我们知道了在R4上把本地优先级调高。这样R3就会选择高优先级的路由器(100M的快速以太网)走。但是现在的拓扑却不一样了,R2上增加了一个150.150.1.1/24loopback地址。这样如果R3150.150.1.1/24再通过R4走的话就不合适了,因为R3通过R2走只会通过一条串行链路,但如果通过R4走的话。那要通过两条串行链路加上一条快速以太链路。
2
、通过上述分析。我们需要达到以下特殊要求:
A
R3130.130.1.0/24R4(下一跳为10.1.1.2/24)
B
R3150.150.1.0/24 R2(下一跳为192.168.1.1/24)
C
R4130.130.1.0/24150.150.1.0/24R1(下一跳为192.168.2.2/24
D R3的下一跳要为R4
3
、直接把R4的优先级调高,只会让R3到所有目的路由都会走R4。但用route-map基于目标网络的优先级就能很好的实现。直接在 R4上做策略路由,对要到达指定目的地址的路由,直接修改它的本地优先级,并且加一条空路由图,这样其它的网络走向都会不变。
4、由于 BGP的本地优先级默认为 100,所以我们要在 R4上做 route-map针对 130.130.1.0/24的路由上调本地优先级,其值只要比 100大即可,并且为了明确 R3的路径,并在 R4上指定下一跳为 R4自我:
R4(config)#access-list 10 per 130.130.1.0 0.0.0.255 ( 建立一个ACL)
R4(config)#route-map pbr per 10   ( 建立一个名为pbr的路由图)
R4(config-route-map)#match ip add 10 ( 匹配ACL 10)
R4(config-route-map)#set local-preference 150 ( 匹配之后把本地优先级改成150)
R4(config)#router bgp 64513 (进入bgp进程)
R4(config-router)#nei 192.168.2.2 route-map pbr in (指定邻居匹配路由图)
R4(config-route-map)#exit
R4(config)#route-map pbr permit 20 ( 建立空的路由图,让整个网络的其它路由都按默认方式通告)
R4(config)#router bgp 64513
R4(config-router)#nei 10.1.1.1 next-hop-self  (指定下一跳为自我)
5 、在R4clear ip bgp * soft 软涮新一下bgp之后,再来看一下R3R4上的bgp数据库:
R3#sh ip bgp
…………
   Network          Next Hop            Metric LocPrf Weight Path
* i10.1.1.0/24      10.1.1.2                 0    100      0 i
*>                  0.0.0.0                  0         32768 i
*  130.130.1.0/24   192.168.1.1                            0 64512 i
*>i                 10.1.1.2                 0    150      0 64512 i (配置路由图增加了R4优先级)
* i150.150.1.0/24   10.1.1.2                 0    100      0 64512 i
*>                  192.168.1.1              0             0 64512 i (同时R3现在选择了走R2
* i172.16.1.0/24    10.1.1.2                 0    100      0 64512 i
*>                  192.168.1.1              0             0 64512 i
*  192.168.1.0      192.168.1.1              0             0 64512 i
*>                  0.0.0.0                  0             32768 i
*  192.168.2.0      192.168.1.1                            0 64512 i
*>i                 10.1.1.2                 0    100      0 i
 
R4#sh ip bgp
…………
   Network          Next Hop            Metric LocPrf Weight Path
*> 10.1.1.0/24      0.0.0.0                  0         32768 i
* i                 10.1.1.1                 0    100      0 i
*> 130.130.1.0/24   192.168.2.2              0    150      0 64512 i
*> 150.150.1.0/24   192.168.2.2                            0 64512 i (加了空路由图,不影响R4
* i                 192.168.1.1              0    100      0 64512 i
*> 172.16.1.0/24    192.168.2.2              0             0 64512 i
* i                 192.168.1.1              0    100      0 64512 i
*  192.168.1.0      192.168.2.2                            0 64512 i
*>i                 10.1.1.1                 0    100      0 i
*  192.168.2.0      192.168.2.2              0             0 64512 i
*>                  0.0.0.0                  0         32768 i
五、看一下R3R4 的路由表并跟踪验证一下配置效果:
R3#sh ip route
…………
Gateway of last resort is not set
 
     172.16.0.0/24 is subnetted, 1 subnets
B       172.16.1.0 [20/0] via 192.168.1.1, 00:58:13
     10.0.0.0/24 is subnetted, 1 subnets
C       10.1.1.0 is directly connected, Serial1/1
     130.130.0.0/24 is subnetted, 1 subnets
B       130.130.1.0 [200/0] via 10.1.1.2, 00:35:56
C    192.168.1.0/24 is directly connected, Serial1/0
B    192.168.2.0/24 [200/0] via 10.1.1.2, 00:58:14
     150.150.0.0/24 is subnetted, 1 subnets
B       150.150.1.0 [20/0] via 192.168.1.1, 00:58:13
 
R3#traceroute 150.150.1.1
 
Type escape sequence to abort.
Tracing the route to 150.150.1.1
 
  1 192.168.1.1 40 msec *  44 msec
R3#
 
R4#sh ip route
…………
Gateway of last resort is not set
 
     172.16.0.0/24 is subnetted, 1 subnets
B       172.16.1.0 [20/0] via 192.168.2.2, 00:29:55
     10.0.0.0/24 is subnetted, 1 subnets
C       10.1.1.0 is directly connected, Serial1/0
     130.130.0.0/24 is subnetted, 1 subnets
B       130.130.1.0 [20/0] via 192.168.2.2, 00:59:43
B    192.168.1.0/24 [200/0] via 10.1.1.1, 00:59:45
C    192.168.2.0/24 is directly connected, FastEthernet0/0
     150.150.0.0/24 is subnetted, 1 subnets
B       150.150.1.0 [20/0] via 192.168.2.2, 00:29:55
R4#

你可能感兴趣的:(职场,休闲,BGP,本地优先级)