思科cisoc 路由器IKEv2配置ipsec tunnel口隧道

环境拓扑图

R1配置

接口配置

R1#configure terminal
R1(config)#interface ethernet 1/0
R1(config-if)#no shutdown
R1(config-if)#ip address 30.1.1.2 255.255.255.0
R1(config-if)#exit
R1(config)#interface ethernet 1/1
R1(config-if)#no shutdown
R1(config-if)#ip address 172.16.1.193 255.255.255.0
R1(config-if)#exit

IPSec配置

# ike密钥配置
R1(config)#crypto ikev2 keyring ike_key  # 生成ike密钥名称
R1(config-ikev2-keyring)#peer 20.1.1.1  # 对端IP
R1(config-ikev2-keyring-peer)#address 20.1.1.1  # 添加对端IP
R1(config-ikev2-keyring-peer)#pre-shared-key 123456  # 配置预共享密钥
R1(config-ikev2-keyring-peer)#exit
R1(config-ikev2-keyring)#exit
# IKEv2一阶段配置
R1(config)#crypto ikev2 profile ike_pro  # 生成ike概要名称
R1(config-ikev2-profile)#match identity remote address 20.1.1.1 255.255.255.255  # 配置对端ike IP地址
R1(config-ikev2-profile)#authentication remote pre-share  # 设置对端认证方式为预共享密钥
R1(config-ikev2-profile)#authentication local pre-share  # 设置本端认证方式为预共享密钥
R1(config-ikev2-profile)#keyring local ike_key  # 关联预共享密钥配置
R1(config-ikev2-profile)#exit
# IKEv2二阶段配置
R1(config)#crypto ipsec profile ipsec_pro  # 配置IPSec名称并进入配置
R1(ipsec-profile)#set ikev2-profile ike_pro  # 关联ike配置
R1(ipsec-profile)#set pfs group2  # 设置pfs为2
R1(ipsec-profile)#exit
# tunnel口配置
R1(config)#interface tunnel 0  # 进入tunnel口
R1(config-if)#ip address 30.30.30.2 255.255.255.0  # 关闭tunnel口IP
R1(config-if)#tunnel source ethernet 1/0  # 配置本端为接口
R1(config-if)#tunnel destination 20.1.1.1  # 配置对端为IP
R1(config-if)#tunnel protection ipsec profile ipsec_pro  # 关联IPSec配置
R1(config-if)#exit

路由配置

R1(config)#ip route 20.1.1.0 255.255.255.0 30.1.1.1
R1(config)#ip route 10.1.1.0 255.255.255.0 tunnel 0  # 配置路由进入tunnel口

R2配置

接口配置

R2#configure ter
R2(config)#interface ethernet 1/0
R2(config-if)#ip address 30.1.1.1 255.255.255.0
R2(config-if)#no shutdown
R2(config-if)#exit
R2(config)#interface ethernet 1/1
R2(config-if)#ip address 20.1.1.2 255.255.255.0
R2(config-if)#no shutdown

R3配置

接口配置

R3#configure terminal
R3(config)#interface ethernet 1/1
R3(config-if)#no shutdown
R3(config-if)#ip address 20.1.1.1 255.255.255.0
R3(config-if)#exit
R3(config)#interface ethernet 1/0
R3(config-if)#no shutdown
R3(config-if)#ip address 10.1.1.2 255.255.255.0
R3(config-if)#exit

IPSec配置

# ike密钥配置
R3(config)#crypto ikev2 keyring ike_key  # 生成ike密钥名称
R3(config-ikev2-keyring)#peer 30.1.1.2  # 对端IP
R3(config-ikev2-keyring-peer)#address 30.1.1.2  # 添加对端IP
R3(config-ikev2-keyring-peer)#pre-shared-key 123456  # 配置预共享密钥
R3(config-ikev2-keyring-peer)#exit
R3(config-ikev2-keyring)#exit
# IKEv2一阶段配置
R3(config)#crypto ikev2 profile ike_pro  # 生成ike概要名称
R3(config-ikev2-profile)#match identity remote address 30.1.1.2 255.255.255.255  # 配置对端ike IP地址
R3(config-ikev2-profile)#authentication remote pre-share  # 设置对端认证方式为预共享密钥
R3(config-ikev2-profile)#authentication local pre-share  # 设置本端认证方式为预共享密钥
R3(config-ikev2-profile)#keyring local ike_key  # 关联预共享密钥配置
R3(config-ikev2-profile)#exit
# IKEv2二阶段配置
R3(config)#crypto ipsec profile ipsec_pro  # 配置IPSec名称并进入配置
R3(ipsec-profile)#set ikev2-profile ike_pro  # 关联ike配置
R3(ipsec-profile)#set pfs group2  # 设置pfs为2
R3(ipsec-profile)#exit
# tunnel口配置
R3(config)#interface tunnel 0  # 进入tunnel口
R3(config-if)#ip address 30.30.30.1 255.255.255.0  # 关闭tunnel口IP
R3(config-if)#tunnel source ethernet 1/1  # 配置本端为接口
R3(config-if)#tunnel destination 30.1.1.2  # 配置对端为IP
R3(config-if)#tunnel protection ipsec profile ipsec_pro  # 关联IPSec配置
R3(config-if)#exit

路由配置

R3(config)#ip route 30.1.1.0 255.255.255.0 20.1.1.2
R3(config)#ip route 172.16.1.0 255.255.255.0 tunnel 0  # 配置路由进入tunnel口
R3(config)#end

R4配置

接口配置

R4#conf terminal
R4(config)#interface ethernet 1/0
R4(config-if)#ip address 10.1.1.1 255.255.255.0
R4(config-if)#no shutdown
R4(config-if)#exit

路由配置

R4(config)#ip route 0.0.0.0 0.0.0.0 10.1.1.2
R4(config)#end

结果截图