【记录】strongSwan\ipSec 修改IKEport

搜了半天都没找到想要的答案,终于这篇的评论里的老哥给了我提示:https://blog.csdn.net/xingyeping/article/details/51745110

我用的strongSwan版本:5.6.2

两步:

1.根据strongSwan官网wiki,可以找到ipsec.conf详细说明页面,其中关于协商端口的字段如下:

left|rightikeport = <port>

UDP port the left participant uses for IKE communication. If unspecified, port 500 is used with the port
floating to 4500 if a NAT is detected or MOBIKE is enabled.
Specifying a local IKE port different from the default additionally requires a socket implementation that
listens to this port. Not supported for IKEv1 connections prior to 

  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
强烈推荐使用 strongSwan 来搭建 IPsec 环境。以下是基本的步骤: 1. 安装 strongSwan 对于 Ubuntu/Debian 用户: ``` sudo apt-get update sudo apt-get install strongswan ``` 对于 CentOS/RHEL 用户: ``` sudo yum install epel-release sudo yum install strongswan ``` 2. 配置 strongSwan strongSwan 的主配置文件位于 /etc/ipsec.conf。在此文件中,您需要指定以下内容: - IPsec 隧道的本地和远程端点。 - 加密和认证算法。 - 交换密钥的方式(例如使用预共享密钥或使用证书)。 以下是一个示例配置文件: ``` # /etc/ipsec.conf - strongSwan IPsec configuration file config setup charondebug="all" uniqueids=yes conn myvpn left=%defaultroute leftid=@vpn-server leftsubnet=192.168.1.0/24 right=%any rightid=@vpn-client rightsubnet=10.0.0.0/24 ike=aes256-sha256-modp2048! esp=aes256-sha256-modp2048! authby=secret auto=start ``` 在上面的示例中,我们定义了一个名为“myvpn”的连接,并指定了本地和远程端点的 IP 地址和子网。我们还指定了 IKE 和 ESP 的加密和认证算法,以及使用预共享密钥进行身份验证。 3. 配置 IPsec 预共享密钥 在上面的配置文件中,我们使用了预共享密钥进行身份验证。因此,我们需要在 /etc/ipsec.secrets 文件中定义这些密钥。以下是一个示例文件: ``` # /etc/ipsec.secrets - strongSwan IPsec secrets file @vpn-server @vpn-client : PSK "mysecret" ``` 在上面的示例中,我们定义了一个名为“mysecret”的预共享密钥,它将用于身份验证。 4. 启动 strongSwan 启动 strongSwan 服务: ``` sudo systemctl start strongswan ``` 5. 验证 IPsec 连接 使用以下命令检查 strongSwan 是否已成功建立连接: ``` sudo ipsec status ``` 如果一切正常,您应该看到类似以下输出: ``` Security Associations (1 up, 0 connecting): myvpn[1]: ESTABLISHED 2 minutes ago, 192.168.1.1[vpn-server]...10.0.0.1[vpn-client] myvpn[1]: IKEv2 SPIs: 5e7e0f1e6b4d6b37_i* 3c8f23a81b1425d0_r, pre-shared key reauthentication in 54 minutes myvpn[1]: IKE proposal: AES_CBC_256/HMAC_SHA2_256_128/PRF_HMAC_SHA2_256/MODP_2048 myvpn{1}: INSTALLED, TUNNEL, ESP in UDP SPIs: c7e4a8a2_i 13a3b0f1_o myvpn{1}: AES_CBC_256/HMAC_SHA2_256_128, 0 bytes_i, 0 bytes_o, rekeying in 32 minutes ``` 恭喜您,您已成功搭建了一个 strongSwan IPsec 环境!

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值