步骤:
以R1为例进行配置
1.配置路由
2.定义加密数据的acl
access 101 permit ip 172.16.1.0 0.0.0.255 172.16.2.0 0.0.0.255
3.定义isakmp policy
crypto isakmp policy 1
authentication pre-share (采用pre-share key进行验证)
(authentication参数必须配置,其他参数如group、hash、encr、lifetime等, 如果进行配置,需要注意两个路由器上的对应参数配置必须相同。)
4.定义pre-share key
crypto isakmp key pre-share-key address 192.168.1.2
(其中pre-share-key 为key,两个路由器上要一样,其中192.168.1.2为peer路由器的ip地址。 )
5.定义transform-set
crypto ipsec transform-set vpn-tfs esp-3des esp-sha-hmac
(其中vpn-tfs为transform-set name,后面两项为加密传输的算法)
(mode transport/tunnel tunnel为默认值,此配置可选)
6.定义crypto map entry
cry map vpn-map 10 ipsec-isakmp
(其中vpn-map为map name,10 是entry 号码,ipsec-isakmp表示采用isakmp进行密钥管理)
match address 101 (定义进行加密传输的数据,与第二步对应)
set peer 192.168.1.2 (定义peer路由器的ip)
set transform-set vpn-tfs (与第五步对应)
(如果一个接口上要对应多个vpn peer,可以定义多个entry,每个entry对应一个peer)
7.将crypto map应用到接口上
inter f0 (vpn通道入口)
cry map vpn-map
8.同样方法配置r2路由器。
R1的完整配置:
r1#sh run
Building configuration...
Current configuration : 1064 bytes
!
version 12.2
service timestamps debug uptime
service timestamps log uptime
no service password-encryption
!
hostname r1
!
ip subnet-zero
!
no ip domain-lookup
!
crypto isakmp policy 1
authentication pre-share
crypto isakmp key pre-share-key address 192.168.1.2
!
crypto ipsec transform-set vpn-tfs esp-3des esp-sha-hmac
!
crypto map vpn-map 10 ipsec-isakmp
set peer 192.168.1.2
set transform-set vpn-tfs
match address 101
!
call rsvp-sync
!
interface Ethernet0/0
ip address 172.16.1.1 255.255.255.0
no keepalive
half-duplex
!
interface Serial1/0
ip address 192.168.1.1 255.255.255.0
!
router ospf 100
log-adjacency-changes
network 172.16.1.0 0.0.0.255 area 0
network 192.168.1.0 0.0.0.255 area 0
!
ip classless
no ip http server
!
access-list 101 permit ip 172.16.1.0 0.0.0.255 172.16.2.0 0.0.0.255
!
dial-peer cor custom
!
line con 0
line aux 0
line vty 0 4
login
!
end
r1#
R2的完整配置:
r2#sh run
Building configuration...
Current configuration : 1103 bytes
!
version 12.2
service timestamps debug uptime
service timestamps log uptime
no service password-encryption
!
hostname r2
!
username r1 password 0 cisco
ip subnet-zero
!
crypto isakmp policy 1
authentication pre-share
crypto isakmp key pre-share-key address 192.168.1.1
!
crypto ipsec transform-set vpn-tfs esp-3des esp-sha-hmac
!
crypto map vpn-map 10 ipsec-isakmp
set peer 192.168.1.1
set transform-set vpn-tfs
match address 101
!
call rsvp-sync
!
!
interface Ethernet0/0
ip address 172.16.2.1 255.255.255.0
no keepalive
half-duplex
!
interface Serial1/0
ip address 192.168.1.2 255.255.255.0
clockrate 64000
crypto map vpn-map
!
router ospf 100
log-adjacency-changes
network 172.16.2.0 0.0.0.255 area 0
network 192.168.1.0 0.0.0.255 area 0
!
ip classless
no ip http server
!
access-list 101 permit ip 172.16.2.0 0.0.0.255 172.16.1.0 0.0.0.255
!
dial-peer cor custom
!
line con 0
line aux 0
line vty 0 4
!
End
r2#
测试:
(1)未将map应用到接口之前,在r1,扩展ping,source 192.168.1.1 destination 172.16.2.1,通过。扩展ping,source 172.16.1.1 destination 172.16.2.1,通过。
(2)map应用到接口之后,在r1,扩展ping,source 192.168.1.1 destination 172.16.2.1,通过。
查看show crypto ipsec sa ,可以看到数据没有通过vpn 通道进行传输,因为不符合acl 101。
(3)map应用到接口之后,在r1,扩展ping,source 172.16.1.1 destination 172.16.2.1,通过。查看show cry ip sa,可以看到数据通过vpn 通道进行传输。
(4)在r2上同样进行测试。
site to site vpn(采用rsa-encrypted)