#!/bin/bash
#This is a fast firewall configuration script.
#Script author:
#编写防火墙配置脚本首要的任务是先定义脚本使用的变量
#设置防火墙状态的变量
IPTABLES_STATUS=0
#设置OUTPUT和INPUT链的默认规则变量
DEFAULT_OUTPUT=0
DEFAULT_INPUT=0
#设置系统服务SSH的端口规则变量
RULE_SSH=0
#设置ICMP协议规则变量(决定ping服务)
RULE_ICMP=0
设置INPUT/OUTPUT链需要打开的端口列表
OPEN_IN_PORT=null
OPEN_OUT_PORT=null
#设置命令头变量
IPT="/sbin/iptables"
#设置防火墙开机自启动状态的函数
#function iptables_status
#Used to set the firewall status
function iptables_status()
{
if [ $1 = 0 ]
then
if `chkconfig --level 345 iptables on &>/dev/null`
then
return 0
else
return 1
fi
else
if `chkconfig iptables off &>/dev/null`
then
return 0
else
return 1
fi
fi
}
#脚本的主体结构(防火墙自启动状态的赋值)
if [ "`whoami`" != "root" ]
then
echo "You need to be root to run this script" >2
exit
fi
while true
do
echo -n "Open the system firewall?[yes|no]"
read ANS
case "$ANS" in
y|Y|yes|Yes)
#This is a fast firewall configuration script.
#Script author:
#编写防火墙配置脚本首要的任务是先定义脚本使用的变量
#设置防火墙状态的变量
IPTABLES_STATUS=0
#设置OUTPUT和INPUT链的默认规则变量
DEFAULT_OUTPUT=0
DEFAULT_INPUT=0
#设置系统服务SSH的端口规则变量
RULE_SSH=0
#设置ICMP协议规则变量(决定ping服务)
RULE_ICMP=0
设置INPUT/OUTPUT链需要打开的端口列表
OPEN_IN_PORT=null
OPEN_OUT_PORT=null
#设置命令头变量
IPT="/sbin/iptables"
#设置防火墙开机自启动状态的函数
#function iptables_status
#Used to set the firewall status
function iptables_status()
{
if [ $1 = 0 ]
then
if `chkconfig --level 345 iptables on &>/dev/null`
then
return 0
else
return 1
fi
else
if `chkconfig iptables off &>/dev/null`
then
return 0
else
return 1
fi
fi
}
#脚本的主体结构(防火墙自启动状态的赋值)
if [ "`whoami`" != "root" ]
then
echo "You need to be root to run this script" >2
exit
fi
while true
do
echo -n "Open the system firewall?[yes|no]"
read ANS
case "$ANS" in
y|Y|yes|Yes)