<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
<title><![CDATA[沧海一粟]]></title> 
<link>http://www.dzhope.com/index.php</link> 
<description><![CDATA[Web系统架构与服务器运维,php开发]]></description> 
<language>zh-cn</language> 
<copyright><![CDATA[沧海一粟]]></copyright>
<item>
<link>http://www.dzhope.com/post//</link>
<title><![CDATA[iptables在web服务器的示例]]></title> 
<author>jed &lt;jed521@163.com&gt;</author>
<category><![CDATA[服务器技术]]></category>
<pubDate>Wed, 29 Dec 2010 23:10:59 +0000</pubDate> 
<guid>http://www.dzhope.com/post//</guid> 
<description>
<![CDATA[ 
	新建一个shell脚本<br/>vi firewall.sh<br/>将下面的内容，从“内容开始”至“内容结束”全部复制添加到上面的脚本文件中。<br/>注意将下面内容中的一个内容替换--&#123;你的源IP&#125; 替换成你的源IP。如果你的源IP是动态的，建议将开放80那样开放它。<div class="code"><br/>------------------------------------------内容开始<br/>#!/bin/sh<br/>/sbin/modprobe ip_tables<br/>/sbin/modprobe iptable_filter<br/>/sbin/modprobe iptable_nat<br/>/sbin/modprobe ip_conntrack<br/>/sbin/modprobe ip_conntrack_ftp<br/>#以上命令为载入模块<br/>iptables -P INPUT DROP<br/>iptables -F INPUT&nbsp;&nbsp; <br/>iptables -P OUTPUT ACCEPT<br/>iptables -F OUTPUT<br/>iptables -P FORWARD DROP<br/>iptables -F FORWARD<br/>iptables -t nat -F<br/>#以上命令为设置默认规则----禁止所有，注意会清空原有规则，请注意原有规则的保存备份。<br/>################################add tointernet##########################<br/>iptables -A INPUT -p udp --sport 53 -j ACCEPT<br/>iptables -A INPUT -p udp --sport 123 -j ACCEPT<br/>iptables -A INPUT -p tcp --sport 20 -j ACCEPT<br/>iptables -A INPUT -p tcp --sport 21 -j ACCEPT<br/>iptables -A INPUT -p tcp --sport 80 -j ACCEPT<br/>iptables -A INPUT -p tcp --sport 443 -j ACCEPT<br/>iptables -A INPUT -p tcp --sport 8080 -j ACCEPT<br/>################################add tointernet##########################<br/>#以上规则的意思是，开放你服务器对外访问的回程允许，如果你的服务器不需要对外访问，请删除<br/>#<br/>#<br/>################################add manager#############################<br/>iptables -A INPUT -s 127.0.0.1 -j ACCEPT<br/>iptables -A INPUT -s &#123;你的源IP&#125; -p 0 -j ACCEPT<br/>################################add manager#############################<br/>#以上的规则的意思是，开放你的管理客户端的所有通讯(当然包括22端口啦)，但除了这个源IP外，其它任何IP都访问该服务器的22端口了<br/>#<br/>#<br/>################################add 80##################################<br/>iptables -A INPUT -p tcp --dport 80 -j ACCEPT<br/>################################add 80##################################<br/>#开放外网所有访问你的80<br/>#如果你的MYSQL或其它服务需要对外开放，请按上面的格式添加<br/>#<br/>#<br/>/etc/rc.d/init.d/iptables save<br/>/etc/rc.d/init.d/iptables restart<br/>------------------------------------------内容结束<br/><br/></div><br/>保存shell脚本文件。<br/><br/>通过下面的命令，将脚本执行<br/>/bin/sh firewall.sh<br/>看到OK状态后，通过下面的命令检查IPTABLES状态<br/>iptables -L -n<br/><br/><br/>Tags - <a href="http://www.dzhope.com/tags/shell/" rel="tag">shell</a> , <a href="http://www.dzhope.com/tags/iptables/" rel="tag">iptables</a>
]]>
</description>
</item><item>
<link>http://www.dzhope.com/post//#blogcomment</link>
<title><![CDATA[[评论] iptables在web服务器的示例]]></title> 
<author> &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Thu, 01 Jan 1970 00:00:00 +0000</pubDate> 
<guid>http://www.dzhope.com/post//#blogcomment</guid> 
<description>
<![CDATA[ 
	
]]>
</description>
</item>
</channel>
</rss>