ifconfig_fxp0="inet xxx.xxx.xxx.001 netmask 255.255.255.0" ifconfig_fxp0_alias0="inet xxx.xxx.xxx.002 netmask 255.255.255.0" ifconfig_fxp0_alias1="inet xxx.xxx.xxx.003 netmask 255.255.255.0" 绑好之后我们现在就开始分析了,首先我们来看看内部网络,内部要上Internet就必须要有一个网关,并且让他们正常的使用网络,假设FreeBSD内部网卡编号为fxp1,那么我们还要在rc.conf里加入: ifconfig_fxp1="inet 10.125.0.1 netmask 255.255.0.0" 然后在防火墙规则里加上: divert 8668 ip from any to any via fxp0 这条规则,答应NATD服务,仅答应NATD服务还不行,还要设置内部网络能连接到Internet,我们再加上: allow ip from any to 10.125.0.0/16 allow ip from 10.125.0.0/16 to any
allow tcp from any to xxx.xxx.xxx.001 80 in allow tcp from xxx.xxx.xxx.001 80 to any out //答应任意地方能访问防火墙的80 allow tcp from 10.80.0.80 80 to any out allow tcp from any to 10.80.0.80 80 in //答应任意地方访问WWW服务器的80端口 allow tcp from 10.125.0.0/16 to 10.80.0.80 21 in allow tcp from 10.125.0.0/16 to 10.80.0.80 20 in
allow tcp from 10.80.0.80 21 to 10.125.0.0/16 out allow tcp from 10.80.0.80 20 to 10.125.0.0/16 out //答应内部网络使用FTP服务器连接WWW服务器
allow udp from any to xxx.xxx.xxx.003 53 in allow udp from xxx.xxx.xxx.003 53 to any out //答应任意地方能访问防火墙的53端口 allow tcp from any to xxx.xxx.xxx.003 25 in allow tcp from xxx.xxx.xxx.003 25 to any out //答应任意地方能访问防火墙的smtp端口 allow udp from 10.80.2.53 53 to any out allow udp from any to 10.80.2.53 53 in //答应任意地方访问DNS服务器的53端口 allow tcp from any to 10.80.2.53 25 in allow tcp from 10.80.2.53 25 to any out //答应任意地方访问DNS的SMTP端口 allow tcp from 10.125.0.0/16 to 10.80.2.53 110 in allow tcp from 10.80.2.53 110 to 10.125.0.0/16 out //答应企业内部访问DNS的POP3端口 NATD设置为: redirect_port udp 10.80.2.53:53 xxx.xxx.xxx.003:53 //把10.80.2.53的53转到xxx.xxx.xxx.003的53上,使用的UDP。 redirect_port tcp 10.80.2.53:25 xxx.xxx.xxx.003:25 //把10.80.2.53的25转到xxx.xxx.xxx.003的25上,使用的TCP。