H3C 单点公网IPsec配置实验

网络架构与IPsec VPN部署方案

为实现总部与分支网络通过运营商多层NAT环境安全互联,现部署IPsec VPN隧道,具体网络架构与接口地址规划如下:

一、设备接口与地址分配

设备 接口 IP 地址 所属网段 备注
PCA GE_0/1 192.168.0.1 192.168.0.0/24 总部终端
R1 GE_0/0 192.168.0.254 192.168.0.0/24 连接PC
R1 GE_0/1 12.1.1.1 12.1.1.0/24 连接公网
R2 GE_0/1 12.1.1.2 12.1.1.0/24 连接R1
R2 GE_0/2 23.1.1.2 23.1.1.0/24 连接运营商网络
R3 GE_0/2 23.1.1.3 23.1.1.0/24 接入多层NAT区域
R3 GE_0/0 10.10.10.1 10.10.10.0/24 连接分支公网段
R4 GE_0/0 10.10.10.2 10.10.10.0/24 连接R3
R4 GE_0/1 192.168.1.254 192.168.1.0/24 连接PCB
PCB GE_0/1 192.168.1.1 192.168.1.0/24 分支终端

二、IPsec VPN实现目标

通过在总部(含R1、R2及网段 192.168.0.0/24)与分支(含R4及网段 192.168.1.0/24)间建立IPsec隧道,穿越由R3及多层NAT构成的运营商公网环境,实现两私有网络安全互通。本方案可有效保障数据传输的机密性、完整性及业务私密性。

三、设备配置

R1配置

python 复制代码
# 配置接口IP地址
# 连接内网的接口,作为总部192.168.0.0/24网段的网关
interface GigabitEthernet0/0
 ip address 192.168.0.254 255.255.255.0

# 连接公网的接口,用于接入运营商网络
interface GigabitEthernet0/1
 ip address 12.1.1.1 255.255.255.0
 # 应用出方向NAT,使用ACL 3000规则判断哪些流量需要做地址转换
 nat outbound 3000

# 配置默认路由,指定下一跳为运营商侧路由器(R2)的接口地址
ip route-static 0.0.0.0 0 12.1.1.2
 
# 配置高级ACL 3000,用于NAT策略
acl advanced 3000
 # 规则0:禁止对去往分支192.168.1.0/24网段的流量进行NAT转换(保障IPsec流量以原始IP传输)
 rule 0 deny ip source 192.168.0.0 0.0.0.255 destination 192.168.1.0 0.0.0.255
 # 规则5:允许其他所有IPv4流量进行NAT转换
 rule 5 permit ip

# 配置高级ACL 3010,定义IPsec感兴趣流(需要被IPsec保护的数据流)
acl advanced 3010
 # 匹配从总部网段192.168.0.0/24去往分支网段192.168.1.0/24的所有IP流量
 rule 0 permit ip source 192.168.0.0 0.0.0.255 destination 192.168.1.0 0.0.0.255

# 配置IPsec变换集,定义安全协议和算法
ipsec transform-set G0/1_IPV4_1
 # 使用ESP协议,加密算法为AES-CBC-128
 esp encryption-algorithm aes-cbc-128 
 # 认证算法为SHA-1
 esp authentication-algorithm sha1

# 配置IKE密钥链,设置预共享密钥
ike keychain 1
 # 对所有对端(0.0.0.0/0)使用相同的预共享密钥"123456"
 pre-shared-key address 0.0.0.0 0.0.0.0 key simple 123456

# 配置IKE提议(使用默认参数)
ike proposal 1

# 配置IKE Profile,管理IKE协商策略
ike profile 1
 # 引用前面定义的密钥链1
 keychain 1
 # 使用野蛮模式(Aggressive Mode)进行IKE协商
 exchange-mode aggressive
 # 设置本端身份标识为FQDN格式,名称为"center"
 local-identity fqdn center
 # 匹配对端身份:允许任何IP地址的对端
 match remote identity address 0.0.0.0 0.0.0.0
 # 同时匹配对端身份:期望对端FQDN为"branch"
 match remote identity fqdn branch
 # 引用ike提议
 ike profile 1

# 创建IPsec策略模板
ipsec policy-template G0/1 1
 # 引用前面定义的变换集G0/1_IPV4_1
 transform-set G0/1_IPV4_1 
 # 引用ACL 3010定义需要保护的流量
 security acl 3010 
 # 指定本端接口地址
 local-address 12.1.1.1
 # 引用IKE Profile 1进行密钥协商
 ike-profile 1
 
# 基于模板创建IPsec策略
ipsec policy G0/1 1 isakmp template G0/1
 
# 在公网接口上应用IPsec策略
interface GigabitEthernet0/1
 ipsec apply policy G0/1

R4配置

python 复制代码
#              
interface GigabitEthernet0/0
 ip address 10.10.10.2 255.255.255.0
 nat outbound 3000

#
interface GigabitEthernet0/1
 ip address 192.168.1.254 255.255.255.0
 
#
acl advanced 3000
 rule 0 deny ip source 192.168.1.0 0.0.0.255 destination 192.168.0.0 0.0.0.255
 rule 5 permit ip
#
acl advanced 3010
 rule 0 permit ip source 192.168.1.0 0.0.0.255 destination 192.168.0.0 0.0.0.255

#              
ipsec transform-set G0/0_IPV4_1
 esp encryption-algorithm aes-cbc-128 
 esp authentication-algorithm sha1 

#
ike keychain 1
 pre-shared-key address 12.1.1.1 255.255.255.255 key simple 123456

#
ike profile 1
 keychain 1
 exchange-mode aggressive
 local-identity fqdn branch
 match remote identity address 12.1.1.1 255.255.255.255
 match remote identity fqdn center
 proposal 1 

#
ike proposal 1

#
ipsec policy G0/0 1 isakmp
 transform-set G0/0_IPV4_1 
 security acl 3010 
 remote-address 12.1.1.1
 ike-profile 1

#
interface GigabitEthernet0/0
 ipsec apply policy G0/0

四、配置验证

R1查看IPsec隧道

R4查看IPsec隧道

抓包正常

相关推荐
-快乐的程序员-17 小时前
simple websocket用法
网络·websocket·网络协议
半桔18 小时前
【网络编程】网络通信基石:从局域网到跨网段通信原理探秘
linux·运维·网络协议·php
沐浴露z19 小时前
【深入理解计算机网路07】详解局域网:以太网、VLAN与无线局域网
网络·网络协议·计算机网络·408
XUE-52113141 天前
路由策略与路由控制实验
运维·网络·网络协议·智能路由器
加油20191 天前
如何快速学习一个网络协议?
网络·网络协议·学习·方法论
十碗饭吃不饱1 天前
WebClient工具调用HTTP接口报错远程主机断开连接
网络·网络协议·http
liu****1 天前
基于websocket的多用户网页五子棋(九)
服务器·网络·数据库·c++·websocket·网络协议·个人开发
心态特好1 天前
详解WebSocket及其妙用
java·python·websocket·网络协议
Yefimov2 天前
DPDK:从网络协议栈的角度来观察微内核
后端·网络协议
IT_Octopus2 天前
https私人证书 PKIX path building failed 报错解决
java·spring boot·网络协议·https