Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

[Bug] IPv6 connectivity is lost after initializing port forwarding

Cerrado
#13,876 1 comentario 0 reacciones 1 asignado Ver en GitHub

Los mantenedores suelen responder en 1 día

@wanghe-fit2cloud ya está trabajando en esto.

Desde el 20/9/2026.

Evaluación

Este issue todavía no se ha evaluado.

Descripción

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

Lenguaje dominante
Go
Estrellas
37.1k
Forks
3.4k
Merge medio
13 h
PR fusionados (30 d)
82

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de 1Panel-dev/1Panel

Todos los issues de 1Panel-dev/1Panel

Issues similares

Más issues de Go

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.