ip6tables -restore -h failed

本文详细介绍了如何在RH系列的系统上禁用IPv6,并提供了禁用和启用IPv6的方法。主要涉及在`/etc/sysconfig/network`文件中设置`NETWORKING_IPV6=no`和在`/etc/modprobe.conf`文件中添加禁用IPv6模块的配置。此外,还讨论了重新启用IPv6的方法,即注释掉禁用配置。

最近安装一个Linux系统,由于安装时没有IPv6环境,短时间内也不使用IPv6,所以安装过程中就没有开启IPv6的支持,防火墙是开启的。重新启动系统发现系统在加载IPv6防火墙规则的时候出错,提示为:

[root@Router ~]# /etc/init.d/ip6tables start

Applying ip6tables firewall rules: ip6tables-restore v1.3.5: ip6tables-restore: unable to initializetable 'filter'

Error occurred at line: 3
Try `ip6tables-restore -h' or 'ip6tables-restore --help' for more information.
                                                           [FAILED]

[root@Router ~]#

经过深入分析发现,由于安装程序防止系统支持IPv6,在/etc/modprobe.conf增加了相应的参数禁用IPv6。

alias net-pf-10 off
alias ipv6 off
options ipv6 disable=1

解决办法:不让ip6tables这个服务随开机启动,其实出现这个问题的主要原因是:安装程序禁用系统载入IPv6模块的同时,没有将ip6tables这个服务禁用。

=======================================================
将以上问题引申一下:
1、如何在RH系列的系统上禁用IPv6,以前都是在/etc/sysconfig/network文件中增加:

NETWORKING_IPV6=no

系统启动完毕后,你通过ifconfig仍然可以在接口上看到IPv6地址。
所以要禁用IPv6,在/etc/modprobe.conf中增加:

alias net-pf-10 off
alias ipv6 off
options ipv6 disable=1

2、如果安装时禁用了IPv6,如果让系统支持IPv6。
将/etc/modprobe.conf中的相应选项注释掉即可,如:

#alias net-pf-10 off
#alias ipv6 off
#options ipv6 disable=1

最好在/etc/sysconfig/network文件中增加:

NETWORKING_IPV6=yes
(LocalDefault/172.17.0.0/16)" 9月 26 21:07:19 localhost.localdomain dockerd[12365]: time="2025-09-26T21:07:19.066066211+08:00" level=debug msg="daemon configured with a 15 seconds minimum shutdown timeout" 9月 26 21:07:19 localhost.localdomain dockerd[12365]: time="2025-09-26T21:07:19.066080362+08:00" level=debug msg="start clean shutdown of all containers with a 15 seconds timeout..." 9月 26 21:07:19 localhost.localdomain dockerd[12365]: time="2025-09-26T21:07:19.066706289+08:00" level=debug msg="Unix socket /var/run/docker/libnetwork/cdf952a48d49.sock was closed. The external key listener will stop." 9月 26 21:07:19 localhost.localdomain dockerd[12365]: time="2025-09-26T21:07:19.067043873+08:00" level=debug msg="Cleaning up old mountid : start." 9月 26 21:07:19 localhost.localdomain dockerd[12365]: time="2025-09-26T21:07:19.067231775+08:00" level=debug msg="Cleaning up old mountid : done." 9月 26 21:07:19 localhost.localdomain dockerd[12365]: failed to start daemon: Error initializing network controller: error creating default "bridge" network: Failed to program NAT chain: COMMAND_FAILED: '/usr/sbin/ip6tables-restore -w -n' failed: ip6tables-restore v1.4.21: goto 'FWDI_docker' is not a chain 9月 26 21:07:19 localhost.localdomain dockerd[12365]: Error occurred at line: 2 9月 26 21:07:19 localhost.localdomain dockerd[12365]: Try `ip6tables-restore -h' or 'ip6tables-restore --help' for more information. 9月 26 21:07:19 localhost.localdomain systemd[1]: docker.service: main process exited, code=exited, status=1/FAILURE -- Subject: Unit docker.service has failed -- Unit docker.service has failed. 9月 26 21:07:19 localhost.localdomain systemd[1]: Unit docker.service entered failed state. 9月 26 21:07:19 localhost.localdomain systemd[1]: docker.service failed. 9月 26 21:07:21 localhost.localdomain systemd[1]: docker.service holdoff time over, scheduling restart. -- Subject: Unit docker.service has finished shutting down -- Unit docker.service has finished shutting down. 9月 26 21:07:21 localhost.localdomain systemd[1]: start request repeated too quickly for docker.service -- Subject: Unit docker.service has failed -- Unit docker.service has failed. 9月 26 21:07:21 localhost.localdomain systemd[1]: Unit docker.service entered failed state. 9月 26 21:07:21 localhost.localdomain systemd[1]: docker.service failed.
最新发布
09-28
你遇到的错误信息如下: ``` ERROR: problem running ufw-init ip6tables-restore v1.8.7 (nf_tables): Couldn't load match `hl':No such file or directory Error occurred at line: 50 Problem running '/etc/ufw/before6.rules' ``` 这个错误表明 **UFW 在启用时尝试加载 IPv6 防火墙规则失败**,具体是在处理 `/etc/ufw/before6.rules` 文件时遇到了问题。 --- ## 🧠 错误原因分析 - `Couldn't load match 'hl'`:表示你的系统缺少对 IPv6 中 `hoplimit`(相当于 IPv4 的 TTL)模块的支持。 - 这通常发生在嵌入式系统或某些 NAS 系统中(如极空间 Z4 Pro),它们可能没有完整支持所有 iptables/nftables 模块。 - UFW 默认会尝试启用 IPv6 规则,但在这种环境下会出错。 --- ## ✅ 解决方案:禁用 IPv6 的 UFW 支持 ### 步骤 1:编辑 UFW 配置文件 ```bash nano /etc/default/ufw ``` 找到以下行: ```bash IPV6=yes ``` 将其改为: ```bash IPV6=no ``` 保存并退出(在 nano 中按 `Ctrl+O` 保存,`Ctrl+X` 退出)。 --- ### 步骤 2:重新启用 UFW ```bash ufw disable ufw enable ``` 此时你应该不会再看到之前的错误。 --- ### 步骤 3:确认状态是否正常 ```bash ufw status verbose ``` 输出应类似: ``` Status: active To Action From -- ------ ---- 22/tcp ALLOW Anywhere ``` --- ## 🔒 补充建议:放行 SSH 并防止被锁在外面 为了安全起见,在启用 UFW 前请确保已经执行了放行 SSH 的命令: ```bash ufw allow 22/tcp ``` 如果你使用的是自定义端口(如 22000): ```bash ufw allow 22000/tcp ``` --- ## 📌 如果你还想修复 IPv6 支持(进阶) 你需要确认内核是否支持 `hl` 模块,并安装相关依赖: ```bash modprobe xt_HL ``` 如果提示找不到模块,说明你的系统不支持完整的 IPv6 防火墙功能。在这种情况下,继续禁用 IPv6 是更稳妥的做法。 --- ##
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值