Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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

# Setup iptables
IPT="/sbin/iptables"

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

# Set default policies for all three default chains
$IPT -P INPUT DROP
$IPT -P FORWARD DROP
$IPT -P OUTPUT ACCEPT

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

2 Answers 2

up vote 0 down vote accepted

everything you need to know is here

http://www.tldp.org/LDP/abs/html/

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

EDIT:

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: https://wiki.debian.org/iptables

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

 
discard

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.