0 Replies - 1727 Views - Last Post: 19 August 2008 - 03:59 PM

#1 Tom9729   User is offline

  • Segmentation fault
  • member icon

Reputation: 181
  • View blog
  • Posts: 2,642
  • Joined: 30-December 07

Simple firewall script

Posted 19 August 2008 - 03:59 PM

Description: The only requirements are Bash and iptables.

To enable the firewall, do 'sh firewall.sh --enable'.

To disable it, do 'sh firewall.sh --disable'.This is a simple script that enables/disables an iptables firewall.

When the firewall is enabled all packets except for those belonging to normal requests will be dropped.

This script must be run as root.
# Filename:      firewall.sh
# Description:  A script to enable/disable an iptables
#                      firewall that will block all incoming
#                      packets (except requests).
# Author:         Tom Arnold

case $1 in
    --enable )
	echo "Enabling firewall..."
	iptables -F
	iptables -A INPUT -i lo -j ACCEPT
	iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
	iptables -A INPUT -j DROP

    --disable )
	echo "Disabling firewall..."
	iptables -F
    * )
	echo "Usage: sh firewall.sh [ACTION]"
	echo "t--enabletenable the firewall"
	echo "t--disabletdisable the firewall"
	echo "Report bugs to <[email protected]>."

Is This A Good Question/Topic? 0
  • +

Page 1 of 1