基於策略的路由提供了一種機制,用於根據網路管理員定義的策略來表示和實施資料包的轉發/路由。基於策略的路由應用於傳入資料包,並使用路由對映定義策略。根據路由對映中定義的標準,將資料包轉發/路由到相應的下一跳。本文檔為通過IPv6進行的基於策略的路由提供了一個配置示例。
本文件沒有特定需求。
注意:有關限制的詳細資訊,請參閱IPv6 PBR的限制。
本文件所述內容不限於特定軟體和硬體版本。
本文中的資訊是根據特定實驗室環境內的裝置所建立。文中使用到的所有裝置皆從已清除(預設)的組態來啟動。如果您的網路正在作用,請確保您已瞭解任何指令可能造成的影響。
如需文件慣例的詳細資訊,請參閱思科技術提示慣例。
在此配置方案中,基於策略的路由(PBR)配置在WAN路由器上,而策略路由應用在fa1/0介面上。根據來自網路的配置流量,6001:66:66:66::6被重定向到中間路由器。這是通過基於策略的路由實現的。此配置示例將下一跳設定為2001:10:10:10::2。如果流量來源為6001:66:66::6,則流量將重定向到中間路由器,然後到達網際網路路由器。
註:使用Command Lookup Tool(僅限註冊客戶)查詢有關本文檔中使用的命令的更多資訊。
本檔案會使用以下網路設定:
本檔案會使用以下設定:
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 |
初始版本 |