免费注册 查看新帖 |

Chinaunix

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

[网络管理] [原创]用tc+iptables+HTB解决ADSL宽带速度瓶颈技术 [复制链接]

论坛徽章:
0
21 [报告]
发表于 2006-03-03 11:47 |只看该作者
原帖由 枫影谁用了 于 2006-3-3 11:27 发表


flashget开几十个线程下载

這個在iptables就完全可以解決的。不用tc


这个好像是需要connlimit和random模块吧?我刚好没编译这两个,想知道,如果不通过iptables,在现有基础上,就没有别的办法吗?

论坛徽章:
1
白银圣斗士
日期:2015-11-23 08:33:04
22 [报告]
发表于 2006-03-03 13:42 |只看该作者
原帖由 thatday 于 2006-3-3 11:47 发表


这个好像是需要connlimit和random模块吧?我刚好没编译这两个,想知道,如果不通过iptables,在现有基础上,就没有别的办法吗?


為何要編譯這兩個模塊?現有的iptables裡沒有嗎?
man iptables

connlimit
       Allows you to restrict the number of parallel TCP connections to a server per client IP address (or address block).

       [!] --connlimit-above n
              match if the number of existing tcp connections is (not) above n

       --connlimit-mask bits
              group hosts using mask

       Examples:

       # allow 2 telnet connections per client host
              iptables -p tcp --syn --dport 23 -m connlimit --connlimit-above 2 -j REJECT

       # you can also match the other way around:
              iptables -p tcp --syn --dport 23 -m connlimit ! --connlimit-above 2 -j ACCEPT

       # limit the nr of parallel http requests to 16 per class C sized network (24 bit netmask)
              iptables -p tcp --syn --dport 80 -m connlimit --connlimit-above 16 --connlimit-mask 24 -j REJECT

   connmark
       This module matches the netfilter mark field associated with a connection (which can be set using the CONNMARK target below).

       --mark value[/mask]
              Matches packets in connections with the given mark value (if a mask is specified, this  is  logically  ANDed  with  the  mark
              before the comparison).


