25

I have what appears to be weird and convoluted set of rules which work for me at the moment. Is there a way of "exporting" those and saving them to a file so that they can be restored later on in case things are messed up?

3 Answers 3

41

With suitable privilege

iptables-save > /some/file

will save your iptables configuration to /some/file

and

iptables-restore < /some/file

will restore your saved configuration from /some/file.

1
  • Ah... I didnt know of those. I kept looking for some command line options!
    – siliconpi
    Sep 23, 2010 at 0:43
3

This should do the trick. It writes your rules to /etc/sysconfig/iptables; if you (re)start iptables after you do this, your rules should be there :)

/sbin/service iptables save
1

Don't you have iptables-save and iptables-restore commands ?

1
  • This tone is a bit rude my friend :) Nov 2, 2022 at 14:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.