ユーザ用ツール

サイト用ツール


01_linux:01_net:tcで帯域制限2

差分

このページの2つのバージョン間の差分を表示します。

この比較画面へのリンク

次のリビジョン
前のリビジョン
01_linux:01_net:tcで帯域制限2 [2016/08/30 06:24] – 作成 matsui01_linux:01_net:tcで帯域制限2 [2019/09/19 23:38] (現在) matsui
行 1: 行 1:
 +====== tcで帯域制限(htb) ======
  
 +class構造の制限を用意して、条件を設定し帯域制限する事ができるclassful qdiscにHTB
 +
 +
 +===== インバウンド =====
 +
 +この部分で、仮想インターフェース(tlhdj20bhophy4)のtransfer(VMから見るとインバウンド)に制限がかかります。
 +<code>
 +# tc qdisc add dev tlhdj20bhophy4 root tbf rate 50mbit latency 50ms burst 1mb mtu 33000
 +</code>
 +
 +===== アウトバウンド =====
 +
 +この部分で、bond1からアウトバウンドに制限をかけている。
 +  Running: tc qdisc  add dev bond1 root handle 1 htb
 +  Running: tc class  add dev bond1 parent 1: classid 1:5 htb rate 50Mbit ceil 50Mbit mtu 33000
 +  Running: tc filter add dev bond1 protocol ip parent 1:0 prio 1 handle 5 fw flowid 1:5
 +
 +
 +===== 削除 =====
 +<code>
 +# tc qdisc del dev tlhdj20bhophy4 root
 +</code>
 +
 +==== 1. CLASS ====
 +
 +bond1のhtb class 1:5に制限を用意
 +<code>
 +# tc -s class show dev bond1
 +class htb 1:5 root prio 0 rate 5000Kbit ceil 5000Kbit burst 33625b cburst 33625b 
 + Sent 112955642 bytes 77814 pkt (dropped 615983, overlimits 0 requeues 0) 
 + rate 32bit 0pps backlog 0b 0p requeues 0 
 + lended: 78024 borrowed: 0 giants: 0
 + tokens: 53800 ctokens: 53800
 +</code>
 +
 +==== 2. FILTER ====
 +
 +bond1のフィルターにfwmark 0x5 のトラフィックをcalss 1:5に飛ばす
 +<code>
 +# tc -s filter show dev bond1
 +filter parent 1: protocol ip pref 1 fw 
 +filter parent 1: protocol ip pref 1 fw handle 0x5 classid 1:5
 +</code>
 +
 +[[https://linuxjf.osdn.jp/JFdocs/Adv-Routing-HOWTO/lartc.qdisc.filters.html|フィルタについて]]
 +
 +==== 3. IPTABLES ====
 +
 +該当のインターフェース(tlhdj20bhophy4)からのパケットに対して0x5のマークを点ける
 +
 +<code>
 +# iptables -L FORWARD -nv -t mangle
 +iptables -A FORWARD -t mangle -m physdev --physdev-in 'tlhdj20bhophy4' -j MARK --set-mark 5
 +
 +Chain FORWARD (policy ACCEPT 7790K packets, 4496M bytes)
 + pkts bytes target     prot opt in     out     source               destination         
 + 694K 1035M MARK       all  --  *      *       0.0.0.0/           0.0.0.0/          PHYSDEV match --physdev-in tlhdj20bhophy4 MARK set 0x5 
 +    0     0 MARK       all  --  *      *       0.0.0.0/           0.0.0.0/          PHYSDEV match --physdev-in c29k8sh2hyvosi MARK set 0x5 
 +
 +</code>
 +
 +[[http://labs.gree.jp/blog/2014/10/11288/|参考サイト]]
 +[[http://labs.gree.jp/blog/2014/10/11266/|参考サイト]]
 +
 +{{tag>network}}