从 Ubuntu 18.04 升级到 20.04 后缺少 iptables 内核模块

从 Ubuntu 18.04 升级到 20.04 后缺少 iptables 内核模块

从 Ubuntu 18.04 版本升级到 20.04(focal)后,缺少 iptables 内核模块:

root@server:~# iptables -L
modprobe: FATAL: Module ip_tables not found in directory /lib/modules/5.4.0-42-generic
iptables v1.8.4 (legacy): can't initialize iptables table `filter': Table does not exist (do you need to insmod?)
Perhaps iptables or your kernel needs to be upgraded.

我尝试了以下操作,但未能解决问题:

sudo apt-get install --reinstall iptables
sudo apt-get install --reinstall linux-headers-$(uname -r)
sudo dpkg-reconfigure iptables
dkms autoinstall

linux-modules-extra 也已安装

的输出ls -R /var/lib/dkms是:

/var/lib/dkms:
dkms_dbversion  wireguard

/var/lib/dkms/wireguard:
1.0.20200611  kernel-5.4.0-42-generic-x86_64

/var/lib/dkms/wireguard/1.0.20200611:
5.4.0-42-generic  source

/var/lib/dkms/wireguard/1.0.20200611/5.4.0-42-generic:
x86_64

/var/lib/dkms/wireguard/1.0.20200611/5.4.0-42-generic/x86_64:
log  module

/var/lib/dkms/wireguard/1.0.20200611/5.4.0-42-generic/x86_64/log:
make.log

/var/lib/dkms/wireguard/1.0.20200611/5.4.0-42-generic/x86_64/module:
wireguard.ko

关于如何重新激活 iptables 有什么想法吗?

答案1

在我的 Ubuntu 20.04 安装中,该文件/lib/modules/5.4.0-40-generic/kernel/net/ipv4/netfilter/ip_tables.ko属于linux-modules软件包,而不是linux-modules-extra。重新安装linux-modules应该可以解决问题:

sudo apt-get install --reinstall linux-modules-5.4.0-42-generic

相关内容