A-A+

思科路由器L2LVPN解决地址重叠并实现同时能上公网的配置

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

一.概述:

LAN-to-LAN IPSEC VPN如果两端内网地址重叠,互相不能访问,需要配置静态NAT,才能实现互相访问,参考路由器上的其他文章,地址重叠的问题解决了,但是却导致不能上公网,经过测试,借助loopback口,用策略路由,混合使用IP NAT inside/outside 和NVI (ip nat enable),可以解决地址重叠,并且内部主机还能上公网,特记录下来。

二.基本思路:

A.解决地址重叠的问题:

---配置静态NAT,两边内网对于对方来说都是另外一个网段,从而实现两边内网通过主机位地址一对一访问。

B.解决不能上公网的问题:

---混合使用两种不同方式的NAT,并通过策略路由,根据需要进行静态NAT和动态PAT上公网

C.利用的特性:

---NAT在IPSEC VPN之前进行

---路由器有两种配置NAT的方法,一种传统的接口下ip nat inside/outside方式,一种NAT Virtual Interface (NVI)方式,在接口下配置ip nat enable,两种方式可以同时并存

---能成功进行NAT首先需要存在路由,另外一个必须的条件是:从ip nat inside接口进入,从ip nat outside接口出,或者从一个ip nat enable接口进入,从另外一个ip nat enable接口出

---对于传统方式的L2L VPN配置,路由器内网口和外网口作为一对ip nat enable口,使得内网上公网的流量能够PAT上公网;PBR把VPN流量送到loopbak口,loopbak口和外网口作为一对ip nat inside/outside,在VPN之前就进行NAT。

---对于SVTI方式的L2L VPN配置,路由器内网口和外网口作为一对ip nat enable口,使得内网上公网的流量能够PAT上公网;PBR把VPN流量送到loopbak口,loopbak口和tunnel口作为一对ip nat inside/outside,在VPN之前就进行NAT。

三.测试拓扑:

四.基本配置:

A.总部Server路由器:

interface Ethernet0/0

ip address 10.1.1.2 255.255.255.0

no shut

ip route 0.0.0.0 0.0.0.0 10.1.1.1

B.总部Center路由器:

interface Ethernet0/0

ip address 10.1.1.1 255.255.255.0

no shut

interface Ethernet0/1

ip address 202.100.1.1 255.255.255.0

no shut

ip route 0.0.0.0 0.0.0.0 202.100.1.10

C.Internet路由器:

interface Ethernet0/0

ip address 202.100.1.10 255.255.255.0

no shut

interface Ethernet0/1

ip address 202.100.2.10 255.255.255.0

no shut

C.Branch路由器:

interface Ethernet0/0

ip address 10.1.1.1 255.255.255.0

no shut

interface Ethernet0/1

ip address 202.100.2.1 255.255.255.0

no shut

ip route 0.0.0.0 0.0.0.0 202.100.2.10

E.分支inside路由器:

interface Ethernet0/0

ip address 10.1.1.2 255.255.255.0

no shut

ip route 0.0.0.0 0.0.0.0 10.1.1.1

五.L2L IPSEC VPN配置:

A.Center路由器:

①第一阶段策略:

crypto isakmp policy 10

hash md5

authentication pre-share

group 2

crypto isakmp key cisco address 202.100.2.1

②第二阶段转换集:

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

③感兴趣流:

ip access-list extended vpn

permit ip 10.1.1.0 0.0.0.255 172.16.1.0 0.0.0.255

④配置cryto map并在接口应用:

crypto map crymap 10 ipsec-isakmp

set peer 202.100.2.1

set transform-set transet

match address vpn

interface e0/1

crypto map crymap

B.Branch路由器:

①第一阶段策略:

crypto isakmp policy 10

hash md5

authentication pre-share

group 2

crypto isakmp key cisco address 202.100.1.1

②第二阶段转换集:

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

③感兴趣流:

ip access-list extended vpn

permit ip 10.1.1.0 0.0.0.255 172.16.1.0 0.0.0.255

④配置cryto map并在接口应用:

crypto map crymap 10 ipsec-isakmp

set peer 202.100.1.1

set transform-set transet

match address vpn

interface e0/1

crypto map crymap

六.NAT配置:

A.上公网PAT配置:

