elastix iptables 安全设置

来源:互联网 发布:python netsnmp 实例 编辑:程序博客网 时间:2024/05/16 06:35

#!/bin/sh

#脚本名称:firewall.sh

 

#用途:防火墙设置,只开发web和ssh端口

/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 udp -m udp --dport 5060 -j ACCEPT

#iptables -A INPUT -p udp -m udp --dport 4569 -j ACCEPT

#iptables -A INPUT -p udp -m udp --dport 10000:20000 -j ACCEPT

################################add tointernet##########################

#以上规则的意思是,开放你服务器对外访问的回程允许,如果你的服务器不需要对外访问,请删除

#

#

################################add manager#############################

iptables -A INPUT -s 127.0.0.1 -j ACCEPT

iptables -A INPUT -s 192.168.1.0/24 -j ACCEPT

#iptables -A INPUT -s {你的源IP} -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 22 -j ACCEPT

################################add 80##################################

#开放外网所有访问你的web 和ssh

#如果你的MYSQL或其它服务需要对外开放,请按上面的格式添加

#

#

#################################close icmp#################################

iptables -A INPUT -p icmp -j DROP

#################################close icmp#################################

#以上规则的意思是关闭icmp

#

/etc/rc.d/init.d/iptables save

/etc/rc.d/init.d/iptables restart

原创粉丝点击