Lab1 IOS的NAT+IPsec VPN基于预共享密钥验证 25 分钟前 上传
下载附件 (49.83 KB)
实现目标: 公司A部和公司B部都能通过PAT访问Internet 公司A部和公司B部的内外能通过IPSec VPN安全的通讯
1. 预配 R1 interfaceLoopback0 ipaddress 10.1.1.1 255.255.255.0 no sh interfaceFastEthernet0/0 ipaddress 12.12.12.1 255.255.255.0 no sh ip route0.0.0.0 0.0.0.0 12.12.12.2
R2 interfaceFastEthernet0/0 ipaddress 12.12.12.2 255.255.255.0 no sh interfaceFastEthernet0/1 ipaddress 23.23.23.2 255.255.255.0 no sh
R3 interfaceLoopback0 ipaddress 10.2.2.2 255.255.255.0 no sh interfaceFastEthernet0/1 ipaddress 23.23.23.3 255.255.255.0 no sh ip route0.0.0.0 0.0.0.0 23.23.23.2 预备实现Internet网络能连通 R1 pingR3 R1#ping23.23.23.3
Typeescape sequence to abort. Sending5, 100-byte ICMP Echos to 23.23.23.3, timeout is 2 seconds: !!!!! Successrate is 100 percent (5/5), round-trip min/avg/max = 76/96/128 ms OK ! 2. 实现NAT功能时公司A部和公司B部都能通过PAT访问Internet R1 ipaccess-list extended NAT_A permit ip 10.1.1.0 0.0.0.255 any 定义公司A部PAT感兴趣流量内网10.1.1.0/24到Internet的流量 ip natinside source list NAT_A interface FastEthernet0/0 overload 引用NAT_A的感兴趣流量做PAT转换成F0/0对应公有IP(12.12.12.1) interfaceLoopback0 ip natinside! interfaceFastEthernet0/0 ip natoutside 分别去外网口和内网口应用NAT
R3 同R1相似 ipaccess-list extended NAT_B permit ip 10.2.2.0 0.0.0.255 any ip natinside source list NAT_B interface FastEthernet0/1 overload interfaceLoopback0 ip natinside interfaceFastEthernet0/1 ip natoutside
测试NAT转换是否成功 R1#ping12.12.12.2 source loopback 0 Typeescape sequence to abort. Sending5, 100-byte ICMP Echos to 12.12.12.2, timeout is 2 seconds: Packetsent with a source address of 10.1.1.1 !!!!! R1#sh ipnat translations ProInside global Inside local Outside local Outside global icmp 12.12.12.1:1 10.1.1.1:1 12.12.12.2:1 12.12.12.2:1
R3#ping23.23.23.2 source loopback 0 Typeescape sequence to abort. Sending5, 100-byte ICMP Echos to 23.23.23.2, timeout is 2 seconds: Packetsent with a source address of 10.2.2.2 !!!!! R3#sh ipnat translations ProInside global Inside local Outside local Outside global icmp 23.23.23.3:6 10.2.2.2:6 23.23.23.2:6 23.23.23.2:6
OK!R1和R3的对应的内网可以通过PAT转换成功访问Internet
3. IPsec VPN R1 定义VPN的感兴趣流量从公司A部到公司B部的内网的流量为VPN感兴趣流量 ipaccess-list extended VPN_A permit ip 10.1.1.0 0.0.0.255 10.2.2.00.0.0.255
cryptoisakmp policy 1 encr 3des hash md5 authentication pre-share group 2 cryptoisakmp key www.netconfed.com address 23.23.23.3 IKE 1阶段的协商参数用3DES加密算法,哈希算法MD5,DH2,预共享密钥验证,验证对端为23.23.23.3,密钥为www.netconfed.com
cryptoipsec transform-set VPN_SET esp-3des esp-sha-hmac
IKE2阶段的协商参数用ESP封装 3DES,SHA cryptomap VPN_MAP 1 ipsec-isakmp set peer 23.23.23.3 set transform-set VPN_SET match address VPN_A 关联IKE1和IKE2 interfaceFastEthernet0/0 crypto map VPN_MAP 应用外网接口上出去VPN加密,回来VPN解密。
R3 定义VPN的感兴趣流量从公司B部到公司A部的内网的流量为VPN感兴趣流量
ip access-list extended VPN_B permit ip 10.2.2.0 0.0.0.255 10.1.1.00.0.0.255
crypto isakmp policy 1 encr 3des hash md5 authentication pre-share group 2 crypto isakmp key www.netconfed.comaddress 12.12.12.1
crypto ipsec transform-set VPN_SETesp-3des esp-sha-hmac
crypto map VPN_MAP 1 ipsec-isakmp set peer 12.12.12.1 set transform-set VPN_SET match address VPN_B
interface FastEthernet0/1 crypto map VPN_MAP
测试: 触发VPN感兴趣流量看VPN是否正常工作! R1#ping 10.2.2.2 source loopback 0 Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to10.2.2.2, timeout is 2 seconds: Packet sent with a source address of10.1.1.1 U.U. R3#ping 10.1.1.1 source loopback 0
Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to10.1.1.1, timeout is 2 seconds: Packet sent with a source address of10.2.2.2 U.U.U 以上输出为目标地址不可达 问题来了,为什么?
现实中大家应该知道目标IP为私网地址在Internet上一般是无法通讯的,ISP是不会给私网IP路由的。但是我们IPSec VPN的隧道技术是可以实现私网通过Internet访问私网的,也就是IPSec VPN可以实现10.1.1.0 访问10.2.2.0的! 但是在我的刚才的测试中没有实现,是因为NAT和VPN相互是不兼容的。我们可以看看 R1#sh ip nat translations Pro Inside global Inside local Outside local Outside global icmp 12.12.12.1:2 10.1.1.1:2 10.2.2.2:2 10.2.2.2:2 R1的源为10.1.1.1目标为10.2.2.2的流量做了NAT转换,将源10.1.1.1转成12.12.12.2了 所以VPN的感兴趣流量全部走NAT进程了,而目标为10.2.2.2是不能路由的。 也就是所没有通过IPSec的ESP封装到隧道。 所以我们的想办法将NAT和IPsec VPN分离开,如下: R1 ip access-list extended NAT_A deny ip 10.1.1.0 0.0.0.255 10.2.2.0 0.0.0.255 permit ip 10.1.1.0 0.0.0.255 any ip access-list extended VPN_A permit ip 10.1.1.0 0.0.0.255 10.2.2.00.0.0.255
R3 ip access-list extended NAT_B deny ip 10.2.2.0 0.0.0.255 10.1.1.0 0.0.0.255 permit ip 10.2.2.0 0.0.0.255 any ip access-list extended VPN_B permit ip 10.2.2.0 0.0.0.255 10.1.1.00.0.0.255 通过ACl的流量分类功能在NAT的感兴趣流量里面deny掉IPSec VPN的感兴趣流量,也就是当流量的IPsec感兴趣流量是不做NAT转换,而直接通过VPN进程处理。
再来做测试: R1 R1#ping10.2.2.2 source loopback 0
Typeescape sequence to abort. Sending5, 100-byte ICMP Echos to 10.2.2.2, timeout is 2 seconds: Packetsent with a source address of 10.1.1.1 .!!!! 测试Ping通实现公司A部和公司B部能够通讯!
R1#shcrypto isakmp sa IPv4Crypto ISAKMP SA dst src state conn-id slot status 23.23.23.3 12.12.12.1 QM_IDLE 1003 0 ACTIVE 可以看到IKE1 Sa是ACTIVE状态!
R1#sh crypto ipsec sa
interface:FastEthernet0/0 Crypto map tag: VPN_MAP, local addr12.12.12.1
protected vrf: (none) local ident (addr/mask/prot/port): (10.1.1.0/255.255.255.0/0/0) remote ident (addr/mask/prot/port) 10.2.2.0/255.255.255.0/0/0) current_peer 23.23.23.3 port 500 PERMIT, flags={origin_is_acl,} #pkts encaps: 4, #pkts encrypt: 4, #pktsdigest: 4 #pkts decaps: 4, #pkts decrypt: 4, #pktsverify: 4 #pkts compressed: 0, #pkts decompressed: 0 #pkts not compressed: 0, #pkts compr.failed: 0 #pkts not decompressed: 0, #pkts decompressfailed: 0 #send errors 1, #recv errors 0
local crypto endpt.: 12.12.12.1, remotecrypto endpt.: 23.23.23.3 path mtu 1500, ip mtu 1500, ip mtu idbFastEthernet0/0 current outbound spi:0x88A12FB9(2292264889)
inbound esp sas: spi: 0x824DFB18(2186148632) transform: esp-3des esp-sha-hmac , in use settings ={Tunnel, } conn id: 5, flow_id: SW:5, crypto map:VPN_MAP sa timing: remaining key lifetime(k/sec): (4422209/3564) IV size: 8 bytes replay detection support: Y Status: ACTIVE
inbound ah sas:
inbound pcp sas:
outbound esp sas: spi: 0x88A12FB9(2292264889) transform: esp-3des esp-sha-hmac , in use settings ={Tunnel, } conn id: 6, flow_id: SW:6, crypto map:VPN_MAP sa timing: remaining key lifetime(k/sec): (4422209/3562) IV size: 8 bytes replay detection support: Y Status: ACTIVE
outbound ah sas:
outbound pcp sas: 可以看到IPSec Sa状态是OK了!有加密解密的流量!
然后测试NATR1# ping 12.12.12.2 source loopback 0
Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 12.12.12.2, timeout is 2 seconds: Packet sent with a source address of 10.1.1.1 !!!!! Success rate is 100 percent (5/5), round-trip min/avg/max = 56/68/100 ms R1#sh ip nat translations Pro Inside global Inside local Outside local Outside global icmp 12.12.12.1:9 10.1.1.1:9 12.12.12.2:9 12.12.12.2:9
R3#ping 23.23.23.2 source loopback 0
Type escape sequence to abort.Sending 5, 100-byte ICMP Echos to 23.23.23.2, timeout is 2 secondsacket sent with a source address of 10.2.2.2 !!!!! Success rate is 100 percent (5/5), round-trip min/avg/max = 52/72/108 ms R3#sh ip nat translations Pro Inside global Inside local Outside local Outside globalicmp 23.23.23.3:13 10.2.2.2:13 23.23.23.2:13 23.23.23.2:13
实现NAT的正常转发这样就实现了NAT(明文)和IPsecVPN(密文)流量的分离,各走各的!
好了!IOS NAT+IPSecVPN实验结束!大家可以好好的看看show crypto XXX相关的命令熟悉熟悉! 本帖摘自www.netconfed.com.cn
武汉引航思科培训中心,CCIE通过人数位居华中地区首位!
咨询QQ:1092858161
电 话:4006-5566-56 027-87597437
网 址:www.enhan.com.cn
地 址:武汉市洪山区鲁磨路207号洪山科技创业大厦5F
|