①Center路由器:

  1. int e0/0  
  2.   
  3. ip nat enable   
  4.   
  5. int e0/1  
  6.   
  7. ip nat enable   
  8.   
  9. ip access-list extended Internet  
  10.   
  11. deny   ip 10.1.1.0 0.0.0.255 192.168.1.0 0.0.0.255  
  12.   
  13. permit ip 10.1.1.0 0.0.0.255 any  
  14.   
  15. ip nat source list Internet interface Ethernet0/1 overload  

测试:

  1. Server#ping 202.100.1.10  
  2.   
  3. Type escape sequence to abort.  
  4.   
  5. Sending 5, 100-byte ICMP Echos to 202.100.1.10, timeout is 2 seconds:  
  6.   
  7. ..!!!  
  8.   
  9. Success rate is 60 percent (3/5), round-trip min/avg/max = 108/141/160 ms  
  10.   
  11. Server#  
  12.   
  13. Internet#debug ip icmp   
  14.   
  15. ICMP packet debugging is on  
  16.   
  17. Internet#  
  18.   
  19. *Mar  1 02:59:13.535: ICMP: echo reply sent, src 202.100.1.10, dst 202.100.1.1  
  20.   
  21. *Mar  1 02:59:13.687: ICMP: echo reply sent, src 202.100.1.10, dst 202.100.1.1  
  22.   
  23. *Mar  1 02:59:13.831: ICMP: echo reply sent, src 202.100.1.10, dst 202.100.1.1  

②Branch路由器:

  1. int e0/0  
  2.   
  3. ip nat enable   
  4.   
  5. int e0/1  
  6.   
  7. ip nat enable   
  8.   
  9. ip access-list extended Internet  
  10.   
  11. deny   ip 10.1.1.0 0.0.0.255 172.16.1.0 0.0.0.255  
  12.   
  13. permit ip 10.1.1.0 0.0.0.255 any  
  14.   
  15. ip nat source list Internet interface Ethernet0/1 overload  

测试:

  1. Inside#ping 202.100.2.10  
  2.   
  3. Type escape sequence to abort.  
  4.   
  5. Sending 5, 100-byte ICMP Echos to 202.100.2.10, timeout is 2 seconds:  
  6. !!!!!  
  7. Success rate is 100 percent (5/5), round-trip min/avg/max = 60/98/184 ms  
  8. Inside#  
  9. Internet#debug ip icmp   
  10. ICMP packet debugging is on  
  11. *Mar  1 03:04:22.363: ICMP: echo reply sent, src 202.100.2.10, dst 202.100.2.1  
  12. *Mar  1 03:04:22.519: ICMP: echo reply sent, src 202.100.2.10, dst 202.100.2.1  
  13. *Mar  1 03:04:22.575: ICMP: echo reply sent, src 202.100.2.10, dst 202.100.2.1  
  14. *Mar  1 03:04:22.659: ICMP: echo reply sent, src 202.100.2.10, dst 202.100.2.1  
  15. *Mar  1 03:04:22.715: ICMP: echo reply sent, src 202.100.2.10, dst 202.100.2.1  

B.解决地址重叠静态NAT及策略路由设置:

-----只在Center路由器上配置:

①静态NAT:

  1. interface loopback0  
  2. ip add 1.1.1.1 255.255.255.252  
  3. ip nat inside  
  4. interface E0/1  
  5. ip nat outside  
  6. ip nat inside source static network 10.1.1.0 172.16.1.0 /24  
  7. ip nat outside source static network 10.1.1.0 192.168.1.0 /24   

②策略路由:

  1. ip access-list extended VPN  
  2. permit ip 10.1.1.0 0.0.0.255 192.168.1.0 0.0.0.255  
  3. route-map VPN permit 10  
  4. match ip address VPN  
  5. set interface Loopback0  

③测试(既能访问互联网,又能访问VPN):

  1. Server#ping 202.100.1.10  
  2. Type escape sequence to abort.  
  3. Sending 5, 100-byte ICMP Echos to 202.100.1.10, timeout is 2 seconds:  
  4. !!!!!  
  5. Success rate is 100 percent (5/5), round-trip min/avg/max = 64/112/200 ms  
  6. Server#ping 192.168.1.2  
  7.   
  8. Type escape sequence to abort.  
  9. Sending 5, 100-byte ICMP Echos to 192.168.1.2, timeout is 2 seconds:  
  10. .!!!!  
  11. Success rate is 80 percent (4/5), round-trip min/avg/max = 200/229/280 ms  
  12. Server#  

