[Bug] IPv6 connectivity is lost after initializing port forwarding
维护者通常 1 天内回复
@wanghe-fit2cloud 已经在做这个了。
开始于 2026年9月20日。
评估
这个 Issue 还没有评估数据。
描述
Contact Information
No response
1Panel Version
v2.3.1
Problem Description
1Panel 初始化或恢复端口转发功能时,只要检测到系统存在 IPv6 防火墙命令,就会自动启用:
net.ipv6.conf.all.forwarding = 1
同时,该配置会被写入 /etc/sysctl.conf 并立即应用。
Linux 启用全局 IPv6 forwarding 后,会把服务器视为 IPv6 路由器。使用默认值 accept_ra=1 的公网网卡将不再接收 IPv6 Router Advertisement。
对于通过 RA/SLAAC 获取公网 IPv6 地址和默认路由的云服务器,这会导致公网 IPv6 地址无法重新获取或续期,IPv6 默认路由消失,最终只剩下 fe80:: 链路本地地址,IPv6 入站和出站连接均不可用。
使用静态 IPv6 地址和静态网关的服务器不会出现该问题,因此相同版本的 1Panel 在不同服务器上的表现不一致。
当前 dev-v2 分支仍存在相关逻辑:
- agent/utils/firewall/forwarding/sysctl.go
- agent/utils/firewall/forwarding/iptables.go
- agent/utils/firewall/forwarding/nftables.go
相关源码:
https://github.com/1Panel-dev/1Panel/blob/dev-v2/agent/utils/firewall/forwarding/sysctl.go
https://github.com/1Panel-dev/1Panel/blob/dev-v2/agent/utils/firewall/forwarding/iptables.go
Steps to Reproduce
-
准备一台通过 RA/SLAAC 获取公网 IPv6 地址和默认路由的 Linux 云服务器。
-
确认初始状态:
sysctl net.ipv6.conf.all.forwarding
sysctl net.ipv6.conf.eth0.accept_ra
典型结果:
net.ipv6.conf.all.forwarding = 0
net.ipv6.conf.eth0.accept_ra = 1
-
确认服务器当前拥有公网 IPv6,并且 IPv6 网络正常。
-
在 1Panel 的“主机 → 防火墙 → 端口转发”中初始化端口转发;或者从已启用旧版端口转发的 v2.2.5 升级至 v2.3.1。
-
检查系统配置:
sysctl net.ipv6.conf.all.forwarding
grep -n "net.ipv6.conf.all.forwarding" /etc/sysctl.conf
可以看到:
net.ipv6.conf.all.forwarding = 1
-
重启网络、重启服务器,或等待现有 RA/SLAAC 地址和路由信息失效。
-
再次检查
ip -6 address和ip -6 route,公网 IPv6 地址或默认路由消失,只剩下fe80::链路本地地址。
The expected correct result
初始化仅包含 IPv4 规则的端口转发功能时,不应修改服务器的 IPv6 forwarding 和 Router Advertisement 行为。
建议:
- 不要仅根据 ip6tables、ip6tables-restore 或 nftables 是否存在,就自动启用全局 IPv6 forwarding。
- 仅在用户创建或恢复 IPv6 端口转发规则时启用 IPv6 forwarding。
- 启用前检查服务器是否存在依赖 RA/SLAAC 的公网网卡。
- 如果相关网卡使用 accept_ra=1,应停止操作并显示明确警告,提示用户在 forwarding 模式下需要配置 accept_ra=2。
- 不建议未经确认就自动把所有网卡的 accept_ra 修改为 2,因为这会改变服务器的 IPv6 路由及 RA 信任策略。
Related log output
启用端口转发前:
net.ipv6.conf.all.forwarding = 0
net.ipv6.conf.eth0.accept_ra = 1
公网 IPv6:正常
IPv6 默认路由:正常
启用或恢复端口转发后:
net.ipv6.conf.all.forwarding = 1
net.ipv6.conf.eth0.accept_ra = 1
公网 IPv6:在重新配置或租期失效后消失
IPv6 默认路由:消失
/etc/sysctl.conf 中新增:
net.ipv4.ip_forward = 1
net.ipv6.conf.all.forwarding = 1
Additional Information
No response
- 主要语言
- Go
- 星标
- 37.1k
- 派生
- 3.4k
- 平均合并
- 13 小时
- 30 天内合并 PR
- 82
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
1Panel-dev/1Panel 的其他 Issue
-
[Bug] AI Gateway Concurrency Errors可能已有人在做 @wanghe-fit2cloud 今天认领。 未关闭type: ai-gateway
1Panel-dev/1Panel#14035 · 1 条评论 · 已指派 1 人 ·
维护者通常 1 天内回复
-
[Bug] Excessive Overhead in the Embedding Gateway可能已有人在做 @wanghe-fit2cloud 今天认领。 未关闭type: ai-gateway
1Panel-dev/1Panel#14034 · 1 条评论 · 已指派 1 人 ·
维护者通常 1 天内回复
-
[Bug] Website statistics queue cursor is not initialized, causing worker 0 to periodically scan historical sequence numbers and block requests可能已有人在做 @wanghe-fit2cloud 于 2 天前认领。 未关闭type: question
1Panel-dev/1Panel#14028 · 已指派 1 人 ·
维护者通常 1 天内回复
-
[Feature] Human Verification可能已有人在做 @wanghe-fit2cloud 于 2 天前认领。 未关闭type: feature-request
1Panel-dev/1Panel#14027 · 3 条评论 · 已指派 1 人 ·
维护者通常 1 天内回复
-
[Bug] All models added by the Qwen Token Plan are recognized as text models.可能已有人在做 @wanghe-fit2cloud 于 2 天前认领。 未关闭type: ai-gateway
1Panel-dev/1Panel#14026 · 1 条评论 · 已指派 1 人 ·
维护者通常 1 天内回复
查看 1Panel-dev/1Panel 的全部 Issue
相似的 Issue
-
automation models
难度 2/5 1-3 小时 新手友好度 68/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
microsoft/TypeScript#64758 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 62/100
SocialGouv/iterion#2369 ·
维护者通常 1 天内回复
-
daemon/cluster: imageWithDigestString returns the mirror error even when upstream resolves the tag未关闭
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 1 天内回复
-
area/ci bug priority/p3
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复