LinuxCommandLibrary

iptables-save

dumps the current iptables IPv4 configuration to stdout or a file

TLDR

Print all rules

$ sudo iptables-save
copy
Print specific table
$ sudo iptables-save -t filter
copy
Save to file
$ sudo iptables-save -f /etc/iptables.rules
copy

SYNOPSIS

iptables-save [OPTIONS]

DESCRIPTION

iptables-save dumps the current iptables IPv4 configuration to stdout or a file. The output can be restored using iptables-restore. Use ip6tables-save for IPv6 rules.

PARAMETERS

-t, --table table

Only output rules for the specified table (filter, nat, mangle, raw, security)
-f, --file filename
Write output to file instead of stdout
-c, --counters
Include packet and byte counters in output

CAVEATS

This saves only IPv4 rules. Use ip6tables-save for IPv6. Rules are output in a format suitable for iptables-restore. Counter values change constantly on active systems.

HISTORY

iptables-save is part of the iptables package for managing the Linux kernel firewall.

SEE ALSO

> TERMINAL_GEAR

Curated for the Linux community

Copied to clipboard

> TERMINAL_GEAR

Curated for the Linux community