Saturday, March 26, 2011

my basic IPTABLES firewall

#!/bin/bash
#
# iptables example configuration script
#
# Flush all current rules from iptables
#
/sbin/iptables -F
#
# Allow SSH connections on tcp port 22
# This is essential when working on remote servers via SSH to prevent locking yourself out of the system
#
/sbin/iptables -A INPUT -p tcp --dport 22 -j ACCEPT
# Port 1521 for oracle
/sbin/iptables -A INPUT -p tcp --dport 1521 -j ACCEPT
#
# Set default policies for INPUT, FORWARD and OUTPUT chains
#
/sbin/iptables -P INPUT DROP
/sbin/iptables -P FORWARD DROP
/sbin/iptables -P OUTPUT ACCEPT
#
# Set access for localhost
#
/sbin/iptables -A INPUT -i lo -j ACCEPT
#
# Accept packets belonging to established and related connections
#
/sbin/iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
#
#---------------------------------------------------------------
# Allow port 80 (www) and 22 (SSH) connections to the firewall
#---------------------------------------------------------------

/sbin/iptables -A INPUT -p tcp -i eth0 --dport 80 --sport 1024:65535 \
  -m state --state NEW -j ACCEPT

# Save settings
#
/sbin/service iptables save
#
# List rules
#
/sbin/iptables -L -v

No comments:

Post a Comment

Followers

About Me

Torrance, CA, United States