Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

[Bug] IPv6 connectivity is lost after initializing port forwarding

Chiusa
#13,876 1 commento 0 reazioni 1 assegnatario Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@wanghe-fit2cloud ci sta già lavorando.

Dal 20/9/2026.

Valutazione

Questa issue non è ancora stata valutata.

Descrizione

status: dev-complete status: ready-for-release type: optimization
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
  1. 准备一台通过 RA/SLAAC 获取公网 IPv6 地址和默认路由的 Linux 云服务器。

  2. 确认初始状态:

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
  1. 确认服务器当前拥有公网 IPv6,并且 IPv6 网络正常。

  2. 在 1Panel 的“主机 → 防火墙 → 端口转发”中初始化端口转发;或者从已启用旧版端口转发的 v2.2.5 升级至 v2.3.1。

  3. 检查系统配置:

sysctl net.ipv6.conf.all.forwarding
grep -n "net.ipv6.conf.all.forwarding" /etc/sysctl.conf

可以看到:

net.ipv6.conf.all.forwarding = 1
  1. 重启网络、重启服务器,或等待现有 RA/SLAAC 地址和路由信息失效。

  2. 再次检查 ip -6 address 和 ip -6 route,公网 IPv6 地址或默认路由消失,只剩下 fe80:: 链路本地地址。

The expected correct result

初始化仅包含 IPv4 规则的端口转发功能时,不应修改服务器的 IPv6 forwarding 和 Router Advertisement 行为。

建议:

  1. 不要仅根据 ip6tables、ip6tables-restore 或 nftables 是否存在,就自动启用全局 IPv6 forwarding。
  2. 仅在用户创建或恢复 IPv6 端口转发规则时启用 IPv6 forwarding。
  3. 启用前检查服务器是否存在依赖 RA/SLAAC 的公网网卡。
  4. 如果相关网卡使用 accept_ra=1,应停止操作并显示明确警告,提示用户在 forwarding 模式下需要配置 accept_ra=2。
  5. 不建议未经确认就自动把所有网卡的 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

Lingua principale
Go
Stelle
37.1k
Fork
3.4k
Merge medio
12h 4m
PR unite (30g)
93

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di 1Panel-dev/1Panel

Tutte le issue di 1Panel-dev/1Panel

Issue simili

Altre issue su Go

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.