IPFirewall可以有效的增进系统的安全,但是除非你对IPFirewall有 相当的了解,否则你可能把你的机器弄的无法上网路。 警告!!绝对不要从远端连线设定IPFW,一定要从console!! 不然设定错误,你的连线可能会被中断!! 你必须在kernelconfigfile中加入optionsIPFIREWALL及options IPFIREWALL_VERBOSE,再重新编译kernel。 在你开始以前,请先manipfw。 1.编辑/etc/sysconfig,把firewall=NO改成firewall=YES 2.修改/etc/rc.firewall 你可以参照里面的□例,如果看不懂的话,请manipfw 以下是一个简单的例子: echo"IPFirewallRules...." #truetoenable,falsetodisable iftrue;then #basicinformation net="140.113.139.0" mask="255.255.255.0" mask_b="255.255.0.0" myip="140.113.139.1" #flushallrules #FreeBSD-2.21996/Sep以後的版本,请使用ipfw-fflush(见後PS) /sbin/ipfwflush #Allowallconnectionsatlast #IPFWdefaultrule:"65535denyallfromanytoany" /sbin/ipfwadd65000passallfromanytoany #Allowallconnections(thelatestmatch65000)本行最後才match! /sbin/ipfwadd65000passallfromanytoany #Allowalllocalhostconnections(firstmatch)本行最先match! /sbin/ipfwadd1000passallfrom127.0.0.1to127.0.0.1 /sbin/ipfwadd1010passallfrom${myip}toa #Friendlysites(fullyaccessrights) #这些host最好用IP,或是要纪录在/etc/hosts中 /sbin/ipfwadd1100passallfromFriend1toany /sbin/ipfwadd1120passallfromServertoany /sbin/ipfwadd1130passallfromFreeBSD.csie.nctu.edu.twtoany #denyeverything(assholehost) /sbin/ipfwadd2000denyallfrom123.123.123.123

{mask}toany #denyremotesysloggingtogetrideofsecurityproblem /sbin/ipfwadd3000denyudpfromanytoany514 #denyusersoutofcampusfromdoing"rusers","rwall" /sbin/ipfwadd4000passudpfrom${net}

{mask_b}toany1034,1035 /sbin/ipfwadd4010denyudpfromanytoany1034,1035 #denymosthostsfromtcpsprayme /sbin/ipfwadd5000denytcpfromanytoany9