linux防火墙脚本 不指定

jed , 2013-6-19 12:01 , 服务器技术 , 评论(0) , 阅读(112586) , Via 本站原创 | |
firewall.sh

#!/bin/sh
/sbin/modprobe ip_tables
/sbin/modprobe iptable_filter
/sbin/modprobe iptable_nat
/sbin/modprobe ip_conntrack
/sbin/modprobe ip_conntrack_ftp
#以上命令为载入模块
iptables -P INPUT DROP
iptables -F INPUT
iptables -P OUTPUT ACCEPT
iptables -F OUTPUT
iptables -P FORWARD DROP
iptables -F FORWARD
iptables -t nat -F
#以上命令为设置默认规则----禁止所有,注意会清空原有规则,请注意原有规则的保存备份。
################################add tointernet##########################
iptables -A INPUT -p udp --sport 53 -j ACCEPT
iptables -A INPUT -p udp --sport 123 -j ACCEPT
iptables -A INPUT -p tcp --sport 20 -j ACCEPT
iptables -A INPUT -p tcp --sport 21 -j ACCEPT
iptables -A INPUT -p tcp --sport 80 -j ACCEPT
iptables -A INPUT -p tcp --sport 443 -j ACCEPT
iptables -A INPUT -p tcp --sport 8080 -j ACCEPT
iptables -A INPUT -p tcp --sport 25 -j ACCEPT
iptables -A INPUT -p tcp --sport 3306 -j ACCEPT
iptables -A INPUT -p tcp --sport 52521 -j ACCEPT
################################add tointernet##########################
#以上规则的意思是,开放你服务器对外访问的回程允许,如果你的服务器不需要对外访问,请删除
################################禁止IP#############################
#iptables -A INPUT  -s 66.85.180.96 -j DROP
#
################################add manager#############################
iptables -A INPUT -s 127.0.0.1 -j ACCEPT
iptables -A INPUT -s ***.***.***.*** -p 0 -j ACCEPT

################################add manager#############################
#以上的规则的意思是,开放你的管理客户端的所有通讯(当然包括22端口啦),但除了这个源IP外,其它任何IP都访问该服务器的22端口了
#
#
################################add 80##################################
iptables -A INPUT -p tcp --dport 80 -j ACCEPT
iptables -A INPUT -p tcp --dport 3306 -j ACCEPT
################################add 80##################################
#开放外网所有访问你的80
#如果你的MYSQL或其它服务需要对外开放,请按上面的格式添加
#
#丢弃坏的TCP包
#iptables -A FORWARD -p TCP ! --syn -m state --state NEW -j DROP
#处理IP碎片数量,防止攻击,允许每秒100个
#iptables -A FORWARD -f -m limit --limit 100/s --limit-burst 100 -j ACCEPT
#
#
/etc/rc.d/init.d/iptables save
/etc/rc.d/init.d/iptables restart



jk.sh


#!/bin/bash
WAIT_DIR=${1-/datan/website}
nohup /usr/local/bin/inotifywait --exclude '^/datan/website/(god|ddimg|upimg|file)/' -qmre attrib,modify,move,create,delete $WAIT_DIR --format '"%w" "%f" "%e" "%T"' --timefmt='%F_%T' \
        | while read DIR FILE EVENT TIME ;do
echo $DIR $FILE $EVENT $TIME >>/data/logs/jk/web_$(date -d "yesterday" +"%Y%m%d").txt

done



发表评论

昵称

网址

电邮

打开HTML 打开UBB 打开表情 隐藏 记住我 [登入] [注册]