THIS MODULE IS DEPRECATED AND HAS BEEN REPLACED BY 瞁hashlimit瞁

       --dstlimit avg
              Maximum average match rate (packets per second unless followed by /sec /minute /hour /day postfixes).

       --dstlimit-mode mode
              The limiting hashmode.  Is the specified limit per dstip, dstip-dstport tuple, srcip-dstip tuple, or  per  srcipdstip-dstport
              tuple.

       --dstlimit-name name
              Name for /proc/net/ipt_dstlimit/* file entry

       [--dstlimit-burst burst]
              Number of packets to match in a burst.  Default: 5

       [--dstlimit-htable-size size]
              Number of buckets in the hashtable

       [--dstlimit-htable-max max]
              Maximum number of entries in the hashtable

       [--dstlimit-htable-gcinterval interval]
              Interval between garbage collection runs of the hashtable (in miliseconds).  Default is 1000 (1 second).

       [--dstlimit-htable-expire time
              After which time are idle entries expired from hashtable (in miliseconds)?  Default is 10000 (10 seconds).

   ecn
       This  allows  you to match the ECN bits of the IPv4 and TCP header.  ECN is the Explicit Congestion Notification mechanism as speci-
       fied in RFC3168

       --ecn-tcp-cwr
              This matches if the TCP ECN CWR (Congestion Window Received) bit is set.

       --ecn-tcp-ece
              This matches if the TCP ECN ECE (ECN Echo) bit is set.




--limit rate
              Maximum  average  matching rate: specified as a number, with an optional ?second? ?minute? ?hour? or ?day?suffix; the
              default is 3/hour.

       --limit-burst number
              Maximum initial number of packets to match: this number gets recharged by one every time the limit  specified  above  is  not
              reached, up to this number; the default is 5.

   mac
       --mac-source [!] address
              Match source MAC address.  It must be of the form XX:XX:XX:XX:XX:XX.  Note that this only makes sense for packets coming from
              an Ethernet device and entering the PREROUTING, FORWARD or INPUT chains.

   mark
       This module matches the netfilter mark field associated with a packet (which can be set using the MARK target below).

       --mark value[/mask]
              Matches packets with the given unsigned mark value (if a mask is specified, this is logically ANDed with the mask before  the
              comparison).

   mport
       This module matches a set of source or destination ports.  Up to 15 ports can be specified.  It can only be used in conjunction with
       -p tcp or -p udp.

       --source-ports port[,port[,port...]]
              Match if the source port is one of the given ports.  The flag --sports is a convenient alias for this option.

       --destination-ports port[,port[,port...]]
              Match if the destination port is one of the given ports.  The flag --dports is a convenient alias for this option.

       --ports port[,port[,port...]]
              Match if the both the source and destination ports are equal to each other and to one of the given ports.

[ 本帖最后由 枫影谁用了 于 2006-3-3 13:46 编辑 ]

论坛徽章:
0
23 [报告]
发表于 2006-03-03 13:58 |只看该作者
原帖由 枫影谁用了 于 2006-3-3 13:42 发表


為何要編譯這兩個模塊?現有的iptables裡沒有嗎?
man iptables

--limit rate
              Maximum  average  matching rate: specified as a number, with an optional ?second? ?mi ...

用户态的程序有,并不代表内核态的程序存在
iptables 只是一个用户态的程序,他实际上是给内核态的 netfilter 传送数据,真正运作的是内核态的东西

man iptables
这只能证明有那个 man 文件

iptables -m connlimit -h
这只能证明存在 libipt_connlimit.so

只有真正去执行的时候,才能证明 libipt_connlimit.so 和 ipt_connlimit.o 同时存在,且运转正常

论坛徽章:
1
白银圣斗士
日期:2015-11-23 08:33:04
24 [报告]
发表于 2006-03-03 14:00 |只看该作者
原帖由 platinum 于 2006-3-3 13:58 发表

用户态的程序有,并不代表内核态的程序存在
iptables 只是一个用户态的程序,他实际上是给内核态的 netfilter 传送数据,真正运作的是内核态的东西

man iptables
这只能证明有那个 man 文件

iptables - ...


明白。
是的啊!!!!!因為我執行過,所以我才說。

前幾天他自己和我說他也在編譯2.6.15的內核,難道他編譯沒成功??

论坛徽章:
0
25 [报告]
发表于 2006-03-06 11:46 |只看该作者
我没说我在编译2.6.15的内核,我听你说编译了很不错,我才说那我有空也试试,然后后来在虚拟机上装了FC4,顺便yum了一下,升级了内核,但不是自己编译。
另外,我的服务器系统是centos4.1,当时的确是没编译这几个模块,所以man出来也没用,实际上没有编译的。还有,如果编译了,我也会用,呵呵:)

论坛徽章:
0
26 [报告]
发表于 2006-03-06 11:59 |只看该作者
太好了,TC太强了

论坛徽章:
1
白银圣斗士
日期:2015-11-23 08:33:04
27 [报告]
发表于 2006-03-06 12:21 |只看该作者
原帖由 thatday 于 2006-3-6 11:46 发表
我没说我在编译2.6.15的内核,我听你说编译了很不错,我才说那我有空也试试,然后后来在虚拟机上装了FC4,顺便yum了一下,升级了内核,但不是自己编译。
另外,我的服务器系统是centos4.1,当时的确是没编译这几 ...


哦。你沒有編譯阿!!

那趕緊嘗鮮

论坛徽章:
0
28 [报告]
发表于 2006-03-14 16:28 |只看该作者
原帖由 枫影谁用了 于 2006-3-6 12:21 发表


哦。你沒有編譯阿!!

那趕緊嘗鮮


有空再试,小公司呆着,什么东西可做可不做,再这么下去人都要变懒惰了,最近再潜心研习java,准备跳槽..

论坛徽章:
0
29 [报告]
发表于 2006-03-14 19:12 |只看该作者
好像只能限制下载带宽吧
每个用户上传带宽没法控制

论坛徽章:
0
30 [报告]
发表于 2006-04-17 11:44 |只看该作者
KindGeorge 兄,iptables -t mangle -A PREROUTING -i $DEV -j MARK --set-mark 6 ,这句中为何是-i $DEV,而不是-o $DEV呢? --set-mark 6是为了控制上传的,似乎应该是-o $DEV(从PPP0出去的包)。
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

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

清除 Cookies - ChinaUnix - Archiver - WAP - TOP