Fli
01-01-2016, 11:46 PM
When doing some changes in iptables, one can first save the rules so it can be restored if something go wrong.
SAVE
iptables-save > /etc/iptables/rules.v4-datehere-working;ip6tables-save > /etc/iptables/rules.v6-datehere-working
RESTORE
iptables-restore < /etc/iptables/rules.v4-datehere-working;ip6tables-restore < /etc/iptables/rules.v6-datehere-working
----
After rules are changed and verified to be working/not blocking valid traffic, it needs to be saved to survive reboot:
Make it persistent:
On CentOS, its done by command:
"service iptables save" or "iptables-save > /etc/sysconfig/iptables"
On Debian/Ubuntu, one may try:
sudo apt install iptables-persistent && sudo iptables-save|sudo tee -a /etc/iptables/rules.v4 && sudo ip6tables-save|sudo tee -a /etc/iptables/rules.v6
(system will then load that files during boot)
NOTE: some services add iptables rules upond start and so you may consider adjusting your exported /etc/iptables/rules.v* files in case you find that after reboot there are duplicate rules.
SAVE
iptables-save > /etc/iptables/rules.v4-datehere-working;ip6tables-save > /etc/iptables/rules.v6-datehere-working
RESTORE
iptables-restore < /etc/iptables/rules.v4-datehere-working;ip6tables-restore < /etc/iptables/rules.v6-datehere-working
----
After rules are changed and verified to be working/not blocking valid traffic, it needs to be saved to survive reboot:
Make it persistent:
On CentOS, its done by command:
"service iptables save" or "iptables-save > /etc/sysconfig/iptables"
On Debian/Ubuntu, one may try:
sudo apt install iptables-persistent && sudo iptables-save|sudo tee -a /etc/iptables/rules.v4 && sudo ip6tables-save|sudo tee -a /etc/iptables/rules.v6
(system will then load that files during boot)
NOTE: some services add iptables rules upond start and so you may consider adjusting your exported /etc/iptables/rules.v* files in case you find that after reboot there are duplicate rules.