↑ ↓ select, Enter open, Esc close

Back up iptables rules to a file

root@server
iptables-save > /root/iptables-$(date +%F-%H%M).rules

Writes all IPv4 tables, chains and rules in iptables-restore format to a file under /root. This lets you restore the previous state after a failed change. For IPv6, ip6tables-save works the same way.

Note: Worthwhile before experimenting on Plesk servers with the firewall extension, because the extension sets its rules directly via iptables.

Also searched as

  • how to save iptables rules
  • backup firewall rules linux
  • iptables-save to file

Related one-liners

All in Firewall

Read first, then run.

The commands on myline.de act directly on servers, files and databases. A wrong path or placeholder can delete data irreversibly or make a server unreachable.

  • All commands are provided without warranty and are not tested on every system.
  • Understand what a command does before running it, and check every placeholder.
  • Make a backup first and, if possible, try it on a test system.
  • You run commands at your own risk. Liability for damages is excluded to the extent permitted by law.