使用tc来控制带宽

我有两个网卡。 eth0连接到Internet,eth1连接到LAN。

我想限制使用iptables和linux tc的下载限制。

所以我写了一个testing脚本来validation它是否工作。

我的iptablesconfiguration如下。

iptables -t mangle -N INBOUND iptables -t mangle -I PREROUTING -i eth0 -j INBOUND iptables -t mangle -A INBOUND -j MARK --set-mark 60 

我的入口configuration如下。

 tc qdisc add dev eth0 handle 1: ingress tc filter add dev eth0 parent 1: protocol ip prio 1 handle 60 fw police rate 100kbit burst 20kbit drop flowid :1 

你能告诉我我在这里错过了什么吗?

 NIC -> INGRESS -> NETFILTER -> EGRESS -> NIC (MARK) 

交通netfilter通过入口纪律后,在界面,以便您的标记不在乎。

使用'tc filter … u32'。

看一下Wonder Shaper:

http://lartc.org/wondershaper/

控制上传/下载速度是'tc'的一个奇妙的用途。