All pastes #1812715 Raw Edit

/etc/init.d/firewall

public text v1 · immutable
#1812715 ·published 2010-02-27 00:58 UTC
rendered paste body
#! /bin/sh
#
# firewall      Start/Stop iptables firewall
#
# Author:       Mark A. LaDoux <mark@haktstudios.com>
#

set -e

PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

SCRIPTNAME=/etc/init.d/$NAME

# Gracefully exit if the package has been removed.
test -x $DAEMON || exit 0

case "$1" in
  start)
        echo -n "Starting iptables firewall"
        iptables-restore < /etc/firewall.conf
        echo "."
        ;;
  stop)
        echo -n "Stopping iptables firewall"
        iptables -F
	iptables -X
	iptables -t nat -F
	iptables -t nat -X
	iptables -t mangle -F
	iptables -t mangle -X
	iptables -P INPUT ACCEPT
	iptables -P FORWARD ACCEPT
	iptables -P OUTPUT ACCEPT
        echo "."
        ;;
  save)
	echo -n "Saving iptables firewall configuration"
	rm -rf /etc/firewall.conf
	iptables-save > /etc/firewall.conf
	echo "."
	;;
  *)
        echo "Usage: $SCRIPTNAME {start|stop|save}" >&2
        exit 1
        ;;
esac

exit 0