A-A+

通过全局路由表的方式实现MPLS VPN上互联网的方法探究

2015年11月24日 站长资讯 暂无评论

一.概述:

MPLS VPN中,如果CE有三根线,一根连接内网,一根专线连接MPLS的PE,一根直接连接互联网,那么内网通过CE上互联网比较容易:CE通过MPLS VPN的明细路由走PE,一条默认路由到连接互联网的设备。但是有时情况没那么简单,CE只有一根专线连接PE,并且还需通过PE上互联网,这就需要有方法把上互联网的流量和MPLS VPN的流量分开,本文采用全局路由的方式来实现。

参考链接:http://www.cisco.com/en/US/tech/tk436/tk428/technologies_configuration_example09186a00801445fb.shtml

二.基本思路:

A.

三.测试拓扑:

四.基本配置:

  1. A.CE1  
  2. interface Loopback0  
  3.      ip address 4.4.4.4 255.255.255.255  
  4. interface Loopback1  
  5.      ip address 192.168.1.1 255.255.255.0  
  6. interface Loopback2  
  7.      ip address 192.168.10.1 255.255.255.0  
  8. interface Ethernet0/0  
  9.      ip address 10.1.1.1 255.255.255.0  
  10.      no shut  
  11. ip route 0.0.0.0 0.0.0.0 10.1.1.2  
  12. B.PE1:  
  13. ip vrf A  
  14.      rd 100:1  
  15.      route-target export 1:1  
  16.      route-target import 1:1  
  17. interface Loopback0  
  18.      ip address 1.1.1.1 255.255.255.255  
  19. interface Ethernet0/0  
  20.      ip address 12.1.1.1 255.255.255.0  
  21.      mpls ip  
  22.      no shut  
  23. interface Ethernet0/1  
  24.      ip vrf forwarding A  
  25.   
  26.   
  27.      ip address 10.1.1.2 255.255.255.0  
  28.      no shut  
  29. C.P:  
  30. interface Loopback0  
  31.      ip address 2.2.2.2 255.255.255.255  
  32. interface Ethernet0/0  
  33.      ip address 12.1.1.2 255.255.255.0  
  34.      no shut  
  35.      mpls ip  
  36. interface Ethernet0/1  
  37.      ip address 23.1.1.2 255.255.255.0  
  38.      no shut  
  39.      mpls ip  
  40. interface Ethernet0/2  
  41.      ip address 26.1.1.6 255.255.255.0  
  42.      mpls ip  
  43.      no shut  
  44. D.PE2:  
  45. ip vrf A  
  46.      rd 100:1   
  47.      route-target export 1:1  
  48.      route-target import 1:1  
  49. interface Loopback0  
  50.      ip address 3.3.3.3 255.255.255.0  
  51. interface Ethernet0/0   
  52.      ip address 23.1.1.3 255.255.255.0  
  53.      mpls ip  
  54.      no shut  
  55. interface Ethernet0/1  
  56.      ip vrf forwarding A  
  57.      ip address 202.100.1.2 255.255.255.252  
  58.      no shut  
  59. E.CE2:  
  60. interface Loopback0  
  61.      ip address 5.5.5.5 255.255.255.255  
  62. interface Loopback1  
  63.      ip address 192.168.2.1 255.255.255.0  
  64. interface Loopback2  
  65.      ip address 192.168.20.1 255.255.255.0  
  66. interface Ethernet0/0  
  67.      ip address 10.1.2.1 255.255.255.0  
  68.      no shut  
  69. ip route 0.0.0.0 0.0.0.0 10.1.2.2  

五.MPLS VPN配置:

A.静态路由配置:

  1. ①PE1:  
  2. ip route 192.168.1.0 255.255.255.0 Ethernet0/1 10.1.1.1  
  3. ip route vrf A 192.168.1.0 255.255.255.0 10.1.1.1  
  4.   
  5. ②PE2:  
  6. ip route 192.168.2.0 255.255.255.0 Ethernet0/1 10.1.2.1   
  7. ip route vrf A 192.168.2.0 255.255.255.0 10.1.2.1  

B.IGP配置:

  1. ①PE1:  
  2. router ospf 1  
  3.      router-id 1.1.1.1  
  4.      redistribute static subnets  
  5.      network 0.0.0.0 255.255.255.255 area 0  
  6. ②P:  
  7. router ospf 1  
  8.      router-id 2.2.2.2  
  9.      network 0.0.0.0 255.255.255.255 area 0  
  10. ②PE2:  
  11. router ospf 1  
  12.      router-id 3.3.3.3  
  13.      redistribute static subnets  
  14.      network 0.0.0.0 255.255.255.255 area 0  

