# QoS, Load Balancing and Policy Route (iproute2, traffic control and netlink socket) ###### tags: `linux` `QoS` `iproute2` `traffic control` `tc` `ip route` `policy route` `load balancing` Author: WhoAmI Date: 20220728 Copyright: CC BY-NC-SA ![](https://i.imgur.com/w98vYJF.png) :::success [財團法人台灣兒童暨家庭扶助基金會](https://https:www.ccf.org.tw/) ::: ![](https://i.imgur.com/GGOGLt3.jpg) 這些是運用 [netlink - communication between kernel and user space(AF_NETLINK)](https://man7.org/linux/man-pages/man7/netlink.7.html) netlink socket設計想法: 把 Linux user space 與 kernel space 看成 client/server 架構 例如 您可透過 AF_NETLINK 檢查 route 狀態, e.g., PPPoE :::info 這裡其實真正困難的是 決策問題與優先權的規劃, 使用者命令並不多! 困難的是: 由於 進入的使用者是隨機現象, Detection, Estimation, QoS decision, and Priority 的規劃! 例如 當有 QoS 需求時, 檢測最 "忙" 的 server 然後切換至其他 server 其實不一定是最好的選擇! 有時反而會更嚴重! 甚至不穩定! ::: 實務上請盡可能用 :::info ip route ...代替 route ip addr ... 代替 ifconfig QoS: tc (traffic control) ::: **運作原理基本概念~Queueing Networks** ![](https://i.imgur.com/WEXEpWt.jpg) ![](https://i.imgur.com/tigMG94.png) ![](https://i.imgur.com/KtDGZFy.jpg) ![](https://i.imgur.com/dhSPqay.jpg) ![](https://i.imgur.com/0NsWfBF.jpg) ![](https://i.imgur.com/eEqaReU.png) ![](https://i.imgur.com/WM64bPz.jpg) ![](https://i.imgur.com/bGUlNhK.jpg) ![](https://i.imgur.com/82ojIoE.jpg) [IPROUTE2 Utility Suite Howto](https://www.policyrouting.org/iproute2.doc.html) [Linux Advanced Routing Tutorial by Michal Ludvig on September 12, 2013 ](https:////www.linuxjournal.com/content/linux-advanced-routing-tutorial) **了解 Bridge! 其實這也很重要!** [Linux Bridge Linux BRIDGE-STP-HOWTO: About The Linux Modular Bridge And STP](https://www.tldp.org/HOWTO/BRIDGE-STP-HOWTO/set-up-the-bridge.html) iptables -A FORWARD -p tcp --syn -m limit --limit 1/s -j ACCEPT [Iptables Tutorial – Securing Ubuntu VPS with Linux Firewall](https://www.hostinger.com/tutorials/iptables-tutorial)