实验环境
Dynamips模拟器
Cisco IOS Software, 3700 Software (C3745-ADVIPSERVICESK9-M), Version 12.4(4)T, RELEASE SOFTWARE (fc1)
拓扑结构
以下图所示, R1和R3是×××隧道的两个对端设备。
其中R1的loop 0模拟终端pc1,表明链接到R1的×××内网172.16.1.0
R4模拟终端pc4,表明测试机
R5 f1/5与R3 f1/5之间的网络,表明×××内网172.16.5.0
R5的loop 0模拟终端pc5,表明链接到R5的办公室内网192.168.5.0

实验要求
实现传输模式下的IPSEC-×××通讯。
使172.16.0.0(本实例为172.16.1.0、172.16.4.0和172.16.5.0三个子网)网段内的各子网互联。
而且192.168.5.0内网能够访问172.16.0.0 的子网。
操做步骤
一、基本配置
为各路由器的链接端口配置IP,这里以R3为例
R3(config)#int f1/2
R3(config-if)#no switchport
R3(config-if)#ip add 23.1.1.3 255.255.255.0
R3(config-if)#no shut
R3(config-if)#int f1/4
R3(config-if)#no switchport
R3(config-if)#ip add 172.16.4.3 255.255.255.0
R3(config-if)#no shut
R3(config-if)#int f1/5
R3(config-if)#no switchport
R3(config-if)#ip add 172.16.5.3 255.255.255.0
R3(config-if)#no shut
R3(config-if)#exit
使用Ping命令确认各路由器的直连口的互通性。此时跨路由器是没法访问的。
二、R一、R3配置路由
分别在R1和R3上配置默认路由
R1
R1(config)#ip route 0.0.0.0 0.0.0.0 12.1.1.2
R3
R3(config)#ip route 0.0.0.0 0.0.0.0 23.1.1.2
配置完成后,R1和R3能够互通。
三、R一、R3配置×××隧道
在R1上的配置,对端IP指定为R3上的f1/2口IP。操做步骤可分为两阶段:
第一阶段设置初始身份认证,创建基本的安全通道,为协商之后的SA作准备,主要定义ISAKMP策略,包括对称加密算法、完整验证算法、身份验证的方法,SA的生存期,而且肯定双方的密码和IP地址。
R1(config)#crypto isakmp enable
R1(config)#crypto isakmp policy 100 !建立ISAKMP策略
R1(config-isakmp)#authentication pre-share !指定ISAKMP策略使用预共享密钥的方式
R1(config-isakmp)#encryption des !指定ISAKMP策略使用DES进行加密
R1(config-isakmp)#group 1 !指定ISAKMP策略使用10位密钥算法
R1(config-isakmp)#hash md5 !指定ISAKMP策略的消息摘要算法为md5
R1(config-isakmp)#lifetime 86400 !指定ISAKMP策略建立的ISAKMP SA的有效期为86400秒 ,这是默认值。
R1(config-isakmp)#exit
R1(config)#
R1(config)#crypto isakmp identity address !指定ISAKMP与分部路由器进行身份认证时使用IP地址做为标志。
R1(config)#crypto isakmp key cisco123 address 23.1.1.3 !设置isakmp中双方用的密钥和对端的IP地址(这一步是用于SA传递,SA是单向的)
第二阶段,建立交换集、用于指定加密通讯的访问控制列表、加密图,并将加密图应用到接口中。
R1(config)#crypto ipsec transform-set r1set esp-des esp-md5-hmac !配置IPSec交换集
R1(cfg-crypto-trans)#exit
R1(config)#
R1(config)#access-list 110 permit ip 172.16.1.0 0.0.0.255 172.16.4.0 0.0.0.255 !配置访问控制列表指定须要加密的通讯
R1(config)#access-list 110 permit ip 172.16.1.0 0.0.0.255 172.16.5.0 0.0.0.255
R1(config)#access-list 110 permit ip 172.16.4.0 0.0.0.255 172.16.1.0 0.0.0.255
R1(config)#access-list 110 permit ip 172.16.5.0 0.0.0.255 172.16.1.0 0.0.0.255
R1(config)#
R1(config)#crypto map r1map 100 ipsec-isakmp !建立加密图
% NOTE: This new crypto map will remain disabled until a peer
and a valid access list have been configured.
R1(config-crypto-map)#match address 110 !指定使用此加密图进行加密的通讯,用访问控制列表来定义
R1(config-crypto-map)#set peer 23.1.1.3 !指定加密图用于分支路由器创建×××链接
R1(config-crypto-map)#set transform-set r1set !指定加密图使用的IPSec交换集。
R1(config-crypto-map)#set security-association lifetime kilobytes 86400
R1(config-crypto-map)#set pfs group1 !启用向前保护密钥功能,能够不设置。
R1(config-crypto-map)#exit
R1(config)#
R1(config)#int f1/1
R1(config-if)#no ip mroute-cache
R1(config-if)#no fair-queue
R1(config-if)#crypto map r1map !设置外网接口并指定在该接口上应用配置好的加密图
R1(config-if)#exit
R1(config)#
*Mar 1 02:12:00.819: %CRYPTO-6-ISAKMP_ON_OFF: ISAKMP is ON
在R3上的配置,基本与R1上的配置相同,对端IP指定为R1上的f1/1口IP::
R3(config)#crypto isakmp enable
R3(config)#crypto isakmp policy 100
R3(config-isakmp)#authentication pre-share
R3(config-isakmp)#encryption des
R3(config-isakmp)#group 1
R3(config-isakmp)#hash md5
R3(config-isakmp)#lifetime 86400
R3(config-isakmp)#exit
R3(config)#
R3(config)#crypto isakmp identity address
R3(config)#crypto isakmp key cisco123 address 12.1.1.1
R3(config)#crypto ipsec transform-set r3set esp-des esp-md5-hmac
R3(cfg-crypto-trans)#exit
R3(config)#
R3(config)#access-list 110 permit ip 172.16.1.0 0.0.0.255 172.16.4.0 0.0.0.255
R3(config)#access-list 110 permit ip 172.16.1.0 0.0.0.255 172.16.5.0 0.0.0.255
R3(config)#access-list 110 permit ip 172.16.4.0 0.0.0.255 172.16.1.0 0.0.0.255
R3(config)#access-list 110 permit ip 172.16.5.0 0.0.0.255 172.16.1.0 0.0.0.255
R3(config)#
R3(config)#crypto map r3map 100 ipsec-isakmp
% NOTE: This new crypto map will remain disabled until a peer
and a valid access list have been configured.
R3(config-crypto-map)#match address 110
R3(config-crypto-map)#set peer 12.1.1.1
R3(config-crypto-map)#set transform-set r3set
R3(config-crypto-map)#set security-association lifetime kilobytes 86400
R3(config-crypto-map)#set pfs group1
R3(config-crypto-map)#exit
R3(config)#
R3(config)#int f1/2
R3(config-if)#no ip mroute-cache
R3(config-if)#no fair-queue
R3(config-if)#crypto map r3map
R3(config-if)#exit
R3(config)#
*Mar 1 02:12:37.863: %CRYPTO-6-ISAKMP_ON_OFF: ISAKMP is ON
四、连通测试
R1#ping 172.16.4.3 source 172.16.1.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 172.16.4.3, timeout is 2 seconds:
Packet sent with a source address of 172.16.1.1
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 12/39/60 ms
----------------------------------------------------------
R1#ping 172.16.5.3 source 172.16.1.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 172.16.5.3, timeout is 2 seconds:
Packet sent with a source address of 172.16.1.1
.!!!!
Success rate is 80 percent (4/5), round-trip min/avg/max = 12/49/76 ms
----------------------------------------------------------
R1#ping 172.16.4.4 source 172.16.1.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 172.16.4.4, timeout is 2 seconds:
Packet sent with a source address of 172.16.1.1
.....
Success rate is 0 percent (0/5)
----------------------------------------------------------
R1#ping 172.16.5.5 source 172.16.1.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 172.16.5.5, timeout is 2 seconds:
Packet sent with a source address of 172.16.1.1
.....
Success rate is 0 percent (0/5)
可见,此时172.16.1.1能ping通R3上的172.16.4.三、172.16.5.3,但不能ping通R四、R5,固然,R四、R5也没法ping通172.16.1.1。R四、R5之间也是没法访问的。
由于此时的R四、R5具备路由功能,但却没有路由设置。
五、将R4置为PC机终端
关闭R4的路由功能,并为其设置默认网关,使其成为一台PC终端。
R4(config)#no ip routing
R4(config)#ip default-gateway 172.16.4.3
此时,172.16.1.1和R4能够直接互相ping通,
R1#ping 172.16.4.4 source 172.16.1.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 172.16.4.4, timeout is 2 seconds:
Packet sent with a source address of 172.16.1.1
.!!!!
Success rate is 80 percent (4/5), round-trip min/avg/max = 56/75/88 ms
六、在R5上创建默认路由
R5(config)#ip route 0.0.0.0 0.0.0.0 172.16.5.3
配置好路由后,R5能够与pc一、pc4(R4)相互ping通,
R5(config)#do ping 172.16.1.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 172.16.1.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 24/50/104 ms
----------------------------------------------------------
R5(config)#do ping 172.16.4.4
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 172.16.4.4, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 12/33/60 ms
----------------------------------------------------------
R1#ping 172.16.5.5 source 172.16.1.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 172.16.5.5, timeout is 2 seconds:
Packet sent with a source address of 172.16.1.1
.!!!!
Success rate is 80 percent (4/5), round-trip min/avg/max = 36/56/88 ms
七、在R5上创建NAT
R5(config)#int f1/5
R5(config-if)#ip nat outside
R5(config-if)#exit
R5(config)#int loop 0
R5(config-if)#ip nat inside
R5(config-if)#exit
R5(config)#ip nat pool p1 172.16.5.5 172.16.5.5 netmask 255.255.255.0
R5(config)#access-list 1 permit 192.168.5.0 0.0.0.255
R5(config)#ip nat inside source list 1 pool p1 overload
R5(config)#exit
R5#ping 172.16.1.1 source 192.168.5.5
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 172.16.1.1, timeout is 2 seconds:
Packet sent with a source address of 192.168.5.5
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 12/72/128 ms
固然了,外面是ping不进来的。
注:这是个小实验,把×××和NAT的知识串到一块儿来学习。
实际中×××网络又是如何搭建的?本实验中内网如何上外网?还有待研究。