C.BGP配置:

  1. ①PE1:  
  2. router bgp 100  
  3.      no synchronization  
  4.      bgp router-id 1.1.1.1  
  5.      neighbor 3.3.3.3 remote-as 100  
  6.      neighbor 3.3.3.3 update-source Loopback0  
  7.      neighbor 3.3.3.3 next-hop-self   
  8.      no auto-summary  
  9. address-family vpnv4  
  10.        neighbor 3.3.3.3 activate  
  11.        neighbor 3.3.3.3 send-community extended  
  12.        exit-address-family  
  13. address-family ipv4 vrf A  
  14.        no synchronization  
  15.        network 192.168.1.0  
  16.        exit-address-family  
  17. ②PE2:  
  18. router bgp 100  
  19.      no synchronization  
  20.      bgp router-id 3.3.3.3  
  21.      neighbor 1.1.1.1 remote-as 100  
  22.      neighbor 1.1.1.1 update-source Loopback0  
  23.      neighbor 1.1.1.1 next-hop-self  
  24.      no auto-summary  
  25. address-family vpnv4  
  26.       neighbor 1.1.1.1 activate  
  27.       neighbor 1.1.1.1 send-community extended   
  28.      exit-address-family  
  29. address-family ipv4 vrf A  
  30.       no synchronization  
  31.       network 192.168.2.0  
  32.      exit-address-family  

D.MPLS Lable验证:

  1. PE-1#show mpls forwarding-table  
  2. Local  Outgoing    Prefix            Bytes tag  Outgoing   Next Hop     
  3. tag    tag or VC   or Tunnel Id      switched   interface               
  4. 16     Pop tag     2.2.2.2/32        0          Et0/0      12.1.1.2      
  5. 17     19          3.3.3.3/32        0          Et0/0      12.1.1.2      
  6. 18     Pop tag     23.1.1.0/24       0          Et0/0      12.1.1.2      
  7. 19     Untagged    192.168.1.0/24    0          Et0/1      10.1.1.1      
  8. 20     18          192.168.2.0/24    0          Et0/0      12.1.1.2      
  9. 21     Untagged    192.168.1.0/24[V] 7012       Et0/1      10.1.1.1      
  10. 22     Pop tag     26.1.1.0/24       0          Et0/0      12.1.1.2     
  11. PE-2#show mpls forwarding-table  
  12. Local  Outgoing    Prefix            Bytes tag  Outgoing   Next Hop     
  13. tag    tag or VC   or Tunnel Id      switched   interface               
  14. 16     Pop tag     12.1.1.0/24       0          Et0/0      23.1.1.2      
  15. 17     17          1.1.1.1/32        0          Et0/0      23.1.1.2      
  16. 18     Pop tag     2.2.2.2/32        0          Et0/0      23.1.1.2      
  17. 19     16          192.168.1.0/24    0          Et0/0      23.1.1.2      
  18. 20     Untagged    192.168.2.0/24    0          Et0/1      10.1.2.1      
  19. 21     Untagged    192.168.2.0/24[V] 6410       Et0/1      10.1.2.1      
  20. 22     Pop tag     26.1.1.0/24       0          Et0/0      23.1.1.2  

D.MPLS VPN验证:

  1. CE-1#traceroute 192.168.2.1 source 192.168.1.1  
  2.   
  3. Type escape sequence to abort.  
  4. Tracing the route to 192.168.2.1  
  5.   
  6.  1 10.1.1.2 188 msec 52 msec 64 msec  
  7.  2 12.1.1.2 [MPLS: Labels 19/21 Exp 0] 156 msec 144 msec 140 msec  
  8.  3 10.1.2.2 [MPLS: Label 21 Exp 0] 96 msec 100 msec 124 msec  
  9.  4 10.1.2.1 172 msec 160 msec *  

六.IPsec VPN配置:

A.PE1:

①第一阶段策略:

  1. crypto isakmp policy 10  
  2.      encr 3des  
  3.      hash md5  
  4.      authentication pre-share  
  5.      group 2  
  6. crypto isakmp key cisco address 192.168.2.1  

②第二阶段策略:

crypto ipsec transform-set transet esp-3des esp-md5-hmac

mode transport

③ 配置ipsec profile

crypto ipsec profile ipsec_profile

set transform-set transet

④配置tunnel接口,并应用ipsec profile

  1. interface Tunnel0  
  2.      ip address 172.16.1.1 255.255.255.0  
  3.      ip mtu 1400  
  4.      tunnel source Loopback1   
  5.      tunnel destination 192.168.2.1  
  6.      tunnel protection ipsec profile ipsec_profile  
  7. B.PE2:  

