LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 679|回复: 2

iptables-tc的问题

[复制链接]
发表于 2010-4-12 19:59:15 | 显示全部楼层 |阅读模式
#cbq compile

find: warning: you have specified the -maxdepth option after a non-option argument (, but options are not positional (-maxdepth affects tests specified before it as well as those specified after it).  Please specify options before other arguments.

find: warning: you have specified the -maxdepth option after a non-option argument (, but options are not positional (-maxdepth affects tests specified before it as well as those specified after it).  Please specify options before other arguments.

/sbin/tc qdisc del dev eth0 root
/sbin/tc qdisc add dev eth0 root handle 1 cbq bandwidth 100Mbit avpkt 3000 cell 8
/sbin/tc class change dev eth0 root cbq weight 30Mbit allot 1514

/sbin/tc class add dev eth0 parent 1: classid 1:2 cbq bandwidth 100Mbit rate 1600Kbit weight 160Kbit prio 5 allot 1514 cell 8 maxburst 20 avpkt 3000 bounded
/sbin/tc qdisc add dev eth0 parent 1:2 handle 2 tbf rate 1600Kbit buffer 10Kb/8 limit 15Kb mtu 1500
/sbin/tc filter add dev eth0 parent 1:0 protocol ip prio 200 handle 10 fw classid 1:2
/sbin/tc filter add dev eth0 parent 1:0 protocol ip prio 100 u32 match ip src 192.168.100.100 match ip dst 192.168.100.80 classid 1:2

iptables -t mangle -A FORWORD -d 192.168.100.80/255.255.255.255 -o eth0 -j MARK --set-mark 0xa

问题:

1. 什么是-maxdepth? 如何解决这个错误消息呢?
2. 这个tc脚本对吗?我的本意是限制192.168.100.80的下载速度为200k。
 楼主| 发表于 2010-4-12 20:47:23 | 显示全部楼层
1.第一个错误解决了。是/sbin/cbq脚本中有一处find错误,修改为如下的样子就好了。

577 ### Get a list of configured classes
578 CLASSLIST=`find $1 -maxdepth 1 \( -type f -or -type l\ ) -name 'cbq-*' \
579 -not -name '*~' -printf "%f\n"| sort`
580 [ -z "$CLASSLIST" ] &&
581 cbq_failure "no configuration files found in $1!"
582
583 ### Gather all DEVICE fields from $1/cbq-*
584 DEVFIELDS=`find $1 -maxdepth 1 \( -type f -or -type l \) -name 'cbq-*' \
585 -not -name '*~'| xargs sed -n 's/#.*//;
586 s/[[:space:]]//g; /^DEVICE=[^,]*,[^,]*(,[^,]*)?/ \
587 { s/.*=//; p; }'| sort -u`


cbq脚本中find错误的原文件,请注意-maxdepth的位置:


### Get a list of configured classes
CLASSLIST=`find $1 \( -type f -or -type l \) -name 'cbq-*' \
-not -name '*~' -maxdepth 1 -printf "%f\n"| sort`
[ -z "$CLASSLIST" ] &&
cbq_failure "no configuration files found in $1!"

### Gather all DEVICE fields from $1/cbq-*
DEVFIELDS=`find $1 ( -type f -or -type l ) -name 'cbq-*' \
-not -name '*~' -maxdepth 1| xargs sed -n 's/#.*//; \
s/[[:space:]]//g; /^DEVICE=[^,]*,[^,]*\(,[^,]*\)\?/ \
{ s/.*=//; p; }'| sort -u`
回复 支持 反对

使用道具 举报

 楼主| 发表于 2010-4-13 15:09:09 | 显示全部楼层
流控在修改好cbq脚本后,顺利加载,并且检查了流控统计没有问题。

我的配置文件:

DEVICE=eth0,100Mbit,20Mbit
RATE=1600Kbit
WEIGHT=160Kbit
PRIO=5
RULE=,192.168.10.100

eth0是局域网借口,100M链接,我是按照20Mbit的速度进行划分的。因客户端数量为100,所以限制下载速度200k。rule规则的意思就是不管从哪里来,到192.168.10.100的流量受到限制。

cbq compile

cbq start 后,就有明显的效果了。

cbq stats 可以看具体的信息。

上传我还没有限制,但是道理大同小异。从网上查阅的资料发现,大家都在iptables中对prerouting的包打上了标记,之后进行限速,但是我现在没有打mark,也有限制,其中有什么原因吗?
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表