今天有空对服务器 do-release-upgrade,于是才踩了坑。
鉴于 Fail2ban
对 iptables
具备更好的兼容性和易用性,在服务器的使用环境下,最终决定从 iptables-nft
切换回 iptables-legacy
,主打简单易配置。
以下为 GPT 原文精简:
在 Ubuntu 22.04 中,系统默认使用 iptables-nft
,这是一种兼容 iptables
语法的工具,但其底层实现基于 nftables
。如果希望继续使用传统的 iptables
,可以切换到 iptables-legacy
,同时适用于 Ubuntu 24.04。
1、查看当前 iptables
版本:
sudo update-alternatives --config iptables
此命令将显示可用的 iptables
版本列表,以及当前正在使用的版本。
2、选择 iptables-legacy
:
在上述命令的输出中,将看到类似以下的选项:
There are 2 choices for the alternative iptables (providing /usr/sbin/iptables).
Selection Path Priority Status
------------------------------------------------------------
0 /usr/sbin/iptables-nft 20 auto mode
1 /usr/sbin/iptables-legacy 10 manual mode
2 /usr/sbin/iptables-nft 20 manual mode
Press <enter> to keep the current choice[*], or type selection number:
输入对应 iptables-legacy
的编号(在此示例中为 1
),然后按回车键。
此外,如果希望在系统重启后保留 iptables
规则,需要安装 iptables-persistent
工具:
sudo apt install iptables-persistent
安装过程中,系统会提示保存当前的 iptables
规则,选择“是”即可。
同时,需确保在系统启动时加载保存的规则:
sudo systemctl enable netfilter-persistent
最后 reboot
,重启后确认是否已可用,以上。
本站由以下主机服务商提供服务支持:
0条评论