Skip to content

Nuface Blog

隨意隨手記 Casual Notes

Menu
  • Home
  • About
  • Services
  • Blog
  • Contact
  • Privacy Policy
  • Login
Menu

OPNsense Traffic Shaping 實際設定範例

Posted on 2025-11-122025-11-12 by Rico

📘 一、範例目標

假設企業內部共有三類主要應用:

應用流量方向頻寬上限優先權
Web 流量 (HTTP/HTTPS)Download2 Mbps中
FTP 檔案傳輸Download1 Mbps低
VoIP 語音通話Download2 Mbps高

希望達到以下效果:

  1. 所有流量共用相同的出口介面。
  2. 總頻寬限制為 5 Mbps。
  3. VoIP 流量擁有最高優先權,其次為 Web,再其次為 FTP。

⚙️ 二、設定步驟

Step 1️⃣ 建立 Pipes

進入:

Firewall → Traffic Shaper → Pipes

建立三條下載管道:

名稱頻寬說明
pipe_web2 Mbps限制一般 HTTP/HTTPS 下載
pipe_ftp1 Mbps限制 FTP 傳輸頻寬
pipe_voip2 Mbps限制 VoIP 通話頻寬

⚠️ 若上傳也需限制,請再建立對應的上傳 pipe。


Step 2️⃣ 建立 Queues(權重設定)

進入:

Firewall → Traffic Shaper → Queues

建立三條佇列並綁定到各自的 pipe:

名稱所屬 Pipe權重 (Weight)說明
q_voippipe_voip100VoIP 最高優先
q_webpipe_web50一般 Web 流量
q_ftppipe_ftp10最低優先

權重可依需求微調,例如 VoIP: 100, Web: 60, FTP: 20。


Step 3️⃣ 建立 Rules(匹配條件)

進入:

Firewall → Traffic Shaper → Rules

建立三條規則:

名稱InterfaceDirectionProtocolPort / MatchQueue說明
rule_voipWANoutUDP5060, 10000-20000q_voipVoIP 通話
rule_webWANoutTCP80, 443q_webHTTP / HTTPS
rule_ftpWANoutTCP21q_ftpFTP 傳輸

✅ 若要同時控制上行與下行,可複製一份對應方向的規則。


Step 4️⃣ 套用設定並觀察

按下「Apply」,然後到:

Firewall → Traffic Shaper → Status

即可看到各 Pipe 與 Queue 的實際使用率。
當總頻寬達上限時:

  • VoIP 將保持穩定且低延遲;
  • Web 流量仍可正常存取;
  • FTP 流量會自動被延遲或排隊。

📊 實際運作結果

流量類型實際可用頻寬優先級表現延遲情況
VoIP約 2 Mbps最高最低延遲
Web約 2 Mbps中等中度延遲
FTP約 1 Mbps最低可能延遲或等待佇列

這樣的設計能在公司出口頻寬有限的情況下,
確保關鍵應用(VoIP)優先獲得穩定頻寬,
同時維持一般上網與檔案傳輸的公平性。

Recent Posts

  • Postfix + Let’s Encrypt + BIND9 + DANE Fully Automated TLSA Update Guide
  • Postfix + Let’s Encrypt + BIND9 + DANE TLSA 指紋自動更新完整教學
  • Deploying DANE in Postfix
  • 如何在 Postfix 中部署 DANE
  • DANE: DNSSEC-Based TLS Protection

Recent Comments

  1. Building a Complete Enterprise-Grade Mail System (Overview) - Nuface Blog on High Availability Architecture, Failover, GeoDNS, Monitoring, and Email Abuse Automation (SOAR)
  2. Building a Complete Enterprise-Grade Mail System (Overview) - Nuface Blog on MariaDB + PostfixAdmin: The Core of Virtual Domain & Mailbox Management
  3. Building a Complete Enterprise-Grade Mail System (Overview) - Nuface Blog on Daily Operations, Monitoring, and Performance Tuning for an Enterprise Mail System
  4. Building a Complete Enterprise-Grade Mail System (Overview) - Nuface Blog on Final Chapter: Complete Troubleshooting Guide & Frequently Asked Questions (FAQ)
  5. Building a Complete Enterprise-Grade Mail System (Overview) - Nuface Blog on Network Architecture, DNS Configuration, TLS Design, and Postfix/Dovecot SNI Explained

Archives

  • December 2025
  • November 2025
  • October 2025

Categories

  • AI
  • Apache
  • Cybersecurity
  • Database
  • DNS
  • Docker
  • Fail2Ban
  • FileSystem
  • Firewall
  • Linux
  • LLM
  • Mail
  • N8N
  • OpenLdap
  • OPNsense
  • PHP
  • QoS
  • Samba
  • Switch
  • Virtualization
  • VPN
  • WordPress
© 2025 Nuface Blog | Powered by Superbs Personal Blog theme