利用FreeBSD组建安全的网关(3) #######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上去。