配置示例
一、配置 IPSec-VPN:
1、配置 一端 IPSec:
指定协商算法crypto isakmp policy 1
encr aes 256
hash sha256
authentication pre-share
group 14
设置一个预共享密钥,并指定对端
crypto isakmp key Skill39! address 100.1.1.1
# 设置 IPSec 隧道模式
crypto ipsec transform-set S2S-IPSEC esp-aes 256 esp-sha256-hmac
mode tunnel //模式设置为隧道
需要使用 ACL 进行匹配流量,将流量引入隧道ip access-list extended VPN
permit ip 192.168.2.0 0.0.0.255 192.168.1.0 0.0.0.255 # 输入内网接口地址(要匹配的地址) # 设置 IPSec VPN
crypto map S2S-MAP 1 ipsec-isakmp # 设置 IPSec名词为 S2S-MAP
set peer 100.1.1.1 # 设置对端地址
set transform-set S2S-IPSEC
match address VPN # 应用 ACL
# 在接口应用 IPSec-VPN
int gi 0/1
crypto map S2S-MAP
2、配置 另一端 IPSec:
指定协商算法crypto isakmp policy 1
encr aes 256
hash sha256
authentication pre-share
group 14
设置一个预共享密钥,并指定对端
crypto isakmp key Skill39! address 200.1.1.1
# 设置 IPSec 隧道模式
crypto ipsec transform-set S2S-IPSEC esp-aes 256 esp-sha256-hmac
mode tunnel //模式设置为隧道
需要使用 ACL 进行匹配流量,将流量引入隧道ip access-list extended VPN
permit ip 192.168.1.0 0.0.0.255 192.168.2.0 0.0.0.255 # 输入内网接口地址(要匹配的地址)匹配源为 192.168.1.0/24 目的地址为 192.168.2.0/24 的流量 # 设置 IPSec VPN
crypto map S2S-MAP 1 ipsec-isakmp # 设置 IPSec名词为 S2S-MAP
set peer 200.1.1.1 # 设置对端地址
set transform-set S2S-IPSEC
match address VPN # 应用 ACL
# 在接口应用 IPSec-VPN
int gi 0/1
crypto map S2S-MAP
二、配置 GRE-over-IPSec:
1、配置一端 GRE-over-IPSec:
crypto isakmp policy 1
encr aes 256
hash sha256
authentication pre-share
group 14
crypto isakmp key Skill39! address 100.1.1.1
设置IPSec模式为 传输模式
crypto ipsec transform-set S2S-IPSEC esp-aes 256 esp-sha256-hmac
mode transport
crypto map S2S-MAP 1 ipsec-isakmp
set peer 100.1.1.1
set transform-set S2S-IPSEC
match address GREOVERIPSEC
int gi0/1
crypto map S2S-MAP
匹配的IP地址不再是内网的,而是 匹配 GRE流量,匹配源为 200.1.1.1,目的为 100.1.1.1 的 GRE流量
ip access-list extended GREOVERIPSEC
permit gre host 200.1.1.1 host 100.1.1.1
interface Tunnel0
ip address 10.0.0.2 255.255.255.252
tunnel source GigabitEthernet0/1
tunnel destination 100.1.1.1
路由(因为 GRE需要路由将流量导入到隧道中)这里可以选择配置动态路由或者静态路由
router eigrp 1
network 10.0.0.0 # 通告 GRE隧道地址
network 192.168.2.0 # 通告 内网地址
2、配置 另一端 GRE-over-IPSec:
crypto isakmp policy 1
encr aes 256
hash sha256
authentication pre-share
group 14
crypto isakmp key Skill39! address 200.1.1.1
设置IPSec模式为 传输模式
crypto ipsec transform-set S2S-IPSEC esp-aes 256 esp-sha256-hmac
mode transport
crypto map S2S-MAP 1 ipsec-isakmp
set peer 200.1.1.1
set transform-set S2S-IPSEC
match address GREOVERIPSEC
int gi0/1
crypto map S2S-MAP
匹配的IP地址不再是内网的,而是 匹配 GRE流量,匹配源为 100.1.1.1,目的为 200.1.1.1 的 GRE流量
ip access-list extended GREOVERIPSEC
permit gre host 100.1.1.1 host 200.1.1.1
interface Tunnel0
ip address 10.0.0.1 255.255.255.252
tunnel source GigabitEthernet0/1
tunnel destination 200.1.1.1
路由(因为 GRE需要路由将流量导入到隧道中)这里可以选择配置动态路由或者静态路由
router eigrp 1
network 10.0.0.0 # 通告 GRE隧道地址
network 192.168.1.0 # 通告 内网地址