基于策略的路由提供一种机制,用于根据网络管理员定义的策略来表示和实施数据包的转发/路由。基于策略的路由应用于传入数据包,并使用路由映射定义策略。根据路由映射中定义的条件,数据包会转发/路由到适当的下一跳。本文档提供了通过IPv6的基于策略的路由的示例配置。
本文档没有任何特定的要求。
注:有关限制的详细信息,请参阅IPv6 PBR的限制。
本文档不限于特定的软件和硬件版本。
本文档中的信息都是基于特定实验室环境中的设备编写的。本文档中使用的所有设备最初均采用原始(默认)配置。如果您使用的是真实网络,请确保您已经了解所有命令的潜在影响。
有关文档规则的详细信息,请参阅 Cisco 技术提示规则。
在此配置方案中,在WAN路由器上配置基于策略的路由(PBR),并在fa1/0接口上应用策略路由。根据来自网络的配置流量,6001:66:66:66::6被重定向到中间路由器。这是通过基于策略的路由实现的。此配置示例将下一跳设置为2001:10:10:10::2。如果流量源为6001:66:66:66::6,则流量将重定向到中间路由器,然后到达Internet路由器。
注意:使用命令查找工具(仅限注册客户)可查找有关本文档中使用的命令的详细信息。
本文档使用以下网络设置:
本文档使用以下配置:
WAN路由器配置 |
---|
WAN_Router# ! ipv6 unicast-routing ipv6 cef ! interface FastEthernet0/0 no ip address duplex auto speed 100 ipv6 address 1001:10:10:10::1/64 ipv6 enable ipv6 eigrp 55 ! interface FastEthernet0/1 no ip address duplex auto speed 100 ipv6 address 2001:10:10:10::1/64 ipv6 enable ipv6 eigrp 55 ! interface FastEthernet1/0 no ip address speed 100 full-duplex ipv6 address 3001:10:10:10::1/64 ipv6 enable ipv6 eigrp 55 ipv6 policy route-map ipv6 ! ipv6 router eigrp 55 router-id 3.3.3.3 no shutdown ! route-map ipv6 permit 10 match ipv6 address ALLOW_INTERNAL_NETWORK set ipv6 next-hop 2001:10:10:10::2 ! ipv6 access-list ALLOW_INTERNAL_NETWORK permit ipv6 6001:66:66:66::/64 any !--- Creates IPv6 access-list ALLOW_INTERNAL_NETWORK !--- and permits any ipv6 address in the network 6001:66:66:66::/64 ! |
中间路由器配置 |
---|
Intermediate_Router# ! ip cef ! ipv6 unicast-routing ipv6 cef ! interface FastEthernet0/0 no ip address duplex auto speed 100 ipv6 address 2001:10:10:10::2/64 ipv6 enable ipv6 eigrp 55 ! interface FastEthernet0/1 no ip address duplex auto speed 100 ipv6 address 4001:10:10:10::2/64 ipv6 enable ipv6 eigrp 55 ! ipv6 router eigrp 55 router-id 2.2.2.2 no shutdown ! |
Internet路由器配置 |
---|
Internet_Router# ! ip cef ! ipv6 unicast-routing ipv6 cef ! ! interface Loopback10 no ip address ipv6 address 5001:55:55:55::5/64 ipv6 enable ! interface FastEthernet0/0 no ip address duplex auto speed 100 ipv6 address 1001:10:10:10::2/64 ipv6 enable ipv6 eigrp 55 ! interface FastEthernet0/1 no ip address duplex auto speed 100 ipv6 address 4001:10:10:10::1/64 ipv6 enable ipv6 eigrp 55 ! ipv6 route ::/64 Loopback10 ipv6 router eigrp 55 router-id 1.1.1.1 no shutdown redistribute connected ! |
本地路由器配置 |
---|
Local_Router# ! ip cef ! ipv6 unicast-routing ipv6 cef ! ! interface Loopback10 no ip address ipv6 address 6001:66:66:66::6/64 ipv6 enable ! interface FastEthernet0/0 no ip address speed 100 full-duplex ipv6 address 3001:10:10:10::2/64 ipv6 enable ! ! ipv6 route ::/64 FastEthernet0/0 !--- Static route is configured in the local router. ! |
从Local_Router发出ping命令以检查基于策略的路由:
Local_Router#ping ipv6 5001:55:55:55::5 Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 5001:55:55:55::5, timeout is 2 seconds: !!!!! Success rate is 100 percent (5/5), round-trip min/avg/max = 8/40/76 ms
在WAN_Router上启用此debug命令,以查看基于策略的路由是否正常运行:
Wan_Router# debug ipv6 policy IPv6 policy-based routing debugging is on Wan_Router# *Mar 1 04:10:43.846: IPv6 PBR (CEF): FastEthernet1/0, matched src 6001:66:66:66::6 dst 5001:55:55:55::5 protocol 17 *Mar 1 04:10:43.846: IPv6 PBR (CEF): FIB policy route via FastEthernet0/1 *Mar 1 04:10:46.826: IPv6 PBR (CEF): FastEthernet1/0, matched src 6001:66:66:66::6 dst 5001:55:55:55::5 protocol 17 *Mar 1 04:10:46.826: IPv6 PBR (CEF): FIB policy route via FastEthernet0/1 *Mar 1 04:10:49.834: IPv6 PBR (CEF): FastEthernet1/0, matched src 6001:66:66:66::6 dst 5001:55:55:55::5 protocol 17 *Mar 1 04:10:49.834: IPv6 PBR (CEF): FIB policy route via FastEthernet0/1 *Mar 1 04:10:52.838: IPv6 PBR (CEF): FastEthernet1/0, matched src 6001:66:66:66::6 dst 5001:55:55:55::5 protocol 17 *Mar 1 04:10:52.838: IPv6 PBR (CEF): FIB policy route via FastEthernet0/1
IPv4和IPv6 PBR不能在接口上共存,如以下示例输出所示:
route-map BGP-NLGP-MSP-I2RandE-ALLOW permit 10 description For allowing BGP sessions and setting next hops match ipv6 address BGP-NLGP-MSP-I2RandE-IPV6-ALLOW ! route-map BGP-NLGP-MSP-I2RandE-ALLOW permit 20 match ip address BGP-NLGP-MSP-I2RandE-IPV4-ALLOW ! route-map BGP-NLGP-MSP-I2RandE-ALLOW permit 30 set ip next-hop 192.168.48.41 set ipv6 next-hop 2620:32:0:1000::2 !
要应用IPv4和IPv6,您必须对IPv4和IPv6使用两个单独的路由映射,然后在接口上应用它们。以下输出示例提供:
route-map IPv6 permit 10 match ipv6 address BGP-NLGP-MSP-I2RandE-IPV6-ALLOW set ipv6 next-hop 2620:32:0:1000::2 route-map IPV4 permit 10 match ip address BGP-NLGP-MSP-I2RandE-IPV4-ALLOW set ip next-hop 192.168.48.41
Router#show run interface e0/0 Building configuration... Current configuration : 163 bytes ! interface Ethernet0/0 ip address 10.57.253.109 255.255.255.252 ip policy route-map IPV4 ipv6 address 2001:468:1900:70::1/64 ipv6 policy route-map IPv6 end
版本 | 发布日期 | 备注 |
---|---|---|
1.0 |
20-Dec-2010 |
初始版本 |