iptables:save_iptable_rules
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
iptables:save_iptable_rules [2016/10/07 11:16] – peter | iptables:save_iptable_rules [2019/11/29 17:43] (current) – removed peter | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== IPTables - Save IPTable rules ====== | ||
- | ===== Save the iptables rules ===== | ||
- | |||
- | The generic method of saving iptables rules is to use the command **iptables-save**, | ||
- | |||
- | <code bash> | ||
- | iptables-save > / | ||
- | </ | ||
- | |||
- | ===== Restore the iptables rules ===== | ||
- | |||
- | The output created by **iptables-save** can then by read on stdin by **iptables-restore**. | ||
- | |||
- | If on a server, without NetworkManager, | ||
- | |||
- | <file / | ||
- | iface eth0 inet static | ||
- | .... | ||
- | pre-up iptables-restore < / | ||
- | </ | ||
- | |||
- | |||
- | ===== Example usage ===== | ||
- | |||
- | As root, issue the command: | ||
- | |||
- | <code bash> | ||
- | iptables-save > / | ||
- | </ | ||
- | |||
- | |||
- | In **/ | ||
- | |||
- | <file / | ||
- | #!/bin/sh | ||
- | iptables-restore < / | ||
- | exit 0 | ||
- | </ | ||
- | |||
- | In **/ | ||
- | |||
- | <file / | ||
- | #!/bin/sh | ||
- | iptables-save -c > / | ||
- | if [ -f / | ||
- | iptables-restore < / | ||
- | fi | ||
- | exit 0 | ||
- | </ | ||
- | |||
- | Give permission to the scripts: | ||
- | |||
- | <code bash> | ||
- | sudo chmod +x / | ||
- | sudo chmod +x / | ||
- | </ | ||
- | |||
- | |||
- | ===== IPv6 ===== | ||
- | |||
- | **NOTE**: |
iptables/save_iptable_rules.1475838964.txt.gz · Last modified: 2020/07/15 09:30 (external edit)