🧭 1. What is CARP? CARP (Common Address Redundancy Protocol) allows multiple firewalls to share a virtual IP address so that if one device fails, another automatically takes over.This ensures continuous network availability and seamless failover. In OPNsense, a typical HA setup includes: When the master stops responding, the backup promotes itself to master and…
Category: OPNsense
About OPNsense
OPNsense 高可用架構:CARP 原理與設定說明
🧭 一、什麼是 CARP? CARP(Common Address Redundancy Protocol) 是一種用來建立防火牆高可用 (High Availability, HA) 的協定。它允許多台防火牆共用一個虛擬 IP (Virtual IP),並在主機發生故障時自動切換,確保外部網路連線不中斷。 OPNsense 中可利用 CARP 將兩台或多台設備組成 HA 群組: 當主機停止運作或失去心跳(Heartbeat)時,備援主機會自動接管虛擬 IP 地址與所有連線。 ⚙️ 二、運作原理 🔹 1️⃣ 虛擬 IP (Virtual IP) CARP 使用虛擬 IP 作為服務對外提供的位址,例如: 外部網路僅知道 203.66.10.10,不論哪台防火牆在運作,連線都會透過這個虛擬 IP 進入。 🔹 2️⃣ VHID 與 AdvSkew 機制 🔹 3️⃣ 心跳訊號 (pfsync + CARP) CARP 會使用 Layer…
OPNsense Firewall Normalization — Principle & Configuration Guide
🧭 1. What is Packet Normalization? In OPNsense, Firewall Normalization (or “scrubbing”) is a low-level packet filtering featureimplemented by the pf firewall engine, which cleans, verifies, and adjusts packets before they are processed by rules. Its main purposes are: You can find it under: ⚙️ 2. How It Works When a packet passes through the…
OPNsense 防火牆封包正規化(Firewall Normalization)原理與應用
🧭 一、什麼是封包正規化 (Packet Normalization)? 在 OPNsense 中,Normalization(封包正規化) 是一項低層級的防火牆安全機制,透過 pf(packet filter)防火牆內建的 scrub 功能,在封包進入或離開防火牆時,強制進行格式檢查與結構修正,確保所有 TCP/IP 封包都符合標準協定格式。 主要目的: 這個功能位於: ⚙️ 二、運作原理 封包通過防火牆時,pf 會先執行「scrub」動作,對封包進行結構檢查、重組與正規化,確保後續規則匹配與流量分析的可靠性。 🔧 常見 scrub 動作: 動作 功能說明 reassemble tcp 將 TCP 分段封包重新組合,防止利用分段繞過偵測。 random-id 隨機化 IP 封包 ID,防止外部主機透過 IP ID 進行流量分析。 min-ttl 64 強制封包 TTL 不低於指定值,避免因過低 TTL 被中途丟棄。 max-mss 1460 限制 TCP 最大封包段長度,避免過大封包造成傳輸錯誤。 no-df 移除「Don’t Fragment」標記,允許防火牆重新分段。 🧩…
Example: Weighted Bandwidth Shaping
📘 1. Objective We have three major outbound traffic types: Application Direction Max Bandwidth Priority Web (HTTP/HTTPS) Download 2 Mbps Medium FTP Download 1 Mbps Low VoIP (SIP + RTP) Download 2 Mbps High Goal: ⚙️ 2. Configuration Steps Step 1️⃣ Create Pipes Navigate to: Name Bandwidth Description pipe_web 2 Mbps Web browsing and downloads…
OPNsense Traffic Shaping 實際設定範例
📘 一、範例目標 假設企業內部共有三類主要應用: 應用 流量方向 頻寬上限 優先權 Web 流量 (HTTP/HTTPS) Download 2 Mbps 中 FTP 檔案傳輸 Download 1 Mbps 低 VoIP 語音通話 Download 2 Mbps 高 希望達到以下效果: ⚙️ 二、設定步驟 Step 1️⃣ 建立 Pipes 進入: 建立三條下載管道: 名稱 頻寬 說明 pipe_web 2 Mbps 限制一般 HTTP/HTTPS 下載 pipe_ftp 1 Mbps 限制 FTP 傳輸頻寬 pipe_voip 2 Mbps 限制 VoIP…
Introduction to Traffic Shaping in OPNsense
🧭 1. What is Traffic Shaping? Traffic shaping is the control of network traffic to optimize or ensure performance, reduce latency, and increase usable bandwidth by applying additional delay or restrictions to packet flows. In OPNsense, traffic shaping is implemented via pipes, queues, and rules. The rules manage flows and assign them to pipes/queues based…
OPNsense中的頻寬管理簡介
🧭 一、什麼是 Traffic Shaping? Traffic Shaping(流量整形,也稱為封包整形/packet shaping)是一種網路流量控制技術,藉由對特定封包集合(流/flow)施加延遲或控制,使其符合預定的頻寬、優先順序或延遲要求。 在 OPNsense 中,Traffic Shaper 提供「管道 (Pipes)」「佇列 (Queues)」「規則 (Rules)」三個構件來實現,並可設定來源/目的 IP、介面、方向 (進/出)、通訊埠等條件。 ⚙️ 二、構成元件與原理 運作流程:使用者/裝置封包依來源、目的、介面、埠號等條件匹配到一條「Shaper Rule」,該規則將封包導向某條 Pipe,再透過該 Pipe 下的 Queue 依權重分配頻寬。若該流量達到管道上限,則多餘封包會被排隊或延遲。 🧩 三、主要應用場景 🧰 四、如何在 OPNsense 中設定 Step 1:建立 Pipes 前往:Firewall → Traffic Shaper → Pipes新增下載/上傳管道,設定頻寬、描述等。 Step 2:建立 Queues(如需權重) 前往:Firewall → Traffic Shaper → Queues選擇所屬 Pipe,設定權重 (weight)、遮罩 (mask)(如以來源或目的 IP 平分頻寬)等。…
Double NAT Issue with OPNsense (Resolved by Direct PPPoE Connection)
🧭 1. Background During internal testing, my setup was: Node IP / Role Test Host 192.168.100.250 (GW: 192.168.100.253) OPNsense LAN 192.168.100.253 OPNsense WAN 172.16.100.253 (GW: 172.16.100.251) UserGW LAN 172.16.100.251 UserGW WAN PPPoE (Internet) The test host attempted to SSH to an external server.The external server received connection attempts (logged in iptables),but the SSH client always…
OPNsense 雙層 NAT 造成連線失敗問題與解決過程
🧭 一、問題背景 在內部測試 OPNsense 時,我建立了如下的測試環境: 節點 IP / 功能 測試主機 192.168.100.250(GW: 192.168.100.253) OPNsense LAN 192.168.100.253 OPNsense WAN 172.16.100.253(GW: 172.16.100.251) UserGW LAN 172.16.100.251 UserGW WAN PPPoE 外網連線 測試主機透過 OPNsense → UserGW → 外網連線至外部 SSH Server。結果外部主機收到封包(可在 iptables log 中看到),但測試主機端 SSH 連線卻一直顯示 “Connection timed out”。 🧩 二、問題分析 從外部伺服器的日誌可看到封包來源為: 這代表: 也就是典型的「雙層 NAT」架構。雖然封包能送出,但回程封包無法正確對應回 OPNsense 的狀態表。 🔍 結果: ⚙️ 三、排查過程 1️⃣…