printerror 发表于 2012-10-28 16:02

PF限速不起作用

本帖最后由 ulovko 于 2012-10-28 16:14 编辑

大家好,第一次使用PF限制单ip网速,但是没有起到相应的作用
现在是把总网速限制在了1.5Mb(pc1_net+pc2_net总共1.5Mb),而我想要达到的效果是每个ip限制到1.5Mb(pc1_net,pc2_net分别1.5Mb),请问我哪里写错了,怎样更正,在这里先谢谢了

#       $OpenBSD: pf.conf,v 1.50 2011/04/28 00:19:42 mikeb Exp $
#
# See pf.conf(5) for syntax and examples.
# Remember to set net.inet.ip.forwarding=1 and/or net.inet6.ip6.forwarding=1
# in /etc/sysctl.conf if packets are to be forwarded between interfaces.

set skip on lo

# filter rules and anchor for ftp-proxy(8)
#anchor "ftp-proxy/*"
#pass in quick inet proto tcp to port ftp divert-to 127.0.0.1 port 8021

# anchor for relayd(8)
#anchor "relayd/*"

pass            # to establish keep-state

# rules for spamd(8)
#table <spamd-white> persist
#table <nospamd> persist file "/etc/mail/nospamd"
#pass in on egress proto tcp from any to any port smtp \
#    rdr-to 127.0.0.1 port spamd
#pass in on egress proto tcp from <nospamd> to any port smtp
#pass in log on egress proto tcp from <spamd-white> to any port smtp
#pass out log on egress proto tcp to any port smtp


#block in quick from urpf-failed to any # use with care

# By default, do not permit remote connections to X11
block in on ! lo0 proto tcp to port 6000:6010

altq on tun0 priq bandwidth 640Kb queue { std_out, tcp_ack_out }

queue std_out   priq(default)
queue tcp_ack_out priority 6

altq on msk0 cbq bandwidth 6Mb queue { std_in }
queue std_in bandwidth 1.5Mb cbq(default)

ext_if="tun0"
int_if="msk0"
local_net = "192.168.0.0/24"
pc1_net = "192.168.0.19"
pc2_net="192.168.0.21"

pass out on $ext_if inet proto {tcp,udp} from $int_if:network to $ext_if flags S/SA keep state(source-track rule, max-src-nodes 50,max-src-states 100)
pass out on $ext_if from $int_if:network to any nat-to ($ext_if) queue(std_out,tcp_ack_out)

pass out on $ext_if from any to $pc1_net keep state queue std_in
pass out on $ext_if from any to $pc2_net keep state queue std_in

macafee 发表于 2012-10-29 09:01

PF限速一直不好用,这个是PF最大的弱项,建议用IPFW+DUMMY NET来限速

printerror 发表于 2012-10-29 10:01

IPFW+DUMMY NET可以限制每个ip,然后可以限制连接数吗?
每个ip+连接数限制应该就可以限制住迅雷等下载工具了吧?可以让别人用下载工具,但是不能把带宽占完了

pf应该可以限每个ip,有方法就最好了,不然还得重装系统换FreeBSD

anthie 发表于 2012-10-29 11:55

本帖最后由 anthie 于 2012-10-29 12:38 编辑

回复 3# printerror

我记得有个国产软件,功能很强悍。据说可以限制p2p。
我用过dummynet。 一般限速很好用。但是对付p2p还是不太好用。

printerror 发表于 2012-10-29 12:42

单ip限速+p2p限制连接数就可以了吧

anthie 发表于 2012-10-29 13:03

回复 5# printerror

限制连接数真的好用吗?开个p2p然后qq不能用了?
我说,你这是歪门邪道。还是用特定软件吧,可以探测常用的p2p。

printerror 发表于 2012-10-29 13:30

连接数是针对每个ip的,他用迅雷把连接数设定的无限大,他打不开网页,登不上qq,他活该,本来就不允许用迅雷

特定的p2p限速软件是什么?在BSD上可用的,未搜索到。

lsstarboy 发表于 2012-10-29 13:59

连接数不是dummynet的事,是ipfw或pf的事,流量整形才是dummynet。
上面提到的限p2p的东西应该是panabit,据说非常棒。

wosl2001 发表于 2012-10-29 15:22

本帖最后由 wosl2001 于 2012-10-29 15:32 编辑


pass out on $ext_if from any to $pc1_net keep state queue std_in
pass out on $ext_if from any to $pc2_net keep state queue std_in

改成

pass in on $int_if from $pc1_net to any keep state queue std_in
pass in on $int_if from $pc2_net to any keep state queue std_in

试试看

printerror 发表于 2012-10-29 19:32

不行,仍然是总带宽为1.5Mb
页: [1] 2 3
查看完整版本: PF限速不起作用