Linux Security – How to Delete a Table in Iptables

firewalliptableslinuxSecurity

how do I delete a table in iptables (as opposed to a chain)?

I have some empty tables that are getting output by iptables-save even though I'm only using the 'filter' table.

For example, I'd like iptables-save to not produce any output regarding the 'mangle' table. Today I was playing around with iptables, and I used the mangle table. My output of iptables-save used to look like this:

# Generated by iptables-save v1.6.0 on Thr Jun 21 00:00:00 2018
*filter
:INPUT DROP [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
-A INPUT -i eth0 -p tcp -m tcp --dport 22 -j ACCEPT
-A INPUT -j DROP
COMMIT
# Completed on Thr Jun 21 00:00:00 2018

But now it looks like this:

# Generated by iptables-save v1.6.0 on Sat Jun 23 00:00:00 2018
*mangle
:PREROUTING ACCEPT [0:0]
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
:POSTROUTING ACCEPT [0:0]
COMMIT
# Completed on Sat Jun 23 00:00:00 2018
# Generated by iptables-save v1.6.0 on Sat Jun 23 00:00:00 2018
*filter
:INPUT DROP [0:0]
:FORWARD DROP [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
-A INPUT -i eth0 -p tcp -m tcp --dport 22 -j ACCEPT
-A INPUT -j DROP
COMMIT
# Completed on Sat Jun 23 00:00:00 2018

How do I delete this unused 'mangle' table to cleanup my iptables-save output?

Best Answer

Try:

rmmod iptable_mangle

once you removed all entries from mangle table (and possibly - restored default chain policies).

Related Topic