免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
楼主: 100000
打印 上一主题 下一主题

pf如何限制每ip的最大连接数(已解决)。能否限制每ip的最大带宽? [复制链接]

论坛徽章:
2
丑牛
日期:2013-09-29 09:47:222015七夕节徽章
日期:2015-08-21 11:06:17
11 [报告]
发表于 2006-01-16 09:01 |只看该作者
那就限制每个ip的流量吧

论坛徽章:
0
12 [报告]
发表于 2006-01-16 09:45 |只看该作者
man pf.conf

里面有
STATEFUL TRACKING OPTIONS
     All three of keep state, modulate state and synproxy state support the
     following options:

     max _number_
           Limits the number of concurrent states the rule may create.  When
           this limit is reached, further packets matching the rule that would
           create state are dropped, until existing states time out.
     no-sync
           Prevent state changes for states created by this rule from appear-
           ing on the pfsync(4) interface.
     _timeout_ _seconds_
           Changes the timeout values used for states created by this rule.
           For a list of all valid timeout names, see OPTIONS above.

     Multiple options can be specified, separated by commas:

           pass in proto tcp from any to any \
                 port www flags S/SA keep state \
                 (max 100, source-track rule, max-src-nodes 75, \
                 max-src-states 3, tcp.established 60, tcp.closing 5)

     When the source-track keyword is specified, the number of states per
     source IP is tracked.

     source-track rule
           The maximum number of states created by this rule is limited by the
           rule's max-src-nodes and max-src-states options.  Only state en-
           tries created by this particular rule count toward the rule's lim-
           its.
     source-track global
           The number of states created by all rules that use this option is
           limited.  Each rule can specify different max-src-nodes and max-
           src-states options, however state entries created by any partici-
           pating rule count towards each individual rule's limits.

     The following limits can be set:

     max-src-nodes _number_
           Limits the maximum number of source addresses which can simultane-
           ously have state table entries.
     max-src-states _number_
           Limits the maximum number of simultaneous state entries that a sin-
           gle source address can create with this rule.

     For stateful TCP connections, limits on established connections (connec-
     tions which have completed the TCP 3-way handshake) can also be enforced
     per source IP.

     max-src-conn _number_
           Limits the maximum number of simultaneous TCP connections which
           have completed the 3-way handshake that a single host can make.
     max-src-conn-rate _number_ / _seconds_
           Limit the rate of new connections over a time interval.  The con-
           nection rate is an approximation calculated as a moving average.

     Because the 3-way handshake ensures that the source address is not being
     spoofed, more aggressive action can be taken based on these limits.  With
     the overload _table_ state option, source IP addresses which hit either
     of the limits on established connections will be added to the named
     table.  This table can be used in the ruleset to block further activity
     from the offending host, redirect it to a tarpit process, or restrict its
     bandwidth.

     The optional flush keyword kills all states created by the matching rule
     which originate from the host which exceeds these limits.  The global
     modifier to the flush command kills all states originating from the of-
     fending host, regardless of which rule created the state.

     For example, the following rules will protect the webserver against hosts
     making more than 100 connections in 10 seconds.  Any host which connects
     faster than this rate will have its address added to the <bad_hosts>
     table and have all states originating from it flushed.  Any new packets
     arriving from this host will be dropped unconditionally by the block
     rule.

           block quick from <bad_hosts>
           pass in on $ext_if proto tcp to $webserver port www flags S/SA keep state \
                   (max-src-conn-rate 100/10, overload <bad_hosts> flush global)


http://www.openbsd.org/cgi-bin/m ... 386&format=html

论坛徽章:
0
13 [报告]
发表于 2006-01-16 09:48 |只看该作者
3Q
看看e文怎么说的。

论坛徽章:
0
14 [报告]
发表于 2006-01-16 10:20 |只看该作者
看意思用这个选项?
(max 100, source-track rule, max-src-nodes 75,max-src-states 3, tcp.established 60, tcp.closing 5)
pass in on $int_if inet proto {tcp,udp} from <ip_www> to any keep state(source-track rule, max-src-nodes 100,max-src-states 10)

这样的话,是不是就是说:表ip_www里的每个ip最多同时拥有100个并发连接。并贴在同一时刻最多只能建立10个并发连接?
原文参数里的max 100是什么意思?是整个规则最多拥有的并发连接数么?

论坛徽章:
0
15 [报告]
发表于 2006-01-16 10:49 |只看该作者
原帖由 剑心通明 于 2006-1-16 09:01 发表
那就限制每个ip的流量吧


能限制每ip的流量?命令在那里?谢谢

论坛徽章:
0
16 [报告]
发表于 2006-01-16 11:16 |只看该作者
node是能有多少个ip可以用, max-src-state每一个ip 的并发连接数为多少, 你上面的意思是这条规则可以存100 个ip地址的state, 每一个ip的并发连接数最大为10

论坛徽章:
0
17 [报告]
发表于 2006-01-16 11:57 |只看该作者
原帖由 rainren 于 2006-1-16 11:16 发表
node是能有多少个ip可以用, max-src-state每一个ip 的并发连接数为多少, 你上面的意思是这条规则可以存100 个ip地址的state, 每一个ip的并发连接数最大为10


老大,太感谢了。

论坛徽章:
0
18 [报告]
发表于 2006-01-16 16:21 |只看该作者
那这句话的意思是不是就是:
(max 100, source-track rule, max-src-nodes 75,max-src-states 3, tcp.established 60, tcp.closing 5)

最多只能有100个连接(多的直接扔掉),每个ip最多有3个连接,同时最多允许75个ip连接。设置连接的ttl是60,结束的连接的ttl是5? (添加这两句增加性能,但会有丢包的危险?)

论坛徽章:
0
19 [报告]
发表于 2006-01-17 07:52 |只看该作者
清晨一顶,再问一下如何限制一个表中每一个ip的带宽。

论坛徽章:
0
20 [报告]
发表于 2006-01-17 09:09 |只看该作者
为每一个ip分一个队列, 好好看看faq, pf.conf, 学习自己学会找资料!
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP