EdgeMAX - EdgeRouter中QOS Advanced-Queue CLI 配置

簡介


EdgeRouter 固件 1.8.0 以上版本支援 Advanced-Queue 功能
開啟 Advanced-Queue 會影響 offload 效能

工具


EdgeRouter

網路拓撲說明


eth1 : WAN - ISP 提供的靜態 IP 地址/閘道器/ DNS(帶寬上傳 5M /下載 15M)
eth0 : LAN - 192.168.1.0/24

操作步驟


  1. 限制整個 LAN 的上傳和下載速度

    1. 在 global 建立一個root queue 1

    set traffic-control advanced-queue root queue 1 attach-to global
    set traffic-control advanced-queue root queue 1 bandwidth 20mbit

    1. 分別建立 branch 100 上傳和 200 下載

    set traffic-control advanced-queue branch queue 100 bandwidth 5mbit
    set traffic-control advanced-queue branch queue 100 description Upload
    set traffic-control advanced-queue branch queue 100 parent 1
    set traffic-control advanced-queue branch queue 200 bandwidth 15mbit
    set traffic-control advanced-queue branch queue 200 description Download
    set traffic-control advanced-queue branch queue 200 parent 1

    1. 在 root queue 1 中建立 filter 分別來應用 branch 100 和 200 配置

    set traffic-control advanced-queue filters match 100 attach-to 1
    set traffic-control advanced-queue filters match 100 description ‘WAN upload’
    set traffic-control advanced-queue filters match 100 ip source address 192.168.1.0/24
    set traffic-control advanced-queue filters match 100 target 100
    set traffic-control advanced-queue filters match 200 attach-to 1
    set traffic-control advanced-queue filters match 200 description ‘WAN download’
    set traffic-control advanced-queue filters match 200 ip destination address 192.168.1.0/24
    set traffic-control advanced-queue filters match 200 target 200

    1. 建立 FQ_CODEL queue 用於後續 leaf queues 使用

    set traffic-control advanced-queue queue-type fq-codel FQCODEL_DOWN
    set traffic-control advanced-queue queue-type fq-codel FQCODEL_UP

    1. 分別建立 leaf queue 199 用於默認上傳限速和 leaf queue 299 用於默認下載限速,並配置 queue 方式為 FQ_CODEL

    set traffic-control advanced-queue leaf queue 199 bandwidth 5mbit
    set traffic-control advanced-queue leaf queue 199 description default
    set traffic-control advanced-queue leaf queue 199 parent 100
    set traffic-control advanced-queue leaf queue 199 queue-type FQCODEL_UP
    set traffic-control advanced-queue leaf queue 299 bandwidth 15mbit
    set traffic-control advanced-queue leaf queue 299 description default
    set traffic-control advanced-queue leaf queue 299 parent 200
    set traffic-control advanced-queue leaf queue 299 queue-type FQCODEL_DOWN

    1. 在 branch100 中建立 filter 來應用 leaf 199,在 branch 200 中建立 filter 來應用 leaf 299 配置

    set traffic-control advanced-queue filters match 199 attach-to 100
    set traffic-control advanced-queue filters match 199 description Default
    set traffic-control advanced-queue filters match 199 target 199
    set traffic-control advanced-queue filters match 299 attach-to 200
    set traffic-control advanced-queue filters match 299 description Default
    set traffic-control advanced-queue filters match 299 target 299

  2. 限制單個 IP 和文件傳輸應用上傳速度

    1. 建立 leaf queue 201和filter 用於配置IP地址為192.168.1.11的下載速度限制為4M

    set traffic-control advanced-queue leaf queue 201 bandwidth 4mbit
    set traffic-control advanced-queue leaf queue 201 description 192.168.1.11
    set traffic-control advanced-queue leaf queue 201 parent 200
    set traffic-control advanced-queue filters match 201 attach-to 200
    set traffic-control advanced-queue filters match 201 description ‘limit 192.168.1.11’
    set traffic-control advanced-queue filters match 201 ip destination address 192.168.1.11/32
    set traffic-control advanced-queue filters match 201 target 201

    1. 建立 leaf queue 101和filter 用於配置文件傳輸的應用上傳速度限制為2M

    set traffic-control advanced-queue leaf queue 101 bandwidth 2mbit
    set traffic-control advanced-queue leaf queue 101 description file-transfer
    set traffic-control advanced-queue leaf queue 101 parent 100
    set traffic-control advanced-queue filters match 101 application category File-Transfer
    set traffic-control advanced-queue filters match 101 attach-to 100
    set traffic-control advanced-queue filters match 101 description ‘limit file-transfer’
    set traffic-control advanced-queue filters match 101 target 101

    1. 移除 FQ_CODEL queue,而採用 HFQ queue 來配置 LAN 中每個 IP 的下載速度和上傳速度(下載速度 8Mbps,上傳速度 3Mbps)

    set traffic-control advanced-queue queue-type hfq HFQ_DOWN host-identifier dip
    set traffic-control advanced-queue queue-type hfq HFQ_DOWN max-rate 8mbit
    set traffic-control advanced-queue queue-type hfq HFQ_DOWN subnet 192.168.1.0/24
    set traffic-control advanced-queue leaf queue 299 queue-type HFQ_DOWN
    set traffic-control advanced-queue queue-type hfq HFQ_UP host-identifier sip
    set traffic-control advanced-queue queue-type hfq HFQ_UP max-rate 3mbit
    set traffic-control advanced-queue queue-type hfq HFQ_UP subnet 192.168.1.0/24
    set traffic-control advanced-queue leaf queue 199 queue-type HFQ_UP

備註


  1. 配置某個網段每個 IP 統一限速,只需配置步驟 1 中 (1)-(6) 和步驟 3,HFQ 最多支援 /22 子網掩碼。
  2. 配置 Advanced-Queue 後需要一定時間才能生效,取決於路由器配置文件大小所以生效時間快則幾秒慢則幾分鐘。
  3. leaf queue 的默認 queue 方式為 PFIFO
  4. 附件為ER-X-SFP均衡限速192.168.1.0/24的HFQ QOS配置,使用ER-X-SFP的用戶可在下載後按需求更改 WAN 連接方式和限速配置(EdgeRouter 默認帳號 ubnt/ubnt)