具体配置脚本:
=================================================
VPN_A
=================================================
Building configuration...
! system setting
configure terminal
enable password 0 mpsec
mode route
interface trusted ip 192.168.1.1/255.255.255.0
interface untrusted ip 1.1.1.3/255.255.255.0
ip route 0.0.0.0/0.0.0.0 1.1.1.1
service sshd
web port 443
web idle enable
web idle 999
service web
end
! log config
configure log
logging user stop
logging delete all
end
! firewall config
configure firewall
firewall log start
dnat policy permit
snat policy permit
ldnat policy permit
access-list policy input permit
//默认转发策略是permit
access-list policy forward permit
access-list policy output permit
srr filter enable
end
! vpn config
configure vpn
//启动IPSec服务
service ipsec
//进入ipsec模式
ipsec
//步骤四:配置访问列表,定义要保护的数据流
access-list add ac1 permit
protocol ip 192.168.1.0/255.255.255.0 192.168.2.0/255.255.255.0
commit
//步骤五:配置变换集合,定义所使用的加密算法和安全协议
transform add tr1 tunnel esp-des esp-md5-hmac
//步骤六:配置加密映射,将各个组件组合在一起。
map add map1 untrusted isakmp
match /ac1 //引用步骤四中的定义的数据流
transform tr1 //引用步骤五中的定义的变换集合
peer 2.2.2.2
life time 28800
life bytes 4608000
pfs 2 //配置支持完美前向保护
commit
exit
//进入IKE模式
ike
//步骤一:配置IKE的policy
policy add 1
authentication pre-share
encryption des
hash md5
group 2
lifetime 28800
commit
//步骤二:配置预共享密钥
key preshare ip 2.2.2.2 keystring maipu
//步骤三:配置本地标识
localid ip 1.1.1.3
exit
//步骤七;启用该map
active map map1
end
! user config
-----以下的配置略
=================================================
VPN_B
=================================================
Building configuration...
! system setting
configure terminal
hostname VPN_B
enable password 0 mpsec
mode route
interface trusted ip 192.168.2.1/255.255.255.0
interface untrusted ip 2.2.2.2/255.255.255.0
ip route 0.0.0.0/0.0.0.0 2.2.2.1
service sshd
web port 443
web idle enable
web idle 999
service web
end
! log config
configure log
logging user stop
logging delete all
end
! firewall config
configure firewall
firewall log start
dnat policy permit
snat policy permit
ldnat policy permit
access-list policy input permit
access-list policy forward permit
access-list policy output permit
srr filter enable
end
! vpn config
configure vpn
service ipsec
ipsec
//步骤四:配置访问列表,定义要保护的数据流,与VPN_A所定义的数据流相对应
access-list add ac1 permit
protocol ip 192.168.2.0/255.255.255.0 192.168.1.0/255.255.255.0
commit
transform add tr1 tunnel esp-des esp-md5-hmac
map add map1 untrusted isakmp
match /ac1
transform tr1
peer 1.1.1.3
life time 28800
life bytes 4608000
pfs 2
commit
exit
ike
policy add 1
authentication pre-share
encryption des
hash md5
group group_modp1024
lifetime 28800
commit
//步骤二:配置预共享密钥
key preshare ip 1.1.1.3 keystring maipu
localid ip 2.2.2.2
exit
active map map1
end
! user config
-----以下的配置略
VPN3020上的调试命令:
目前,VPN3020上没有给用户使用的调试命令,只能通过一些show信息来查看IKE协商的情况。
show ipsec sa:查看已经建立的IPSec SA信息
show ipsec status:查看当前的IPSec 的状态,如果IPSec SA已经建立,有IPSec SA establish的信息。
案例4:VPN与VPN、路由器之动态加密映射
网络拓扑如图所示:
需求:中心是一台VPN3020,有两个网点其中一台是vpn3020(或者是vpn3005,两者的配置是一样的),另一个网点是mp803路由器。接入都是动态接入,电信ADSL接入。MP803可以直接拨号,而VPN3020(或者VPN3005)只有以太口,因此,前面要放置一台ADSL modem,才能够进行PPPoE拨号。现在要求是两个网点所挂接两个网络能够访问中心VPN3020后面所挂接的网络(PC2)。
规划:一些具体的IKE、IPSec协商的参数在这里略去。这里重点说明中心VPN(VPN_A)上面的规划,中心可以只配置一个动态的map,数据流源地址为192.168.1.0/24,目的地址为any(注意,不要配置成any 到any),下端的VPN_B的数据流为源地址为192.168.2.0/24 目的地址为192.168.1.0/24;下端的MP803的数据流为源地址为192.168.3.0/24,目的地址为192.168.1.0/24。
具体配置脚本:
=================================================================
MP803:ADSL拨号,同时实现上网和走NAT
=================================================================
hostname MP803
enable password [WOWWWNXSX encrypt
no service password-encrypt
no service enhanced-secure
ip tcp timestamp
//定义要保护的数据流
ip access-list extended 1001
permit ip 192.168.3.0 0.0.0.255 192.168.1.0 0.0.0.255
exit
//定义该数据流走NAT上网,为了避免走内网的数据流也“上网”去了,
//先deny该数据流
ip access-list extended 1002
deny ip 192.168.3.0 0.0.0.255 192.168.1.0 0.0.0.255
permit ip 192.168.3.0 0.0.0.255 any
exit
dialer-list 1 protocol ip permit
//配置NAT
ip nat inside source list 1002 interface dialer0 overload
crypto isakmp policy 1
encryption des
hash sha
authentication pre-share
group 2
lifetime 28800
exit
crypto isakmp key maipu address 1.1.1.3
crypto ipsec transform-set tr1 esp-des esp-md5-hmac
mode tunnel
exit
crypto map map1 1001 ipsec-isakmp
match address 1001
set peer 1.1.1.3
set transform-set tr1
set security-association lifetime seconds 28800
set security-association lifetime kilobytes 4608000
exit
interface loopback0
exit
//拨号配置,map是应用到本虚拟接口
interface dialer0
ip address negotiated
dialer pool 1
dialer-group 1
encapsulation ppp
ppp pap sent-username 01234mp@169 password 01234mp
mtu 1492
ip nat outside
crypto map map1
exit
interface fastethernet0
ip address 192.168.3.1 255.255.255.0
ip nat inside
exit
//物理接口配置
interface atm0
pvc 1/33
encapsulation aal5snap
pppoe-client dial-pool-number 1
no ip route-cache
no cdp enable
exit
ip route 0.0.0.0 0.0.0.0 dialer0
=================================================================
VPN_B:PPPoE拨号,同时实现上网和走NAT
=================================================================
configure terminal
hostname VPN_B
enable password 7 Z2wdXYed9yoyw
mode route
interface trusted ip 192.168.2.1/255.255.255.0
service sshd
web port 443
web idle enable
web idle 10
service web
end
! log config
configure log
logging user stop
logging delete all
logging user delete all
end
! firewall config
configure firewall
firewall log start
dnat policy permit
snat policy permit
ldnat policy permit
//对于走VPN的数据流,避免让其走SNAT出去
snat add any 192.168.2.0/24 192.168.1.0/24 any filter /snat1 log permit
//对于其他的数据流,都让其走SNAT出去
snat add masquerade pppoe 192.168.2.0/24 any /snat2 log
access-list policy input permit
access-list policy forward permit
access-list policy output permit
access-list state input enable
access-list state forward enable
access-list state output enable
srr filter enable
end
! vpn config
configure vpn
service ipsec
//启动service dynamic,表示本端为动态获取IP地址
service dynamic interface ppp
ipsec
//定义所要保护的数据流
access-list add /ac1 permit
protocol ip 192.168.2.0/255.255.255.0 192.168.1.0/255.255.255.0
commit
//定义变换集合
transform add tr1 tunnel esp-des esp-md5-hmac
//配置加密映射,注意此处选择关键字是dynamic
map add map1 dynamic isakmp
//引用所定义的访问列表
match /ac1
//引用所定义的变换集合
transform tr1
peer 1.1.1.3
life time 86600
life bytes 4608000
pfs 2
commit
exit
ike
//定义IKE的policy
policy add 1
authentication pre-share
encryption des
hash sha
group 2
lifetime 28800
commit
//配置预共享密钥
key preshare ip 1.1.1.3 keystring maipu
exit
//激活map
active map map1
end
----中间的配置略
! pppoe client config
configure pppoeclient
//绑定到出口,即从那个接口进行拨号
bind untrusted
//配置上端需要认证的用户名和密码
authuser test_name pass test_name
//开始进行拨号,完成该命令后用show ip route或者show interface
//能够看到PPP链路已经建立成功
pppoe start
end
---后面的配置略
=================================================================
VPN_A:中心的VPN
=================================================================
! system setting
configure terminal
hostname VPN_A
enable password 0 mpsec
mode route
interface trusted ip 192.168.1.1/255.255.255.0
interface untrusted ip 1.1.1.3/255.255.255.0
ip route 0.0.0.0/0.0.0.0 1.1.1.1
service sshd
web port 443
web idle enable
web idle 999
service web
end
! log config
configure log
logging user stop
logging delete all
end
! firewall config
configure firewall
firewall log start
dnat policy permit
snat policy permit
ldnat policy permit
access-list policy input permit
//默认转发策略是permit
access-list policy forward permit
access-list policy output permit
srr filter enable
end
! vpn config
configure vpn
//启动IPSec服务
service ipsec
//进入ipsec模式
ipsec
//步骤四:配置访问列表,定义要保护的数据流
access-list add ac1 permit
protocol ip 192.168.1.0/255.255.255.0 any
commit
//步骤五:配置变换集合,定义所使用的加密算法和安全协议
transform add tr1 tunnel esp-des esp-md5-hmac
//步骤六:配置加密映射,将各个组件组合在一起。
map add map1 untrusted isakmp
//引用步骤四中的定义的数据流
match /ac1
//引用步骤五中的定义的变换集合
transform tr1
peer 0.0.0.0
life time 28800
life bytes 4608000
//配置完美前向保护
pfs 2
commit
exit
//进入IKE模式
ike
//步骤一:配置IKE的policy
policy add 1
authentication pre-share
encryption des
hash md5
group 2
lifetime 28800
commit
//步骤二:配置预共享密钥
key preshare ip 0.0.0.0 keystring maipu
//步骤三:配置本地标识
localid ip 1.1.1.3
exit
//步骤七;启用该map
active map map1
end
! user config
-----以下的配置略
配置总结
常见的配置失误:
1. 现象:一端发起协商后,另一端没有任何响应。
可能的原因:
ü 检查发起协商的数据流是否匹配所定义的要保护的数据流;
ü 检查路由器上是否有默认路由或者到远端局域网段的路由;
ü 检查加密映射(map)是否已经应用到接口上去;
ü 检查两端的peer地址是否配置正确,确保两个VPN网关本身能够互通;
ü 检查预共享密钥是否已经配置;
ü 如果发起协商的一端是路由器,对端是VPN3020,检查是否配置了crypto isakmp peer ip-address A.B.C.D,该命令的含义是以野蛮模式发起协商,而目前VPN3020上尚不支持野蛮模式。
ü 如果其中有台VPN设备是VPN3020,确保在配置的时候是先配置了接口地址,然后启动service ipsec命令的,见案例3中的配置注意事项。
2. 现象:IKE SA(又称第一阶段主模式)协商不成功
可能的原因:
ü 检查两端是否有一致的policy,如果规划使用预共享认证方式,确保双方一致的policy中的认证方式为预共享;
ü 预共享密钥是否配置是否一致;
3. 现象:IKE SA协商成功了,但是快速模式协商不成功,IPSec SA无法建立
可能的原因:
ü 两端的是否有一致的变化集合;
ü 两端的所要保护的数据流是否相对应;
ü 两端的完美前向保护参数(pfs)是否一致;
4. 现象:IPSec SA已经建立成功,但是两边的局域网中两台主机不通。
可能的原因:(这时候已经与IPSec本身没有多大关系了)
ü 主机上是否已经配置网关,该网关指向路由器的一个接口;
ü 检查两台主机上是否启用了防火墙过滤之类的软件;
ü 数据流在Internet上是否已经穿越了NAT(基本可以从路由器出口的地址是否为公网地址来确定)
更多内容请看PCdog.com--VPN技术 win98使用技巧专题
