Firewall

pf 極大地降低了流量

  • June 7, 2013

我在 FreeBSD 9.1 上執行 Web 和郵件伺服器。該系統安裝在 KVM vServer 上。一切正常 - 直到我啟用 pf(4)。我的部落格變得異常緩慢。所有其他流量也是如此,但這並不是那麼煩人。

因此,如果有人能告訴我問題可能出在哪裡,那就太好了。

提前致謝!

使用 benchmarks/iperf 的測試返回以下結果:

禁用 pf:

Client connecting to 109.193.XXX.XXX, TCP port 5001
TCP window size: 32.5 KByte (default)
------------------------------------------------------------
[  3] local 46.38.XXX.XXX port 31302 connected with 109.193.XXX.XXX port 5001
[ ID] Interval       Transfer     Bandwidth
[  3]  0.0-10.0 sec  15.1 MBytes  12.6 Mbits/sec

啟用 pf:

------------------------------------------------------------
Client connecting to 109.193.XXX.XXX, TCP port 5001
TCP window size: 32.5 KByte (default)
------------------------------------------------------------
[  3] local 46.38.XXX.XXX port 61377 connected with 109.193.XXX.XXX port 5001
[ ID] Interval       Transfer     Bandwidth
[  3]  0.0-18.1 sec   128 KBytes  58.1 Kbits/sec

這是我的 pf.conf:

### INTERFACES ###
if = "{ em0 }"

### SETTINGS ###
set block-policy drop

### PORTS ###
tcp_pass = "{ 25 80 465 993}"
udp_pass = "{ 25 80 465 993}"
icmp_types = "echoreq"

### NORMALISATION ###
scrub in all
antispoof for $if

### RULES ###
block all
pass in on $if proto tcp from any to any port $tcp_pass flags S/SA keep state
pass in on $if proto udp to any port $udp_pass keep state
pass out quick all keep state

# PING #
pass in on $if inet proto icmp all icmp-type $icmp_types keep state

# TRACEROUTE #
pass in on $if inet proto udp from any to any port 33433 >< 33626 keep state

這是 rc.conf: … pf_enable=“YES” pf_rules="/etc/pf.conf" pflog_enable=“YES” pflog_logfile="/var/log/pflog" …

9.0 分支似乎對涉及 TCP 分段解除安裝的奇怪配置特別敏感。這可以通過禁用 TSO 來“糾正”:

ifconfig em0 -tso

引用自:https://serverfault.com/questions/514046