Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Currently I have a debian install with a shell script which has the following content (as an example):

# Setup iptables

# Flush old rules, old custom tables
$IPT --flush
$IPT --delete-chain

# Set default policies for all three default chains

I was wondering if, instead of putting these rules in a shell script, I could have them in a file such as iptables.rules instead? This raises two further questions:

  1. Would I need to modify the contents of the script
  2. Where would I need to link the rules file to
share|improve this question
Wherever you found that tutorial, it is ancient, far out of date, and wrong. – Michael Hampton Nov 24 '13 at 2:58
@MichaelHampton That doesn't help – Jimmy Nov 24 '13 at 10:10
up vote 0 down vote accepted

everything you need to know is here

after you have your init script to your liking, you can install it in /etc/init (varies depending on distro) so your processes will survive a reboot


iptables is a special case, where once you have your rules to your liking, you can run

sudo service iptables save

and your rules will be saves accross reboots

share|improve this answer

I think the answers you are looking for might be here:

Basically, the answer is yes. I'm just wondering what you are trying to accomplish. Like nandoP said, you can just use 'iptables save' to save your rules and make them persistent. If you want to save a template rules file to duplicate firewall settings across a few systems you can use your saved rules file as input for iptables-restore.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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