I got this warning after selecting the docker
package when running the Ubuntu 22.04 installer. (I did not get this when I skipped selecting packages and installed Docker manually.)
After migrating to netfilter, those 10 modules can be safely removed with rmmod and blacklisted.
If any rule causes one of the 10 modules to be used, when you attempt to remove the module you will get an error such as
# modprobe -r iptable_nat
modprobe: FATAL: Module iptable_nat is in use.
To completely get rid of # Warning: iptables-legacy tables present
, I needed to wipe out completely iptables
, ip6tables
, iptables-legacy
and ip6tables-legacy
. Examine all four and check if anything from the pair of legacy
s needs to be incorporated into the respective non-legacy
pair. Below, I am using the saved non-legacy
s files after determining that I did not need to incorporate any deltas from the legacy
s.
iptables-save > iptables-save.txt
ip6tables-save > ip6tables-save.txt
iptables-legacy-save > iptables-legacy-save.txt
ip6tables-legacy-save > ip6tables-legacy-save.txt
iptables -P INPUT ACCEPT
iptables -P FORWARD ACCEPT
iptables -P OUTPUT ACCEPT
iptables -t nat -F
iptables -t nat -X
iptables -t mangle -F
iptables -t mangle -X
iptables -F
iptables -X
ip6tables -P INPUT ACCEPT
ip6tables -P FORWARD ACCEPT
ip6tables -P OUTPUT ACCEPT
ip6tables -t nat -F
ip6tables -t nat -X
ip6tables -t mangle -F
ip6tables -t mangle -X
ip6tables -F
ip6tables -X
iptables-legacy -P INPUT ACCEPT
iptables-legacy -P FORWARD ACCEPT
iptables-legacy -P OUTPUT ACCEPT
iptables-legacy -t nat -F
iptables-legacy -t nat -X
iptables-legacy -t mangle -F
iptables-legacy -t mangle -X
iptables-legacy -F
iptables-legacy -X
ip6tables-legacy -P INPUT ACCEPT
ip6tables-legacy -P FORWARD ACCEPT
ip6tables-legacy -P OUTPUT ACCEPT
ip6tables-legacy -t nat -F
ip6tables-legacy -t nat -X
ip6tables-legacy -t mangle -F
ip6tables-legacy -t mangle -X
ip6tables-legacy -F
ip6tables-legacy -X
for x in _raw _mangle _security _nat _filter; do
modprobe -r "iptable${x}"
modprobe -r "ip6table${x}"
done
iptables-restore < iptables-save.txt
ip6tables-restore < ip6tables-save.txt
You will also want to run
update-alternatives --remove iptables /usr/sbin/iptables-legacy
Please consult other resources about update-alternatives
, migrating from iptables to nft, and the security ramifications of completely clearing iptables when the machine is connected to the network. If you have Docker installed, you will not be able to apt-get purge iptables
because it is a dependency of docker-ce
.
sudo update-alternatives --display iptables
. – Doug Smythies Nov 24 '20 at 21:57iptables-legacy
command to see what rules are in legacy format. Then you can convert them to netfilter format. – Soren A Nov 25 '20 at 09:58ACCEPT
– iBug Nov 25 '20 at 10:07--display
output is pretty much the same (I seem to have apriority 10
area, related toiptables-legacy
, which I guess you removed). I run a very complicated iptables rule set and have not seen your warning. Note: my iptables rule set is loaded via bash script, I don't use iptables-persistent or iptables-save. I have another server, but it is still set to legacy. – Doug Smythies Nov 25 '20 at 16:23