- 论坛徽章:
- 0
|
fb6内核添加防火墙功能支持,防火墙规则允许udp包进出服务器,可以ping通网关 dns 服务器 的ip 222。88。88。88,但是不能解析
域名,类似,www。google.com ,但是 /ect/resolv.conf文件已经添加了nameserver 222.88.88.88 ,会是那里的原因?
付上防火墙规则:
新建/etc/ipfw.conf 文件,在文件里写入以下内容:
add 00400 divert natd ip from any to any via xl0 //natd服务启动设置
add 00001 deny log ip from any to any ipopt rr
add 00002 deny log ip from any to any ipopt ts
add 00003 deny log ip from any to any ipopt ssrr
add 00004 deny log ip from any to any ipopt lsrr
add 00005 deny tcp from any to any in tcpflags syn,fin //这5行是过滤各种扫描包
#######tcp#########
add 10000 allow tcp from xx.xx.xx.xx to x.x.x.x 22 in //向Internet的xx.xx.xx.xx这个IP开放SSH服务。也就是只信任这个IP的SSH登陆。
add 10001 allow tcp from any to x.x.x.x 80 in //向整个Internet开放HTTP服务。
add 10002 allow tcp from any to x.x.x.x 25 in //向整个Internet开放smtp服务。
add 10003 allow tcp from any to x.x.x.x 110 in //向整个Internet开放pop3服务。
add 19997 check-state
add 19998 allow tcp from any to any out keep-state setup
add 19999 allow tcp from any to any out //这三个组合起来是允许内部网络访问出去,如果想服务器自己不和Internet进行tcp连接出去,可以把19997和19998去掉。(不影响Internet对服务器的访问)
######udp##########
add 20001 allow udp from any 53 to me in recv xl0 //允许其他DNS服务器的信息进入该服务器,因为自己要进行DNS解析嘛~
add 20002 allow udp from any to x.x.x.x 53 in recv xl0 //向整个Internet开放DNS服务。
add 29999 allow udp from any to any out //允许自己的UDP包往外发送。
######icmp#########
add 30000 allow icmp from any to any icmptypes 3
add 30001 allow icmp from any to any icmptypes 4
add 30002 allow icmp from any to any icmptypes 8 out
add 30003 allow icmp from any to any icmptypes 0 in
add 30004 allow icmp from any to any icmptypes 11 in //允许自己ping别人的服务器。也允许内部网络用router命令进行路由跟踪。
#######lan##########
add 40000 allow all from 192.168.0.0/16 to any
add 40001 allow all from any to 192.168.0.0/16 //允许内部网络访问Internet。
好了,还有natd没设置了,我们再次添加/etc/natd.conf这个文件,其内容如下:
log yes //启动natd的log记录。
redirect_port tcp 192.168.0.2:25 x.x.x.x:25 //把对服务器IP为x.x.x.x的smtp访问转到192.168.0.2的25上去。
redirect_port tcp 192.168.0.2:80 x.x.x.x:80 //把对服务器IP为x.x.x.x的http访问转到192.168.0.2的80上去。
redirect_port tcp 192.168.0.2:110 x.x.x.x:110 //把对服务器IP为x.x.x.x的pop3访问转到192.168.0.2的110上去。
好了,natd也设置完了~重新启动一下系统让防火墙和natd生效,现在就是该装的服务没装了,虽然防火墙已经让这些服务通行。 |
|