本文檔旨在演示使用全域性路由表從基於多協定標籤交換(MPLS)的VPN訪問網際網路所使用的配置示例。
在某些網路方案中,除了繼續維護公司站點之間的VPN連線之外,還需要通過基於MPLS的VPN訪問網際網路。此示例配置側重於從VPN路由和轉發(VRF)提供網際網路訪問,其中包含到網際網路網關路由器(IGW)的預設路由。
要完全理解本文件的內容,需要對MPLS轉發和MPLS VPN有基本的瞭解。
本檔案中的資訊是根據以下軟體和硬體版本。
Cisco IOS®軟體版本12.1(3)T。版本12.0(5)T包括MPLS VPN功能
3600系列或更高版本中的任何思科路由器,例如Cisco 3660或7206
本文中的資訊是根據特定實驗室環境內的裝置所建立。文中使用到的所有裝置皆從已清除(預設)的組態來啟動。如果您在即時網路中工作,請確保在使用任何命令之前瞭解其潛在影響。
在此示例配置中,存在以下策略:
連線到Internet的路由器連線到MPLS網路。它可能將邊界網關協定(BGP)路由注入全域性路由表,也可能不會。
注意:PE路由器瞭解BGP。Gigabit交換器路由器(GSR)(作為提供者核心路由器執行)等路由器根本不會執行BGP。
VRF不需要具有來自網際網路的完整路由表(全域性BGP表),因此靜態預設路由被放入指向IGW的全域性下一跳地址的VRF中。
VPN客戶使用可在全域性Internet路由表中路由的註冊唯一地址範圍。建議不要使用本文檔中討論的訪問方法,因為客戶的網路中只有私有地址。
本檔案中使用的是以下縮寫:
CE — 客戶邊緣路由器
PE — 提供商邊緣路由器
P — 提供商核心路由器
如需文件慣例的詳細資訊,請參閱思科技術提示慣例。
請參閱網路圖表以瞭解此組態的圖示。在本示例中,CE 1和CE 2位於同一個VPN中。它們在customer1 VRF下配置,因為VRF不需要具有來自Internet的完整路由表(根據本文檔的背景理論部分中的策略)。
在CE 1的customer1 VRF中配置一條指向IGW的靜態預設路由。通過在customer1 VRF中放置靜態預設路由,與customer1 VRF中包含的任何路由都不匹配的資料包將傳送到IGW。
註:由於Internet網關下一跳192.168.67.1不是customer1 VRF的一部分,因此在customer1 VRF下配置一條預設路由,該路由指向Internet網關介面s8/0 IP 192.168.67.1。通往192.168.67.1的路由不在customer1 VRF內,因此您需要在customer1 VRF下配置的靜態預設路由內配置一個全域性關鍵字。global關鍵字指定靜態路由的下一跳地址在全域性路由表中解析,而不是在customer1 VRF中解析。
以下是靜態路由的示例。
ip route vrf customer1 0.0.0.0 0.0.0.0 192.168.67.1 global
在customer1 VRF中使用帶global關鍵字的靜態路由可確保將發往Internet的所有資料包路由到Internet網關,然後路由到Internet。
注意: PE 1中的預設路由配置為指向Internet網關的串列介面IP地址(192.168.67.1),而不是環回地址(10.1.1.6)。 這樣可避免在網際網路網關和網際網路(R7)之間的連線發生故障時使路由黑洞。 如果預設路由指向Internet網關的環回地址,並且Internet網關 — R7之間的連線中斷,則所有資料包將繼續路由到Internet網關。之所以會出現這種情況,是因為回送位址保持開啟(與介面s8/0關閉時從全域路由表中撤銷的192.168.67.1不同),且預設路由繼續存在於路由表中。
下一步是確保從網際網路返回到目標CE 1網路11.11.11.0/24的資料包從網際網路網關路由到PE 1並通過MPLS核心路由到CE 1。這可以通過在PE 1的全域性路由表中為指向Serial 8/0介面的CE 1網路配置靜態路由來實現。將其重新分配到開放最短路徑優先(OSPF)中,以便Internet網關在其全域性路由表中擁有該路由。這允許Internet網關將來自Internet的所有資料包路由到PE 1,並路由到CE 1以外的最終目標。
以下示例是在PE 1上的配置中使用的ip route命令。
ip route 11.11.11.0 255.255.255.0 Serial8/0 192.168.10.1
注意:全域性路由表中配置的上述靜態路由是除customer1 VRF內配置的靜態路由之外的,後者用於VPN網路層可達性資訊(NLRI)。 在PE 1上,其配置如下所示。
ip route vrf customer1 11.11.11.0 255.255.255.0 192.168.10.1
注意:要查詢有關本文檔中使用的命令的其他資訊,請使用命令查詢工具(僅限註冊客戶)。
本文檔使用下圖所示的網路設定。
本文檔使用如下所示的配置。
CE 1 |
---|
version 12.2 ! hostname CE-1 ! ip subnet-zero ! interface Loopback0 ip address 10.1.1.1 255.255.255.255 ! interface Loopback2 ip address 11.11.11.1 255.255.255.0 ! interface Serial8/0 ip address 192.168.10.1 255.255.255.252 !--- The interface is connected to PE 1. ! ip classless ip route 0.0.0.0 0.0.0.0 192.168.10.2 !--- This is the default route to route all packets to PE 1. ! |
PE 1 |
---|
version 12.2 ! hostname PE-1 ! ip subnet-zero ! ip vrf customer1 !--- This configured VRF customer1. rd 100:1 !--- This configured the route distiguisher for VRF. route-target export 1:1 route-target import 1:1 !--- This configured the export and import policies into VRF. ! ip cef !--- This enabled Cisco Express Forwarding (CEF) switching. ! interface Loopback0 ip address 10.1.1.2 255.255.255.255 ! interface Ethernet0/0 !--- It is connected to P router. ip address 10.10.23.2 255.255.255.0 tag-switching ip !--- MPLS switching is enabled. ! interface Serial8/0 ! Connected to CE-1 ip vrf forwarding customer1 !--- Route forwarding based on customer1 VRF is enabled. ip address 192.168.10.2 255.255.255.252 ! router ospf 1 log-adjacency-changes redistribute static subnets network 0.0.0.0 255.255.255.255 area 0 ! router bgp 100 no synchronization bgp log-neighbor-changes neighbor 10.1.1.4 remote-as 100 !--- Neighbor relationship with PE 2 is established. neighbor 10.1.1.4 update-source Loopback0 neighbor 10.1.1.4 next-hop-self no auto-summary ! address-family ipv4 vrf customer1 !--- The address-family configuration mode specifies IPv4 unicast !---address prefixes for customer1 VRF. no auto-summary no synchronization network 11.11.11.0 mask 255.255.255.0 !--- CE 1 network 11.11.11.0/24 to PE 2 is announced. network 192.168.10.0 mask 255.255.255.252 exit-address-family ! address-family vpnv4 !--- This is the address-family VPNV4 configuration mode for !--- configuring BGP sessions. neighbor 10.1.1.4 activate neighbor 10.1.1.4 send-community extended no auto-summary exit-address-family ! ip classless ip route 11.11.11.0 255.255.255.0 Serial8/0 192.168.10.1 !--- The static route in the global routing table is pointing to !--- the interface connected to CE 1. ip route vrf customer1 0.0.0.0 0.0.0.0 192.168.67.1 global !--- The static default route under customer1 VRF, routing packets !--- outside of VPN to the Internet gateway. ! routes ip route vrf customer1 11.11.11.0 255.255.255.0 192.168.10.1 !--- The static route for network 11.11.11.0/24 (CE-1 Network) under !---customer1 VRF ensures the reachability of CE 1 network from the !--- other VPN sites. |
P |
---|
version 12.2 ! hostname P ! ip subnet-zero ! ip cef !--- CEF switching is enabled. ! interface Loopback0 ip address 10.1.1.3 255.255.255.255 ! interface Ethernet0/0 !--- This is connected to PE 1. ip address 10.10.23.3 255.255.255.0 tag-switching ip !--- MPLS switching is enabled. ! interface Ethernet1/0 !--- This is connected to PE 2. ip address 10.10.34.3 255.255.255.0 tag-switching ip ! interface Ethernet2/0 !--- This is connected to the Internet gateway. ip address 10.10.36.3 255.255.255.0 tag-switching ip ! router ospf 1 log-adjacency-changes network 0.0.0.0 255.255.255.255 area 0 |
IGW |
---|
version 12.2 ! hostname IGW ! ip subnet-zero ! ip cef !--- This enabled CEF switching. ! interface Loopback0 ip address 10.1.1.6 255.255.255.255 ! interface Ethernet2/0 !--- This is connected to P router. ip address 10.10.36.6 255.255.255.0 tag-switching ip ! interface Serial8/0 !--- This is connected to Internet R7. ip address 192.168.67.1 255.255.255.252 ! router ospf 1 log-adjacency-changes network 0.0.0.0 255.255.255.255 area 0 ! router bgp 100 no synchronization bgp log-neighbor-changes network 11.11.11.0 mask 255.255.255.0 network 22.22.22.0 mask 255.255.255.0 neighbor 192.168.67.2 remote-as 200 no auto-summary |
PE 2 |
---|
version 12.2 ! hostname PE-2 ! ip subnet-zero ! ip vrf customer1 !--- Customer1 VRF is configured. rd 100:1 !--- Route Distinguisher for VRF is configured. route-target export 1:1 route-target import 1:1 !--- This configured the import and export policies for customer1 !--- VRF. ! ip cef !--- This enabled CEF switching. ! interface Loopback0 ip address 10.1.1.4 255.255.255.255 interface Ethernet1/0 !--- Connected to P router. ip address 10.10.34.4 255.255.255.0 tag-switching ip !--- MPLS switching is enabled. ! interface Serial9/0 !--- Connected to CE 2 router. ip vrf forwarding customer1 !--- This enables VRF forwarding on the interface. ip address 192.168.20.1 255.255.255.252 ! router ospf 1 log-adjacency-changes redistribute static subnets network 0.0.0.0 255.255.255.255 area 0 ! router bgp 100 no synchronization bgp log-neighbor-changes neighbor 10.1.1.2 remote-as 100 neighbor 10.1.1.2 update-source Loopback0 neighbor 10.1.1.2 next-hop-self no auto-summary ! address-family ipv4 vrf customer1 !--- This is the address-family IPv4 configuration of customer1 VRF. no auto-summary no synchronization network 22.22.22.0 mask 255.255.255.0 !--- This announces the CE 2 network to PE 1. exit-address-family ! address-family vpnv4 !--- This is the address-family VPNV4 configuration for BGP Sessions !--- with PE 1. neighbor 10.1.1.2 activate neighbor 10.1.1.2 send-community extended no auto-summary exit-address-family ! ip classless ip route 22.22.22.0 255.255.255.0 Serial9/0 192.168.20.2 !--- This is the static route for network 22.22.22.0/24 in the global !--- routing table pointing to the interface connected to CE 2. ip route vrf customer1 0.0.0.0 0.0.0.0 192.168.67.1 global !--- This is the static default route for customer VRF !--- for destinations outside the VPN. ip route vrf customer1 22.22.22.0 255.255.255.0 192.168.20.2 !--- This is the static route within customer1 VRF for CE 2 !--- network for VPN connectivity. |
CE 2 |
---|
version 12.2 ! hostname CE-2 ! ip subnet-zero ! interface Loopback0 ip address 22.22.22.22 255.255.255.0 ! interface Serial9/0 !--- This is connected to PE 2. ip address 192.168.20.2 255.255.255.252 ! ip classless ip route 0.0.0.0 0.0.0.0 192.168.20.1 !--- This is the default route pointing to PE 2. |
本節提供的資訊可用於確認您的組態是否正常運作。
要驗證CE 1和CE 2之間的VPN連線,CE 1應能夠訪問CE 2的網路22.22.22.0/24,反之亦然。要檢查這一點,請在PE 1的customer1 VRF中驗證到網路22.22.22.0/24的路由。
輸出直譯器工具(僅供註冊客戶使用)支援某些show命令,此工具可讓您檢視show命令輸出的分析。
show ip route vrf customer1命令確認從10.1.1.4(PE 2的環回地址)獲知的網路22.22.22.0/24的路由,該路由在下面的輸出中突出顯示。
PE-1# show ip route vrf customer1 Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP D - EIGRP, EX - EIGRP external, 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, E - EGP i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area * - candidate default, U - per-user static route, o - ODR P - periodic downloaded static route Gateway of last resort is 192.168.67.1 to network 0.0.0.0 192.168.10.0/30 is subnetted, 1 subnets C 192.168.10.0 is directly connected, Serial8/0 22.0.0.0/24 is subnetted, 1 subnets B 22.22.22.0 [200/0] via 10.1.1.4, 01:00:50 11.0.0.0/24 is subnetted, 1 subnets S 11.11.11.0 [1/0] via 192.168.10.1 S* 0.0.0.0/0 [1/0] via 192.168.67.1
同樣,在PE 2中,到customer1 VRF中的網路11.11.11.0/24的路由如下例所示。
PE-2# show ip route vrf customer1 Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP D - EIGRP, EX - EIGRP external, 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, E - EGP i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area * - candidate default, U - per-user static route, o - ODR P - periodic downloaded static route Gateway of last resort is 192.168.67.1 to network 0.0.0.0 192.168.10.0/30 is subnetted, 1 subnets B 192.168.10.0 [200/0] via 10.1.1.2, 01:00:09 22.0.0.0/24 is subnetted, 1 subnets S 22.22.22.0 [1/0] via 192.168.20.2 192.168.20.0/30 is subnetted, 1 subnets C 192.168.20.0 is directly connected, Serial9/0 11.0.0.0/24 is subnetted, 1 subnets B 11.11.11.0 [200/0] via 10.1.1.2, 01:00:09 S* 0.0.0.0/0 [1/0] via 192.168.67.1
現在,使用來自CE 1的源IP地址11.11.11.1 ping CE 2上的主機22.22.22,檢查CE 1和CE 2之間的連線。
CE-1# ping Protocol [ip]: Target IP address: 22.22.22.22 Repeat count [5]: Datagram size [100]: Timeout in seconds [2]: Extended commands [n]: y Source address or interface: 11.11.11.1 Type of service [0]: Set DF bit in IP header? [no]: Validate reply data? [no]: Data pattern [0xABCD]: Loose, Strict, Record, Timestamp, Verbose[none]: Sweep range of sizes [n]: Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 22.22.22.22, timeout is 2 seconds: !!!!! Success rate is 100 percent (5/5), round-trip min/avg/max = 20/20/20 ms
按照以下步驟驗證從CE1到Internet的連線。
從CE 1發往Internet或VPN的所有資料包都將使用在CE 1中配置的指向PE 1的預設路由進行路由,如下所示。
CE-1# show ip route 0.0.0.0 Routing entry for 0.0.0.0/0, supernet Known via "static", distance 1, metric 0, candidate default path Routing Descriptor Blocks: * 192.168.10.2 Route metric is 0, traffic share count is 1
進入PE 1介面s8/0的資料包使用customer1 VRF路由表進行路由。PE 1在customer1 VRF中有指向IGW IP地址192.168.67.1的預設路由,如PE 1上show ip route vrf customer1的輸出所示。
PE-1# show ip route vrf customer1 Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP D - EIGRP, EX - EIGRP external, 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, E - EGP i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area * - candidate default, U - per-user static route, o - ODR P - periodic downloaded static route Gateway of last resort is 192.168.67.1 to network 0.0.0.0 192.168.10.0/30 is subnetted, 1 subnets C 192.168.10.0 is directly connected, Serial8/0 22.0.0.0/24 is subnetted, 1 subnets B 22.22.22.0 [200/0] via 10.1.1.4, 01:21:11 11.0.0.0/24 is subnetted, 1 subnets S 11.11.11.0 [1/0] via 192.168.10.1 S* 0.0.0.0/0 [1/0] via 192.168.67.1
因為PE 1上的預設路由配置了global關鍵字,所以它在全域性路由表中查詢下一跳192.168.67.1並路由到IGW,如下所示。
PE-1# show ip route 192.168.67.1 Routing entry for 192.168.67.0/30 Known via "ospf 1", distance 110, metric 84, type intra area Last update from 10.10.23.3 on Ethernet0/0, 00:21:54 ago Routing Descriptor Blocks: * 10.10.23.3, from 10.1.1.6, 00:21:54 ago, via Ethernet0/0 Route metric is 84, traffic share count is 1
到達IGW的資料包將根據從R7獲知的BGP路由路由到Internet。在這種情況下,您可以檢視從R7獲知的BGP路由來演示與Internet的連線。下面顯示了從IGW路由表中的R7獲知的BGP路由(網路99.99.99.0/24)。
IGW# show ip route 99.99.99.0 Routing entry for 99.99.99.0/24 Known via "bgp 100", distance 20, metric 0 Tag 200, type external Last update from 192.168.67.2 01:37:25 ago Routing Descriptor Blocks: * 192.168.67.2, from 192.168.67.2, 01:37:25 ago Route metric is 0, traffic share count is 1 AS Hops 1
源自CE-1的資料包會被路由到Internet。
對於從Internet返回且目的地為CE 1網路11.11.11.0/24的資料包,IGW的全域性路由表中應有一個指向PE 1的路由。配置PE 1全域性路由表中的靜態路由,該路由指向PE 1上連線到CE 1的s8/0介面,並將其重新分發到OSPF。這可確保IGW的全域性路由表中有一個指向PE 1的路由。PE 1上的靜態路由和IGW上的OSPF學習路由如下所示。
IGW# show ip route 11.11.11.0 Routing entry for 11.11.11.0/24 Known via "ospf 1", distance 110, metric 20, type extern 2, forward metric 20 Last update from 10.10.36.3 on Ethernet2/0, 00:34:34 ago Routing Descriptor Blocks: * 10.10.36.3, from 10.1.1.2, 00:34:34 ago, via Ethernet2/0 Route metric is 20, traffic share count is 1 PE-1# show ip route 11.11.11.0 Routing entry for 11.11.11.0/24 Known via "static", distance 1, metric 0 Redistributing via ospf 1 Advertised by ospf 1 subnets Routing Descriptor Blocks: * 192.168.10.1, via Serial8/0 Route metric is 0, traffic share count is 1
現在,使用CE 1的源地址11.11.11.1 ping R7 IP地址99.99.99.1,檢查從CE 1到Internet的連線。
CE-1# ping Protocol [ip]: Target IP address: 99.99.99.1 Repeat count [5]: Datagram size [100]: Timeout in seconds [2]: Extended commands [n]: y Source address or interface: 11.11.11.1 Type of service [0]: Set DF bit in IP header? [no]: Validate reply data? [no]: Data pattern [0xABCD]: Loose, Strict, Record, Timestamp, Verbose[none]: Sweep range of sizes [n]: Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 99.99.99.1, timeout is 2 seconds: !!!!! Success rate is 100 percent (5/5), round-trip min/avg/max = 20/24/32 ms CE-1#
目前尚無適用於此組態的具體疑難排解資訊。
修訂 | 發佈日期 | 意見 |
---|---|---|
1.0 |
10-Aug-2005 |
初始版本 |