[GH-ISSUE #455] 部署docker容器后,使用IEKv2证书连接,win11和安卓手机都能认证连接成功,但内网和外网都不能访问 #424

Closed
opened 2026-03-02 08:18:51 +03:00 by kerem · 1 comment
Owner

Originally created by @barry8316 on GitHub (Nov 12, 2024).
Original GitHub issue: https://github.com/hwdsl2/docker-ipsec-vpn-server/issues/455

任务列表

问题描述
vpn使用iekv2模式能连接成功,但不能访问内网和外网。

1、在客户端点开链接,发现只有发送流量,没有接收流量。

2、宿主机防火墙配置规则
iptables -A INPUT -p udp --dport 500 -j ACCEPT
iptables -A INPUT -p udp --dport 4500 -j ACCEPT
iptables -t nat -A POSTROUTING -j MASQUERADE
iptables -A FORWARD -s 172.17.0.0/16 -d 10.2.0.0/16 -j ACCEPT
iptables -A FORWARD -s 10.2.0.0/16 -d 172.17.0.0/16 -j ACCEPT
iptables -t nat -A POSTROUTING -s 172.17.0.0/16 -d 10.2.0.0/16 -j MASQUERADE
其中172为容器子网,10为vpn子网,彼此之间ping不通。

3、在容器内使用以下命令查看vpn状态:
root@ab:/# ipsec briefstatus
State Information: DDoS cookies not required, Accepting new IKE connections
IKE SAs: total(1), half-open(0), open(0), authenticated(1), anonymous(0)
IPsec SAs: total(1), authenticated(1), anonymous(0)
很奇怪是有一个连接通过认证,但没有开放状态的连接。

期待的正确结果
希望连接成功后能正常访问内外网络。

服务器信息(请填写以下信息)

  • Docker 主机操作系统: [Openwrt]

客户端信息(请填写以下信息)

  • 设备: [Matebook14]
  • 操作系统: [Win11]
  • VPN 模式: [IKEv2]
Originally created by @barry8316 on GitHub (Nov 12, 2024). Original GitHub issue: https://github.com/hwdsl2/docker-ipsec-vpn-server/issues/455 **任务列表** - [x] 我已阅读 [自述文件](https://github.com/hwdsl2/docker-ipsec-vpn-server/blob/master/README-zh.md) - [x] 我已阅读 [重要提示](https://github.com/hwdsl2/docker-ipsec-vpn-server/blob/master/README-zh.md#重要提示) - [x] 我已按照说明 [配置 VPN 客户端](https://github.com/hwdsl2/docker-ipsec-vpn-server/blob/master/README-zh.md#下一步) - [x] 我检查了 [IKEv1 故障排除](https://github.com/hwdsl2/setup-ipsec-vpn/blob/master/docs/clients-zh.md#ikev1-故障排除),[IKEv2 故障排除](https://github.com/hwdsl2/setup-ipsec-vpn/blob/master/docs/ikev2-howto-zh.md#ikev2-故障排除),[启用日志](https://github.com/hwdsl2/docker-ipsec-vpn-server/blob/master/docs/advanced-usage-zh.md#启用-libreswan-日志) 并查看了 [VPN 状态](https://github.com/hwdsl2/setup-ipsec-vpn/blob/master/docs/clients-zh.md#检查日志及-vpn-状态) - [x] 我搜索了已有的 [Issues](https://github.com/hwdsl2/docker-ipsec-vpn-server/issues?q=is%3Aissue) - [x] 这个 bug 是关于 IPsec VPN 服务器 Docker 镜像,而不是 IPsec VPN 本身 <!--- 如果你发现了 IPsec VPN 的一个可重复的程序漏洞,请在 https://github.com/libreswan/libreswan 提交一个错误报告。VPN 的相关问题可在 [Libreswan](https://lists.libreswan.org/mailman/listinfo/swan) 或 [strongSwan](https://lists.strongswan.org/mailman/listinfo/users) 用户邮件列表提问,或者搜索比如 [Stack Overflow](https://stackoverflow.com/questions/tagged/vpn) 等网站。 ---> **问题描述** vpn使用iekv2模式能连接成功,但不能访问内网和外网。 1、在客户端点开链接,发现只有发送流量,没有接收流量。 2、宿主机防火墙配置规则 iptables -A INPUT -p udp --dport 500 -j ACCEPT iptables -A INPUT -p udp --dport 4500 -j ACCEPT iptables -t nat -A POSTROUTING -j MASQUERADE iptables -A FORWARD -s 172.17.0.0/16 -d 10.2.0.0/16 -j ACCEPT iptables -A FORWARD -s 10.2.0.0/16 -d 172.17.0.0/16 -j ACCEPT iptables -t nat -A POSTROUTING -s 172.17.0.0/16 -d 10.2.0.0/16 -j MASQUERADE 其中172为容器子网,10为vpn子网,彼此之间ping不通。 3、在容器内使用以下命令查看vpn状态: root@ab:/# ipsec briefstatus State Information: DDoS cookies not required, Accepting new IKE connections IKE SAs: total(1), half-open(0), open(0), authenticated(1), anonymous(0) IPsec SAs: total(1), authenticated(1), anonymous(0) 很奇怪是有一个连接通过认证,但没有开放状态的连接。 **期待的正确结果** 希望连接成功后能正常访问内外网络。 **服务器信息(请填写以下信息)** - Docker 主机操作系统: [Openwrt] **客户端信息(请填写以下信息)** - 设备: [Matebook14] - 操作系统: [Win11] - VPN 模式: [IKEv2]
kerem closed this issue 2026-03-02 08:18:51 +03:00
Author
Owner

@hwdsl2 commented on GitHub (Nov 12, 2024):

@barry8316 你好!目前本项目对 Openwrt 的 Docker 主机的支持有限。对于你所说的问题,可能是你的宿主机的防火墙配置规则的问题,而不是 Docker 镜像的问题。我对 Openwrt 不熟悉,一般来说,Docker 启动时会自动添加防火墙规则,你上面这些防火墙规则可能都不需要。

你可以尝试在容器中运行 Bash shell,然后使用 curl 或 wget 等工具检查网络连接,例如 wget -O - https://www.google.com,以确保容器内部可以访问因特网。另外,你可以启用 Libreswan 日志,重试连接并检查日志。

<!-- gh-comment-id:2470756205 --> @hwdsl2 commented on GitHub (Nov 12, 2024): @barry8316 你好!目前本项目对 Openwrt 的 Docker 主机的支持有限。对于你所说的问题,可能是你的宿主机的防火墙配置规则的问题,而不是 Docker 镜像的问题。我对 Openwrt 不熟悉,一般来说,Docker 启动时会自动添加防火墙规则,你上面这些防火墙规则可能都不需要。 你可以尝试[在容器中运行 Bash shell](https://github.com/hwdsl2/docker-ipsec-vpn-server/blob/master/docs/advanced-usage-zh.md#%E5%9C%A8%E5%AE%B9%E5%99%A8%E4%B8%AD%E8%BF%90%E8%A1%8C-bash-shell),然后使用 curl 或 wget 等工具检查网络连接,例如 `wget -O - https://www.google.com`,以确保容器内部可以访问因特网。另外,你可以[启用 Libreswan 日志](https://github.com/hwdsl2/docker-ipsec-vpn-server/blob/master/docs/advanced-usage-zh.md#%E5%90%AF%E7%94%A8-libreswan-%E6%97%A5%E5%BF%97),重试连接并检查日志。
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/docker-ipsec-vpn-server#424
No description provided.