<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
<title><![CDATA[BIWEB开源PHP WMS系统创始人ArthurXF肖飞的blog]]></title> 
<link>http://www.bizeway.net/index.php</link> 
<description><![CDATA[网务通 - 网务公司发展之路]]></description> 
<language>zh-cn</language> 
<copyright><![CDATA[BIWEB开源PHP WMS系统创始人ArthurXF肖飞的blog]]></copyright>
<item>
<link>http://www.bizeway.net/read.php?</link>
<title><![CDATA[跟着ArthurXF学FreeBSD40——配置IPFW防火墙]]></title> 
<author>ArthurXF &lt;arthurxf@gmail.com&gt;</author>
<category><![CDATA[FreeBSD]]></category>
<pubDate>Mon, 07 Jan 2008 11:22:18 +0000</pubDate> 
<guid>http://www.bizeway.net/read.php?</guid> 
<description>
<![CDATA[ 
	　　FreeBSD操作系统本身带有二种内置的IP信息包检查机制：ipfw和ipfilter。在创建决定允许哪些信息包进入系统、哪些信息包会被拒之系统门外的规则集方面，二种机制各有自己独特的语法。而在这里我们将使用ipfw配置FreeBSD系统的防火墙。 &nbsp;<br/>　　IPFW本身是FreeBSD内置的，要使用IPFW设置防火墙需要重新编译FreeBSD内核。注意，因为在编译后IPFW默认拒绝所有网络服务，包括对系统本身都会拒绝，所以在配置过程中一定要小心谨慎。<br/><br/>1.对IPFW的一些基本参数进行配置：<br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content">#cd /sys/i386/conf<br/>//如果没有这个目录，说明你的系统没有安装Ports服务，要记得装上。<br/>#cp GENERIC ./ArthurXF_IPFW<br/>用 vi 打开ArthurXF_IPFW文件，在文件未尾加入以下个行<br/>options IPFIREWALL //通知操作系统的内核检查每个IP数据包，将它们与规则集进行比较 <br/>options IPFIREWALL_FORWARD <br/>options IPDIVERT //启用由ipfw divert使用的转向IP套接字。这一选项需要与natd联合使用。 <br/>options IPFIREWALL_VERBOSE //启用通过Syslogd记录日志；如果没有指定这个选项，即使你在过滤规则中指定了记录包，也不会真的记录它们。 <br/>options IPFIREWALL_VERBOSE_LIMIT=10 //限制通过Syslogd记录的每项包规则的记录条数。如果你受到了大量的攻击，想记录防火墙的活动，但又不想由于Syslog洪水一般的记录将你淹没，那么这个选项将会很有用。当使用了这条规则，当规则链中的某一项达到限制数值时，它所对应的日志将不再记录下来。<br/>options IPSTEALTH //启动支持秘密转发的代码，这一选项在使防火墙不被traceroute和类似工具发现时很有用。 <br/>options IPFIREWALL_DEFAULT_TO_ACCEPT //注意，关键地方了，本句把默认的规则动作从“deny”改成“allow”了，作用是在默认状态下IPFW将会接受任何的数据。<br/>options ACCEPT_FILTER_DATA <br/>options ACCEPT_FILTER_HTTP //接受过滤器中的静态连接 <br/>options ICMP_BANDLIM //ICMP_BANDLIM根据带宽限制产生icmp错误。一般情况下我们需要这个选项，它有助于你的系统免受D.O.S.攻击。<br/><br/>另外提供一些优化参数，可以不加的，仅供参考<br/>options PQ_HUGECACHE //为1024k二级缓存的CPU提供支持 <br/>options PQ_LARGECACHE //为512k二级缓存的CPU提供支持 <br/>options PQ_MEDIUMCACHE //为256k二级缓存的CPU提供支持 <br/>options PQ_SMALLCACHE //为128k二级缓存的CPU提供支持 <br/>options CPU_ATHLON_SSE_HACK <br/>options CPU_ENABLE_SSE //为Athlon系列CPU提供SSE支持 <br/>options CPU_SUSP_HLT //打开CPU空闲节能。 <br/>options CPU_UPGRADE_HW_CACHE <br/>options CPU_WT_ALLOC <br/>options NO_MEMORY_HOLE <br/>上面有些参数，不是每个系统都会通过编译的，如果哪条出错了，就把哪条删除即可。<br/>输入完成后，保存，并退出。</div></div><br/><br/>2.编译系统内核：<br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content">#cd /usr/src<br/>#make kernel KERNCONF=ArthurXF_IPFW<br/>//开始编译内核。</div></div><br/><br/>3.加入系统启动项<br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content">#vi /etc/rc.conf<br/>加入如下参数：<br/>firewall_enable="YES"<br/>//激活Firewall防火墙<br/>firewall_script="/etc/rc.firewall"<br/>//Firewall防火墙的默认脚本<br/>firewall_type="/etc/ipfw.conf"<br/>//Firewall 自定义脚本<br/>firewall_quiet="NO"<br/>//启用脚本时是否显示规则信息；假如你不再修改防火墙脚本，那么可以把这里设成“YES“。<br/>firewall_logging_enable="YES"<br/><br/>#vi /etc/syslog.conf 文件，在文件最后加入：<br/>!ipfw<br/>*.* /var/log/ipfw.log<br/>//这行的作用是将IPFW的日志写到/var/log/ipfw.log/文件里。你可以为日志文件指定其它路径。<br/>最后，重启服务器。</div></div><br/>重启之后，你就可以用SSH登录你的服务器了，之后你可以在/etc/ipfw.conf中添加过滤规则来防止入侵了。<br/><br/>4.加入规则<br/>下面的规则只是一个例子。<br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content">vi /etc/ipfw.conf<br/>将下面的内容复制进去<br/>#!/bin/sh <br/>fwcmd="/sbin/ipfw" <br/>#${fwcmd} -f flush <br/>######### &nbsp;TCP &nbsp;########## <br/>${fwcmd} add 001 deny tcp from any to any in tcpflags syn,fin <br/>######### &nbsp;DNS &nbsp;########## <br/>${fwcmd} add 100 pass all from any to any via lo0 <br/>${fwcmd} add 110 deny all from any to 127.0.0.0/8 <br/>${fwcmd} add 120 deny ip from 127.0.0.0/8 to any <br/>${fwcmd} add 130 pass all from me to me <br/> &nbsp;<br/>${fwcmd} add 1000 allow all from me to 202.96.209.5 <br/>${fwcmd} add 1000 allow all from me to 202.96.209.133 <br/>${fwcmd} add 1000 allow all from 202.96.209.5 to me <br/>${fwcmd} add 1000 allow all from 202.96.209.133 to me <br/>######### &nbsp;www ssh ftp mail ########## <br/>${fwcmd} add 500 check-state <br/>${fwcmd} add 10000 pass tcp from any to me 80 in setup &nbsp;keep-state <br/>${fwcmd} add 10000 pass tcp from any to me 443 in setup &nbsp;keep-state <br/>${fwcmd} add 10002 allow tcp from any to me 22 in setup &nbsp;keep-state <br/>${fwcmd} add 10003 pass all from any to me 21 in setup &nbsp;keep-state <br/>${fwcmd} add 10004 pass all from me to any 21 out setup keep-state <br/>${fwcmd} add 10005 pass tcp from any to me 25 in setup &nbsp;keep-state <br/>${fwcmd} add 10006 pass tcp from me to any 25 out setup keep-state <br/>################################ <br/>${fwcmd} add 20000 allow all from any to any 53 setup keep-state <br/>${fwcmd} add 20001 allow tcp from me to any out setup keep-state <br/>${fwcmd} add 20002 allow all from me to any out setup keep-state <br/>${fwcmd} add 20003 allow all from any to me in setup keep-state <br/>######### ICMP ################# <br/>${fwcmd} add 30000 allow icmp from any to any icmptypes 3 <br/>${fwcmd} add 30001 allow icmp from any to any icmptypes 4 <br/>${fwcmd} add 30002 allow icmp from any to any icmptypes 8 out <br/>${fwcmd} add 30003 allow icmp from any to any icmptypes 0 in <br/>${fwcmd} add 30004 allow icmp from any to any icmptypes 11 in <br/>${fwcmd} add 50000 deny all from any to any<br/>中间那些80，443等都是服务的端口号，可以根据需要修改的。</div></div><br/><br/>5.常用命令<br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content">加载规则 &nbsp; &nbsp; &nbsp; &nbsp;sh /etc/ipfw.conf <br/>显示规则 &nbsp; &nbsp; &nbsp; &nbsp;ipfw show</div></div><br/><br/>6.ipfw生效<br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content">要让ipfw自启动生效，就需要修改一下。<br/>#vi /etc/rc.conf<br/>修改为<br/>firewall_script="/etc/ipfw.conf"<br/>firewall_quiet="YES" //安静模式<br/>重起就好了。</div></div><br/>　　此文章有ArthurXF倾情奉献，谢谢支持！<br/><br/>现在ArthurXF本人正在搞PHP等技术培训，如果想学习的人可以跟我联系。另外培训的招生简章在这个网址，想了解的可以去看看。加我QQ：29011218交流也可。<br/><a href="http://www.bizeway.net/read.php/285.htm" target="_blank">PHP培训招生简章</a><br/>Tags - <a href="tag.php?tag=ipfw" rel="tag">ipfw</a> , <a href="tag.php?tag=freebsd" rel="tag">freebsd</a>
]]>
</description>
</item><item>
<link>http://www.bizeway.net/read.php?&amp;guid=0#topreply</link>
<title><![CDATA[[评论] 跟着ArthurXF学FreeBSD40——配置IPFW防火墙]]></title> 
<author> &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Thu, 01 Jan 1970 00:00:00 +0000</pubDate> 
<guid>http://www.bizeway.net/read.php?&amp;guid=0#topreply</guid> 
<description>
<![CDATA[ 
	
]]>
</description>
</item>
</channel>
</rss>