#!/bin/bash
PATH=/sbin:/usr/sbin:/bin:/usr/bin
export PATH
function start(){
echo 'start iptables: [ok]'
iptables -F
iptables -X
iptables -Z
iptables-restore < /root/iptables.rules
}
function stop(){
echo 'stop iptables: [ok]'
iptables -P INPUT ACCEPT
iptables -P OUTPUT ACCEPT
iptables -P FORWARD ACCEPT
function restart(){
stop
sleep 2
start
function status(){
RULES_COUNT=$(iptables -nL | wc -l)
if [ $RULES_COUNT -gt '8' ];then
echo 'iptables is running ...'
else
echo 'iptables is not running ...'
fi
case $1 in
start)
start
;;
stop)
stop
restart)
restart
status)
status
*)
echo 'Usage:start|stop|restart'
esac
本文轉自 freeterman 51CTO部落格,原文連結:http://blog.51cto.com/myunix/1289700,如需轉載請自行聯系原作者