七.后记:

如果VPN采用的不是传统方式配置,而采用的Static VTI配置,配置的方式略微不同:

A.VPN配置:

①Center路由器:

  1. crypto isakmp policy 10  
  2. hash md5  
  3. authentication pre-share  
  4. group 2  
  5. crypto isakmp key cisco address 202.100.2.1  
  6. crypto ipsec transform-set transet esp-des esp-md5-hmac  
  7. crypto ipsec profile ipsecprofile  
  8. set transform-set transet  
  9. interface Tunnel0  
  10. ip address 123.1.1.1 255.255.255.0  
  11. tunnel source Ethernet0/1  
  12. tunnel destination 202.100.2.1  
  13. tunnel mode ipsec ipv4  
  14. tunnel protection ipsec profile ipsecprofile  

②Branch路由器:

  1. crypto isakmp policy 10  
  2. hash md5  
  3. authentication pre-share  
  4. group 2  
  5. crypto isakmp key cisco address 202.100.1.1  
  6.   
  7. crypto ipsec transform-set transet esp-des esp-md5-hmac  
  8. crypto ipsec profile ipsecprofile  
  9. set transform-set transet  
  10. interface Tunnel0  
  11. ip address 123.1.1.2 255.255.255.0  
  12. tunnel source Ethernet0/1  
  13. tunnel destination 202.100.1.1  
  14. tunnel mode ipsec ipv4  
  15. tunnel protection ipsec profile ipsecprofile  

B.上公网PAT配置:

---跟前面相同

C.路由设置:

---引导VPN流量到tunnel口,可以静态路由,也可以动态路由,这里使用静态路由

①Center路由器:

ip route 192.168.1.0 255.255.255.0 123.1.1.2

②Branch路由器:

ip route 172.16.1.0 255.255.255.0 123.1.1.1

D.静态NAT及策略路由设置:

----在centter路由器上配置

①静态NAT:

  1. interface loopback 0  
  2. ip nat inside  
  3. interface tun 0  
  4. ip nat outside  
  5. ip nat inside  source static network 10.1.1.0 172.16.1.0  /24  
  6. ip nat outside source static network 10.1.1.0 192.168.1.0 /24  

②策略路由:

  1. ip access-list extended VPN   
  2. permit ip 10.1.1.0 0.0.0.255 192.168.1.0 0.0.0.255  
  3. route-map VPN permit 10  
  4. match ip address VPN  
  5. set interface loopbak 0  
  6. interface Ethernet0/0  
  7. ip policy route-map VPN  

E.测试(既能访问互联网,又能访问VPN):

  1. Server#ping 202.100.1.10  
  2. Type escape sequence to abort.  
  3. Sending 5, 100-byte ICMP Echos to 202.100.1.10, timeout is 2 seconds:  
  4. !!!!!  
  5. Success rate is 100 percent (5/5), round-trip min/avg/max = 60/104/200 ms  
  6. Server#  
  7. Server#ping 192.168.1.2  
  8. Type escape sequence to abort.  
  9. Sending 5, 100-byte ICMP Echos to 192.168.1.2, timeout is 2 seconds:  
  10. !!!!!  
  11. Success rate is 100 percent (5/5), round-trip min/avg/max = 228/258/284 ms  
  12. Server#  
  13. Inside#debug ip icmp  
  14. ICMP packet debugging is on  
  15. Inside#  
  16. *Mar  1 12:04:14.645: ICMP: echo reply sent, src 10.1.1.2, dst 172.16.1.2  
  17. *Mar  1 12:04:14.949: ICMP: echo reply sent, src 10.1.1.2, dst 172.16.1.2  
  18. *Mar  1 12:04:15.169: ICMP: echo reply sent, src 10.1.1.2, dst 172.16.1.2   
  19. *Mar  1 12:04:15.385: ICMP: echo reply sent, src 10.1.1.2, dst 172.16.1.2  
  20. *Mar  1 12:04:15.633: ICMP: echo reply sent, src 10.1.1.2, dst 172.16.1.2  
标签:

给我留言