#!/usr/bin/env bash

#该脚本的作用是：设置web 防火墙

cp /etc/sysconfig/iptables{,.`date +%F`_bak}

cat << EOF > /etc/sysconfig/iptables
# Firewall configuration written by system-config-firewall
# Manual customization of this file is not recommended.
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]

-A INPUT -p tcp -m tcp --dport 80 --tcp-flags FIN,SYN,RST,ACK SYN -m connlimit --connlimit-above 32 --connlimit-mask 32 -j DROP
-A INPUT -p tcp -s 10.117.64.45 -m multiport --dport 22,873 -j ACCEPT
-A INPUT -p tcp -s 10.117.67.0 -m multiport --dport 22,873 -j ACCEPT
-A INPUT -p tcp --dport 80 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp -s 120.24.212.147 --dport 10050 -j ACCEPT
-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
COMMIT
EOF

service iptables restart