# from the /etc/sysconfig/iptables file. The save and restore
# arguments are included to preserve compatibility with
# Redhat's init.d script (at least in 7.x) if you prefer to use it.
# Redhat installation instructions
#
# 1. Ensure that ipchains will not automatically start.
# chkconfig --level 0123456 ipchains off
# This will make sure that the ipchains init.d script
# is not linked to an S file in any of the rc directories.
#
# 2. Stop ipchains if it's running.
# service ipchains stop
#
# 3. Execute lsmod to see if the ipchains kernel module is still loaded.
# If it is, use rmmod to unload it. -- rmmod ipchains
#
# 4. Have the system link the iptables init.d startup script into run states
# 2, 3, and 5.
# chkconfig --level 235 iptables on
#
# 5. Save this script and execute it to load the ruleset from this file.
# You may need to run the dos2unix command on it to remove carraige returns.
#
# 6. To have it applied at startup, copy this script to
# /etc/init.d/iptables. It accepts stop, start, save, and restore
# arguments. (You may wish to save the existing one first.)
#
# 7. For non-Redhat systems (or Redhat systems if you have a problem), you
# may want to append the command to execute this script to rc.local.
# rc.local is typically located in /etc and /etc/rc.d and is usually
# the last thing executed on startup. Simply add /path/to/script/script_name
# on its own line in the rc.local file.
###############################################################################
#
# Local Settings
#
# sysctl location. If set, it will use sysctl to adjust the kernel parameters.
# If this is set to the empty string (or is unset), the use of sysctl
# is disabled.
SYSCTL="/sbin/sysctl -w"
# To echo the value directly to the /proc file instead
# SYSCTL=""
# IPTables Location - adjust if needed
IPT="/sbin/iptables"
IPTS="/sbin/iptables-save"
IPTR="/sbin/iptables-restore"
# Internet Interface
INET_IFACE="eth0"
INET_ADDRESS="your web ip"
# Localhost Interface
LO_IFACE="lo"
LO_IP="127.0.0.1"
# Save and Restore arguments handled here
if [ "$1" = "save" ]
then
echo -n "Saving firewall to /etc/sysconfig/iptables ... "
$IPTS > /etc/sysconfig/iptables
echo "done"
exit 0
elif [ "$1" = "restore" ]
then
echo -n "Restoring firewall from /etc/sysconfig/iptables ... "
$IPTR < /etc/sysconfig/iptables
echo "done"
exit 0
fi
###############################################################################
#
# Load Modules
#
echo "Loading kernel modules ..."
# You should uncomment the line below and run it the first time just to