交换机
园区网交换机
数据中心与云计算交换机
行业精选交换系列
意图网络指挥官
无线
放装型无线接入点
墙面型无线接入点
智分无线接入点
室外无线接入点
场景化无线
行业精选无线系列
无线管理与应用
功能介绍:
route-map 路由图,通过route-map工具可以对路由更新进行控制,并且能够修改路由的属性。
一、组网要求
在R2上把rip路由重分发进ospf,并且在重分发时进行路由过滤,只允许路由 172.16.1.32/28、172.16.1.48/29、172.16.1.56/30重分发进ospf ,引入的外部路由类型为OE1,metric为50。
二、组网拓扑
三、配置要点
1、基本ip地址配置
2、R1、R2启用rip协议,并将对应接口通告到rip进程
3、R2、R3启用ospf协议,并将对应接口通告到ospf进程
4、在R2上把rip学习到的路由重分发进ospf
5、通过acl或前缀列表,把需要学习的路由匹配出来
6、配置route-map
7、R2将rip路由重分发进ospf,调用route-map做路由控制
三、配置步骤
1、基本ip地址配置
Ruijie(config)#hostname R1
R1(config)#interface fastEthernet 0/0
R1(config-if-FastEthernet 0/0)#ip address 192.168.1.1 255.255.255.0
R1(config-if-FastEthernet 0/0)#exit
R1(config)#interface loopback 1
R1(config-if-Loopback 1)#ip address 172.16.1.1 255.255.255.224
R1(config-if-Loopback 1)#exit
R1(config)#interface loopback 2
R1(config-if-Loopback 2)#ip address 172.16.1.33 255.255.255.240
R1(config-if-Loopback 2)#exit
R1(config)#interface loopback 3
R1(config-if-Loopback 3)#ip address 172.16.1.49 255.255.255.248
R1(config-if-Loopback 3)#exit
R1(config)#interface loopback 4
R1(config-if-Loopback 4)#ip address 172.16.1.57 255.255.255.252
R1(config-if-Loopback 4)#exit
Ruijie(config)#hostname R2
R2(config)#interface fastEthernet 0/2
R2(config-if-FastEthernet 0/2)#ip address 192.168.1.2 255.255.255.0
R2(config-if-FastEthernet 0/2)#exit
R2(config)#interface fastEthernet 0/0
R2(config-if-FastEthernet 0/0)#ip address 192.168.2.1 255.255.255.0
R2(config-if-FastEthernet 0/0)#exit
Ruijie(config)#hostname R3
R3(config)#interface fastEthernet 0/1
R3(config-if-FastEthernet 0/1)#ip address 192.168.2.2 255.255.255.0
R3(config-if-FastEthernet 0/1)#exit
2、R1、R2启用rip协议,并将对应接口通告到rip进程
R1(config)#router rip
R1(config-router)#version 2 //启用rip版本2
R1(config-router)#no auto-summary //关闭自动汇总
R1(config-router)#network 172.16.0.0 //将172.16.0.0的主类网络通告到rip进程
R1(config-router)#network 192.168.1.0
R1(config-router)#exit
R2(config)#router rip
R2(config-router)#version 2
R2(config-router)#no auto-summary
R2(config-router)#network 192.168.1.0
R2(config-router)#exit
3、R2、R3启用ospf协议,并将对应接口通告到ospf进程
R2(config)#router ospf 1 //启用ospf进程 1
R2(config-router)#network 192.168.2.1 0.0.0.0 area 0 //将192.168.2.1对应的接口通告到ospf 进程1的区域 0
R2(config-router)#exit
R3(config)#router ospf 1
R3(config-router)#network 192.168.2.2 0.0.0.0 area 0
R3(config-router)#exit
4、在R2上把rip学习到的路由重分发进ospf
R2(config)#router ospf 1
R2(config-router)#redistribute rip subnets //将rip路由重分发进ospf,必须加subnet
R2(config-router)#exit
5、通过acl或前缀列表,把需要学习的路由匹配出来
注意:
1)匹配路由条目的工具有acl和前缀列表两种,只要选择其中一种就可以
2)若需要匹配一个网段下的几个子网路由,那么用前缀列表会更方便一线,当然用acl也是可以的,只是要写多个条目
如下示例,匹配路由条目172.16.1.32/27、172.16.1.48/28和172.16.1.56/29,acl需要写3个ace条目,前缀列表只要1个条目
1)使用acl匹配路由条目
注意:
此处acl匹配的是路由条目,掩码用0.0.0.0精确匹配对应的路由条目
R2(config)#ip access-list standard 1
R2(config-std-nacl)#10 permit 172.16.1.32 0.0.0.0
R2(config-std-nacl)#20 permit 172.16.1.48 0.0.0.0
R2(config-std-nacl)#30 permit 172.16.1.56 0.0.0.0
R2(config-std-nacl)#exit
2)使用前缀列表匹配路由条目
注意:
1)前缀列表只能用来匹配路由条目,不能用来做数据包过滤
2)前缀列表匹配的是一个网段下的子网,ge代表大于等于多少位掩码,le代表小于多少位掩码
3)前缀列表也是从上往下匹配,与acl的匹配顺序及规则是一样的
R2(config)#ip prefix-list ruijie seq 10 permit 172.16.1.0/24 ge 28 le 30 //定义前缀列表ruijie,匹配前缀为172.16.1.0/24,子网掩码大于等于28小于等于30的路由条目
6、配置route-map
注意:
1)route-map除了可以用来做路由过滤,还能够修改路由的属性
2)route-map可以match的条件比较多(包括 路由条目、metric、metric-type等条件),distribute-list只能匹配路由条目
3)route-map的执行顺序从上到下,最后隐含一条deny any
4)route-map的执行逻辑如下:
route-map aaa permit 10
match x y z //多个match条件横着写,是or的关系,只要满足其中一个条件,该match语句就算匹配
match a
set b //多个set语句竖着写,会同时执行多个set动作
set c
route-map aaa permit 20
match p
match q //多个match条件竖着写,是and的关系,要多个条件同时满足,该match语句才算匹配
set r
route-map aaa deny any (系统隐含)
执行逻辑如下:
If (x or y or z)
then set(b and c)
else if (p and q)
then set r
else deny
route-map的match ip address 可以匹配acl列表,也可以匹配前缀列表,只要选择其中一种就可以,如下分别示例:
1)match ip address 使用acl列表匹配
R2(config)#route-map aaa permit 10
R2(config-route-map)#match ip address 1 //匹配acl列表1的路由条目
R2(config-route-map)#set metric-type type-1 //配置引入的外部路由类型为类型1
R2(config-route-map)#set metric 50 //配置引入的外部路由 metric为50
R2(config-route-map)#exit
2)match ip address 使用前缀列表匹配
R2(config)#route-map aaa permit 10
R2(config-route-map)#match ip address prefix-list ruijie //匹配前缀列表ruijie的路由条目
R2(config-route-map)#set metric-type type-1
R2(config-route-map)#set metric 50
R2(config-route-map)#exit
7、R2将rip路由重分发进ospf,调用route-map做路由控制
注意:
route-map的调用位置可以为路由重分发以及BGP协议neighbor指邻居
R2(config)#router ospf 1
R2(config-router)#redistribute rip subnets route-map aaa //将rip路由重分发进ospf时,调用route-map aaa
R2(config-router)#exit
补充:
BGP协议指neighbor调用route-map的配置命令如下
R2(config)#router bgp 1
R2(config-router)#neighbor 10.1.1.1 route-map aaa in // 方向in代表对从该邻居学习的路由做控制,方向out代表发给该邻居的路由做控制(对bgp邻居使用route-map做路由控制,配置route-map后,需要通过软清除bgp邻居的路由,才能使配置生效,该操作请勿在业务高峰期进行)
四、配置验证
查看R3的路由条目,若R3学习到的路由条目为 172.16.1.32/28、172.16.1.48/29、172.16.1.56/30,且为OE1的路由,并叠加内部cost,则route-map做路由控制配置正确
R3#show ip route
Codes: C - connected, S - static, R - RIP, B - BGP
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
Gateway of last resort is no set
O E1 172.16.1.32/28 [110/51] via 192.168.2.1, 00:03:14, FastEthernet 0/1
O E1 172.16.1.48/29 [110/51] via 192.168.2.1, 00:03:14, FastEthernet 0/1
O E1 172.16.1.56/30 [110/51] via 192.168.2.1, 00:03:14, FastEthernet 0/1
C 192.168.2.0/24 is directly connected, FastEthernet 0/1
C 192.168.2.2/32 is local host.