このページの2つのバージョン間の差分を表示します。
両方とも前のリビジョン前のリビジョン次のリビジョン | 前のリビジョン | ||
01_linux:01_net:tcで帯域制限2 [2016/08/30 06:25] – matsui | 01_linux:01_net:tcで帯域制限2 [2019/09/19 23:38] (現在) – matsui | ||
---|---|---|---|
行 1: | 行 1: | ||
+ | ====== tcで帯域制限(htb) ====== | ||
+ | class構造の制限を用意して、条件を設定し帯域制限する事ができるclassful qdiscにHTB | ||
+ | |||
+ | |||
+ | ===== インバウンド ===== | ||
+ | |||
+ | この部分で、仮想インターフェース(tlhdj20bhophy4)のtransfer(VMから見るとインバウンド)に制限がかかります。 | ||
+ | < | ||
+ | # tc qdisc add dev tlhdj20bhophy4 root tbf rate 50mbit latency 50ms burst 1mb mtu 33000 | ||
+ | </ | ||
+ | |||
+ | ===== アウトバウンド ===== | ||
+ | |||
+ | この部分で、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 | ||
+ | |||
+ | |||
+ | ===== 削除 ===== | ||
+ | < | ||
+ | # tc qdisc del dev tlhdj20bhophy4 root | ||
+ | </ | ||
+ | |||
+ | ==== 1. CLASS ==== | ||
+ | |||
+ | bond1のhtb class 1: | ||
+ | < | ||
+ | # 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 | ||
+ | | ||
+ | | ||
+ | </ | ||
+ | |||
+ | ==== 2. FILTER ==== | ||
+ | |||
+ | bond1のフィルターにfwmark 0x5 のトラフィックをcalss 1: | ||
+ | < | ||
+ | # 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 | ||
+ | </ | ||
+ | |||
+ | [[https:// | ||
+ | |||
+ | ==== 3. IPTABLES ==== | ||
+ | |||
+ | 該当のインターフェース(tlhdj20bhophy4)からのパケットに対して0x5のマークを点ける | ||
+ | |||
+ | < | ||
+ | # iptables -L FORWARD -nv -t mangle | ||
+ | iptables -A FORWARD -t mangle -m physdev --physdev-in ' | ||
+ | |||
+ | Chain FORWARD (policy ACCEPT 7790K packets, 4496M bytes) | ||
+ | pkts bytes target | ||
+ | 694K 1035M MARK | ||
+ | 0 0 MARK | ||
+ | |||
+ | </ | ||
+ | |||
+ | [[http:// | ||
+ | [[http:// | ||
+ | |||
+ | {{tag> |