①第一阶段策略:

  1. crypto isakmp policy 10  
  2.      encr 3des  
  3.      hash md5  
  4.      authentication pre-share  
  5.      group 2  
  6. crypto isakmp key cisco address 192.168.1.1  

②第二阶段策略:

crypto ipsec transform-set transet esp-3des esp-md5-hmac

mode transport

③ 配置ipsec profile

crypto ipsec profile ipsec_profile

set transform-set transet

④配置tunnel接口,并应用ipsec profile

  1. interface Tunnel0  
  2.      ip address 172.16.1.2 255.255.255.0  
  3.      ip mtu 1400  
  4.      tunnel source Loopback1  
  5.      tunnel destination 192.168.1.1  
  6.      tunnel protection ipsec profile ipsec_profile   

C.配置静态路由:

----也可以用动态路由来代替

①PE1:

ip route 192.168.20.0 255.255.255.0 Tunnel0

②PE2:

ip route 192.168.10.0 255.255.255.0 Tunnel0

D.IPSec VPN验证:

①ping:

  1. CE-1#ping 192.168.20.1 source 192.168.10.1  
  2.   
  3. Type escape sequence to abort.  
  4. Sending 5, 100-byte ICMP Echos to 192.168.20.1, timeout is 2 seconds:  
  5. Packet sent with a source address of 192.168.10.1  
  6. .!!!!  
  7. Success rate is 80 percent (4/5), round-trip min/avg/max = 156/186/232 ms  

②查看isakmp sa和加解密:

  1. CE-1#show crypto isakmp sa  
  2. dst             src             state          conn-id slot status  
  3. 192.168.2.1     192.168.1.1     QM_IDLE              2    0 ACTIVE  
  4.   
  5. CE-1#show crypto engine connections active  
  6.   
  7.  ID Interface            IP-Address      State  Algorithm           Encrypt  Decrypt  
  8.   2 Tunnel0              172.16.1.1      set    HMAC_MD5+3DES_56_C        0        0  
  9. 2001 Tunnel0              192.168.1.1     set    3DES+MD5                  4        0  
  10. 2002 Tunnel0              192.168.1.1     set    3DES+MD5                  0        4  

