Quantcast
Channel: FunWithLinux.net » Debian
Viewing all articles
Browse latest Browse all 6

Start iptables in Debian Automatically

$
0
0

If you are trying to make iptables survive a reboot in Debian Squeeze or Wheezy, you may find the following of use.  After you get your iptables all squared away, save them to a text file with the incredibly handy /sbin/iptables-save command:

/sbin/iptables-save > /root/iptables.saved

This will create a text file in the /root directory containing lines that will be parsed by iptables when used with the  iptables-restore command.

Next, add the following script to your system:

#!/bin/sh
### BEGIN INIT INFO
# Provides: iptables
# Required-Start: mountkernfs $local_fs
# Required-Stop: $local_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Set up iptables rules
### END INIT INFO
/sbin/iptables-restore < /root/iptables.saved
case "$1" in
 *)
 echo "iptables loaded from file"
 ;;
esac
exit 0

Save that script to /etc/init.d/iptables

Next, run update-rc.d iptables defaults

You should now see SXXiptables in /etc/rc2.d/ and other run level directories, where XX is a number.


Viewing all articles
Browse latest Browse all 6

Latest Images

Trending Articles





Latest Images