在開發郵件系統或部署郵件伺服器(如 Postfix、Dovecot)時,常常需要快速驗證 SMTP 主機是否可用、帳號密碼是否正確。本文提供兩種實用方式,使用 PHP 7.4 即可輕鬆測試郵件寄送與認證。 ✅ 方法一:使用 PHPMailer(推薦) 這是最直覺、最穩定的做法。PHPMailer 支援 STARTTLS / SMTPS / AUTH LOGIN,並能顯示詳細的 SMTP 除錯訊息。 安裝 若可使用 Composer: 範例程式:smtp_test.php 若無法使用 Composer,可直接下載 PHPMailer 的三個核心檔案:PHPMailer.php, SMTP.php, Exception.php,並在程式中手動引用。 ✅ 方法二:純 PHP Socket 測試(不發信,只測握手) 這個版本不寄信,只測試 連線 → STARTTLS → AUTH LOGIN 是否正常。非常適合快速檢查主機、TLS 或帳密問題。 🔍 常見錯誤與排查 問題 原因與建議 Connection timed out 主機或連接埠錯誤、防火牆阻擋 Peer certificate CN…
Category: Linux
About Linux Tech
Building a Secure OpenVPN Server on OPNsense — Step-by-Step Practical Guide
Author: Rico WuEnvironment: OPNsense 25.xUse case: Remote work, branch office connectivity, employee VPN 1️⃣ Why OPNsense + OpenVPN? OpenVPN is an open-source, SSL-based VPN protocol that’s secure, cross-platform, and reliable.OPNsense provides a built-in GUI for managing OpenVPN — allowing administrators to quickly deploy: This makes OPNsense a strong, cost-free VPN gateway for modern hybrid work….
在 OPNsense 上建立與設定 OpenVPN:完整實務指南
作者: Rico Wu環境: OPNsense 25.x應用場景: 遠端辦公、跨地分公司連線、行動員工 VPN 一、為什麼選擇 OPNsense + OpenVPN? OpenVPN 是一款開源、安全且穩定的 VPN 解決方案,而 OPNsense 內建完整的 OpenVPN 管理介面,可快速建立: 與傳統 VPN 相比,OpenVPN 使用 TLS/SSL 驗證機制,可確保連線安全並支援跨平台(Windows / macOS / Linux / iOS / Android)。 二、建立 OpenVPN 伺服器(Server) 🔹 步驟 1:建立憑證授權中心(CA) 1️⃣ 前往 System → Trust → Authorities → +Add2️⃣ 設定如下: → 儲存 ✅ 🔹 步驟 2:建立伺服器憑證…
Deep Packet Power: Enabling Layer-7 Traffic Control on OPNsense
Author: Rico WuEnvironment: OPNsense 25.x + Zenarmor + SuricataUse case: Enterprise internet access control & application-layer filtering 🧱 1. What Is Layer-7 Control? Traditional firewalls operate mainly at Layer-3 and Layer-4 — controlling traffic based on IP addresses, ports, and protocols.While effective for basic routing and NAT, they can’t tell what the traffic actually is….
深度封包的力量:在 OPNsense 啟用 Layer 7(L7)應用層流量控制
作者: Rico Wu環境: OPNsense 25.x + Zenarmor + Suricata應用場景: 企業上網行為管理與應用層封包管控 🧱 一、什麼是 L7 流量控制? 一般防火牆主要運作在 L3(網路層)與 L4(傳輸層),也就是依據 IP、Port、通訊協定 來允許或阻擋流量。這樣能處理連線方向與基本安全,但無法辨識「應用內容」。 L7(Layer 7,應用層)防火牆 能深入檢視封包內容(DPI, Deep Packet Inspection),可根據實際應用類型進行控制,例如: 在企業網路環境中,L7 控制能大幅提升 安全性、效率與使用行為可視化。 ⚙️ 二、OPNsense 如何支援 L7? OPNsense 是基於 FreeBSD + pf 架構的防火牆,其中 pf 防火牆本身僅支援 L3/L4 控制。 但 OPNsense 可透過 插件與整合模組 實現 L7(應用層)控制,常用的三種方式如下: 模組 功能用途 L7 支援程度 備註 Zenarmor (原名…
Understanding “network unreachable resolving ‘./NS/IN’” Messages in BIND9
When managing a DNS server such as BIND9, you might notice repeated messages like these in your lame-servers.log or system log: At first glance, these may look like DNS errors.In reality, they are harmless IPv6 connectivity warnings, not signs of malfunction. 🔍 Why These Messages Appear When BIND performs recursive queries, it tries to contact…
BIND9 日誌出現「network unreachable resolving ‘./NS/IN’」的原因與解決方式
在管理 DNS 伺服器(如 BIND9)時,有時會在 lame-servers.log 或一般系統日誌中看到如下訊息: 乍看之下像是 DNS 出錯,但其實這些只是 IPv6 無法連線的提醒訊息,並不影響實際解析。 🔍 為什麼會出現這些訊息? BIND 在進行遞迴查詢時,會同時嘗試向根伺服器(Root DNS)查詢 IPv4 與 IPv6。如果你的伺服器或 Docker 容器 沒有啟用 IPv6 網路或沒有預設 IPv6 路由,BIND 嘗試連線到 IPv6 根伺服器(如 2001:500:1::53)時,就會出現: 👉 也就是說,它只是告訴你「IPv6 不通」,並不代表 DNS 功能異常。IPv4 解析仍然正常進行。 ✅ 解決方式(擇一) 方案 A:讓 BIND 僅使用 IPv4(最簡單) 如果你的環境暫時不使用 IPv6,可讓 BIND 啟動時加上 -4 參數。 範例:你原本的啟動腳本為 其中的 -4 位置錯了,應該改成放在 映像名稱之後,如下: 這樣…
Setting Up DNSSEC from Scratch: Building a Secure DNS Zone
In today’s internet infrastructure, DNSSEC (Domain Name System Security Extensions) plays a vital role in preventing forged or tampered DNS responses.This guide walks you step-by-step through creating a new DNS zone and enabling DNSSEC signing to ensure data integrity and trust. 1. What Is DNSSEC? DNSSEC adds cryptographic signatures to DNS records, allowing clients (resolvers)…
從零開始設定 DNSSEC:打造安全的 DNS Zone
在 DNS 架構中,DNSSEC (DNS Security Extensions) 能有效防止 DNS 資料被偽造或竄改。本文將一步步帶你完成一個新的 DNS 區域設定,並加入 DNSSEC 簽章,建立安全可信的名稱解析環境。 一、什麼是 DNSSEC? DNSSEC 透過「公開金鑰簽章」來保護 DNS 資料完整性。簡單來說,它會讓查詢者能驗證 DNS 回應是否真的來自授權的 DNS 伺服器,而不是中途被竄改。 主要機制包含: 二、建立新區域前的準備 三、建立新的 Zone 檔案 建立 /etc/bind/db.example.com,內容如下: 四、在 BIND 設定中加入 Zone 編輯 /etc/bind/named.conf.local: auto-dnssec maintain 與 inline-signing yes 會讓 BIND 自動處理簽章與金鑰輪換。 五、產生 DNSSEC 金鑰 在金鑰目錄(例如 /etc/bind/keys/)中執行: 系統會產生四個檔案: 六、簽署 Zone 重新載入 BIND 讓它執行自動簽章:…
Building a Split-Horizon + DNSSEC Authoritative/Recursive DNS with BIND 9.21
This post turns my containerized BIND 9.21 deployment notes into a step-by-step guide. To protect the real environment, all domains are anonymized as domainA and domainB, and public IPs are shown as examples (e.g., 203.0.113.0/24). Target Architecture Recommended Directory Layout Key points: put all K* key files + .state in /var/cache/bind/keys; keep managed-keys.bind* and *.mkeys*…