# # iptables Script to load iptables style firewall # # Author: Eric von Bayer # # chkconfig: 2345 57 65 # description: Loads or clears the iptables style firewall in a \ # system # Source function library. . /etc/rc.d/init.d/functions ipconf=/etc/iptables.conf lockfile=/var/lock/subsys/iptables # See how we were called. case "$1" in start) # Start up the firewall as long as we have a config file if [ -f $ipconf ]; then action "Starting iptables firewall: " /sbin/iptables-config else action "Starting iptables firewall: " /bin/false fi touch $lockfile ;; stop) # Stop the firewall if we started it if [ -f $lockfile ] ; then action "Stopping iptables firewall: " /sbin/iptables -F /sbin/iptables -X rm -f /var/lock/subsys/iptables else action "Stopping iptables firewall: " /bin/false fi ;; status) # Give a firewall status if [ -f $lockfile ]; then echo -n "IP Chains Firewall was loaded at " ls -al $lockfile | awk '{ print $6 " " $7 " " $8 "." ; }' else echo "IP Chains Firewall is not loaded." fi ;; restart|reload) # Same as start for now if [ -f $ipconf ]; then action "Restarting iptables firewall: " /sbin/iptables-config else action "Restarting iptables firewall: " /bin/false fi touch $lockfile ;; *) # do not advertise unreasonable commands that there is no reason # to use with this device echo "Usage: iptables {start|stop|status|restart|reload}" exit 1 esac exit 0