使用tc實現基於linux的流量管理
【相关文章:在 linux 上架设 FreeBSD 】 【扩展阅读:FreeBSD光盘运行版的制作过程】2004-04-23 15:18 pm 【扩展信息:一个很简单但是最常用的SED例子:UNI】 作者:大楠木(kent@chinalinuxpub.com) 來自:linux知識寶庫 現載:http://www.douzhe.com/docs/linuxtips/ 地址:無名 參考文獻:tc weizhishu www.chinalinuxpub.com linux advanced routing & traffic control howto by bert hubert http://www.chinalinuxpub.com/vbbfor...&threadid=18601 請認真閱讀上面的文章,掌握好相應的概念。 red hat linux 7.3 內核 2.4.18 以上。 局域網的網路拓撲: 在伺服器的eth0 幫定了外部位址 eth0:192.168.1.3 eth1 幫定了內部位址 eth1:1 172.17.1.1 eth1:2 172.18.1.1 eth1:3 172.19.1.1 現在要實現的功能就是整個出口限制在512kbit(上傳流量) , 172.17網段的下載流量下載到512kbit ,172.18 網段限制在128kbit,172.19的網段限制到 3mbit。 方法如下: 首先幫定相應的位址:(不細述) 實現路由設定,使用iptables實現。 # iptables –a input -f # iptables -a output -f # iptables -a forward -f #echo 1 > /proc/sys/net/ipv4/ip_forward #允許轉發 # iptables -a input –j accept # iptables -a output -j accept # iptables -a forward -j accept # iptables -t nat -a postrouting -s 172.17.0.0/16 -j masquerade # iptables -t nat -a postrouting -s 172.18.0.0/16 -j masquerade # iptables -t nat -a postrouting -s 172.19.0.0/16 -j masquerade #進行ip位址偽裝,使得內部的主機的資料包能通過伺服器與外界聯繫。 進行流量管理 #tc qdisc add dev eth0 root tbf rate 512k lantency 50ms burst 1540 #在網卡eth0上使用tbf(tokenbucket filter)過濾佇列,將出口限制在512kbit,延遲50ms,突發資料1540,rate指定的數值就是限制的帶寬。 繼續在eth1做限制。 ... 下一页