七.通过PE上互联网配置:

  1. A.CE1:  
  2. interface Loopback2  
  3.      ip nat inside  
  4. interface Ethernet0/0  
  5.      ip nat outside  
  6. ip access-list extended PAT  
  7.      deny   ip 192.168.0.0 0.0.255.255 192.168.0.0 0.0.255.255  
  8.      permit ip 192.168.0.0 0.0.255.255 any  
  9. ip nat pool NATPOOL 202.100.1.1 202.100.1.2 netmask 255.255.255.0  
  10. ip nat inside source list PAT pool NATPOOL overload  
  11. B.PE1:  
  12. ip route vrf A 0.0.0.0 0.0.0.0 67.1.1.6 global  
  13. ip route 202.100.1.0 255.255.255.0 Ethernet0/1 10.1.1.1  
  14. ip route vrf A 202.100.1.0 255.255.255.0 10.1.1.1  
  15. ---IGP重分布静态路由已经配置  
  16. C.CE2:  
  17. interface Loopback2  
  18.      ip nat inside  
  19. interface Ethernet0/0  
  20.      ip nat outside  
  21. ip access-list extended PAT  
  22.      deny   ip 192.168.0.0 0.0.255.255 192.168.0.0 0.0.255.255   
  23.      permit ip 192.168.0.0 0.0.255.255 any  
  24. ip nat pool NATPOOL 202.100.2.1 202.100.2.2 netmask 255.255.255.0  
  25. ip nat inside source list PAT pool NATPOOL overload  
  26. D.PE2:  
  27. ip route vrf A 0.0.0.0 0.0.0.0 67.1.1.6 global  
  28. ip route 202.100.2.0 255.255.255.0 Ethernet0/1 10.1.2.1  
  29. ip route vrf A 202.100.2.0 255.255.255.0 10.1.2.1  
  30. ---IGP重分布静态路由已经配置  
  31. E.IGW:  
  32. interface Loopback0  
  33.      ip address 6.6.6.6 255.255.255.255  
  34. interface Ethernet0/0  
  35.      ip address 26.1.1.6 255.255.255.0  
  36.      no shut  
  37.      mpls ip  
  38. interface Ethernet0/1  
  39.      ip address 67.1.1.6 255.255.255.0  
  40.      no shut  
  41. access-list 10 permit 202.100.1.0 0.0.0.255  
  42. access-list 10 permit 202.100.2.0 0.0.0.255  
  43. access-list 10 permit 26.1.1.0 0.0.0.255  
  44. router ospf 1  
  45.      router-id 6.6.6.6   
  46.      passive-interface default  
  47.      no passive-interface Ethernet0/0  
  48.      network 26.1.1.0 0.0.0.255 area 0  
  49.      network 67.1.1.0 0.0.0.255 area 0  
  50.      distribute-list 10 in Ethernet0/0  
  51. router bgp 100  
  52.      no synchronization  
  53.      bgp router-id 6.6.6.6  
  54.      network 202.100.1.0  
  55.      network 202.100.2.0  
  56.      neighbor 67.1.1.7 remote-as 200  
  57.      no auto-summary  
  58. F.R7:  
  59. interface Loopback0  
  60.      ip address 7.7.7.7 255.255.255.255  
  61. interface Loopback1  
  62.      ip address 202.100.3.7 255.255.255.0  
  63. interface Ethernet0/0  
  64.      ip address 67.1.1.7 255.255.255.0  
  65.      no shut  
  66. router bgp 200   
  67.      no synchronization  
  68.      bgp router-id 7.7.7.7  
  69.      network 202.100.3.0  
  70.      neighbor 67.1.1.6 remote-as 100  
  71.      no auto-summary  
  72. G.路由验证:  
  73. R7#SHOW IP ROUte  
  74. Codes: C - connected, S - static, R - RIP, M - mobile, B - BGP  
  75.       D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area  
  76.       N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2  
  77.       E1 - OSPF external type 1, E2 - OSPF external type 2  
  78.       i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2  
  79.       ia - IS-IS inter area, * - candidate default, U - per-user static route  
  80.       o - ODR, P - periodic downloaded static route  
  81. Gateway of last resort is not set  
  82.   
  83. B    202.100.2.0/24[20/20] via 67.1.1.6, 00:11:34  
  84. C    202.100.3.0/24 is directly connected, Loopback1  
  85.     67.0.0.0/24 is subnetted, 1 subnets  
  86. C       67.1.1.0 is directly connected, Ethernet0/0  
  87.     7.0.0.0/32 is subnetted, 1 subnets  
  88. C       7.7.7.7 is directly connected, Loopback0  
  89. B    202.100.1.0/24[20/20] via 67.1.1.6, 00:12:04  
  90.   
  91. IGW#SHOW IP ROUte  
  92. Codes: C - connected, S - static, R - RIP, M - mobile, B - BGP  
  93.       D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area  
  94.       N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2  
  95.       E1 - OSPF external type 1, E2 - OSPF external type 2  
  96.       i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2  
  97.       ia - IS-IS inter area, * - candidate default, U - per-user static route  
  98.       o - ODR, P - periodic downloaded static route  
  99.   
  100. Gateway of last resort is not set  
  101.   
  102. O E2 202.100.2.0/24 [110/20] via 26.1.1.2, 00:04:54, Ethernet0/0  
  103. B    202.100.3.0/24[20/0] via 67.1.1.7, 00:42:18  
  104.     6.0.0.0/32 is subnetted, 1 subnets  
  105. C       6.6.6.6 is directly connected, Loopback0  
  106.     67.0.0.0/24 is subnetted, 1 subnets  
  107. C       67.1.1.0 is directly connected, Ethernet0/1  
  108. O E2 202.100.1.0/24 [110/20] via 26.1.1.2, 00:04:54, Ethernet0/0  
  109.     26.0.0.0/24 is subnetted, 1 subnets  
  110. C       26.1.1.0 is directly connected, Ethernet0/0  
  111.   
  112. CE-1#TR 202.100.3.7 SOUrce 192.168.10.1  
  113.   
  114. Type escape sequence to abort.  
  115. Tracing the route to 202.100.3.7  
  116.   
  117.  1 10.1.1.2 88 msec 124 msec 52 msec  
  118.  2 12.1.1.2 [MPLS: Label 21 Exp 0] 92 msec 140 msec 120 msec  
  119.  3 26.1.1.6 108 msec 168 msec 164 msec  
  120.  4 67.1.1.7 172 msec 200 msec *  
  121. CE-1#  
  122. CE-2#TRaceroute 202.100.3.7 SOUrce 192.168.20.1  
  123.   
  124. Type escape sequence to abort.  
  125. Tracing the route to 202.100.3.7  
  126.   
  127.  1 10.1.2.2 52 msec 108 msec 84 msec  
  128.  2 23.1.1.2 [MPLS: Label 21 Exp 0] 60 msec 60 msec 140 msec  
  129.  3 26.1.1.6 104 msec 148 msec 172 msec  
  130.  4 67.1.1.7 160 msec 144 msec *  
标签:

给我留言