- 论坛徽章:
- 0
|
刚接触PF,边学边写的一个规则
有几个问题,请大家看看
1、ext_if 必须允许from any to any port 80的数据报进入,否则DMZ服务器不能访问,改目标地址为dmz服务器的外网地址就不行
2、内网用户能ping通DMZ服务器内网地址,但不能用服务器的内网地址10.1.1.10访问web服务,只能用外网地址
-
- 电 信
- \
- \
- \ fxp0 222.222.222.209/28
- __\______
- | |
- | PF防火墙|
- |_________|
- fxp1/ \fxp2
- / \
- / \
- DMZ / \内网
- servip:10.1.1.10 192.168.0.0/24
复制代码
rc.conf
- defaultrouter="222.222.222.209"
- hostname="www.kkkk.net"
- ifconfig_fxp0="inet 222.222.222.219 netmask 255.255.255.240"
- ifconfig_fxp0_alias0="inet 222.222.222.220 netmask 255.255.255.240"
- ifconfig_fxp1="inet 10.1.1.20 netmask 255.255.255.224"
- ifconfig_fxp2="inet 192.168.0.1 netmask 255.255.255.0"
- linux_enable="YES"
- sshd_enable="YES"
- inetd_enable="YES"
- gateway_enable="YES"
- pf_enable="YES"
- pf_rules="/etc/pf.conf"
- pflog_enable="YES"
- syslogd_flags="-ss"
- sendmail_enable="NO"
- sendmail_submit_enable="NO"
- sendmail_outbound_enable="NO"
- sendmail_msp_queue_enable="NO"
复制代码
pf.conf
- ext_if="fxp0"
- int_if="fxp2"
- dmz_if="fxp1"
- serv_intip="10.1.1.10"
- serv_extip="222.222.222.220"
-
- priv_net="{127.0.0.0/8,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16}"
- icmp_types="echoreq"
- drop_tcpports="{135,139,445,9996,593,6667,15436,137}"
- drop_udpports="{135,139,445,5554,9996,593,137}"
-
- set limit { states 100000, frags 50000 }
- set loginterface fxp0
- set optimization aggressive
- set block-policy drop
- scrub on $ext_if all reassemble tcp
- #NAT规则
- nat on $ext_if from $int_if:network to any ->; $ext_if:0
- binat on $ext_if from $serv_intip to any ->; $serv_extip
- rdr on {$int_if,$dmz_if} proto tcp from any to any port 21 ->; 127.0.0.1 port 8021
- rdr on $int_if proto tcp from $int_if:network to $serv_extip port 80 ->; 127.0.0.1 port 9000
- #过滤规则
- block all
- pass quick on lo0 all
- block in quick on $ext_if from $priv_net to any
- block out quick on $ext_if from any to $priv_net
-
- block quick on {$ext_if,$int_if,$dmz_if} proto tcp from any to any port $drop_tcpports
- block quick on {$ext_if,$int_if,$dmz_if} proto udp from any to any port $drop_udpports
-
- pass in quick on $int_if proto {tcp,udp,icmp} from $int_if:network to any modulate state
-
- pass out quick on $ext_if proto {tcp,udp,icmp} from $ext_if:network to any modulate state
- pass in quick on $ext_if inet proto icmp from any to any icmp-type $icmp_types keep state
- pass in quick on $ext_if proto tcp from any to $ext_if:0 port 22 flags S/SA synproxy state
- pass in quick on $ext_if proto tcp from any to any port 80 flags S/SA synproxy state
-
- pass out quick on $dmz_if proto tcp from any to $serv_intip port 80 synproxy state
- pass in quick on $dmz_if proto {tcp,udp,icmp} from $dmz_if:network to any modulate state
- pass out quick on $dmz_if inet proto icmp from any to $dmz_if:network icmp-type $icmp_types keep state
复制代码 |
|