SoftEther (Software Ethernet) 支援 SSL-VPN (HTTPS 模式穿透防火牆)、L2TP/IPsec、OpenVPN、SSTP、MS-SSTP 多協議,**單端口 (默認 443) 即可承載所有協議**,極適合受限網絡環境。Linux 版以靜態庫 + 手動鏈接形式分發,部署流程獨特,本文完整記錄。
.a 靜態庫鏈接的鏈接器:GCC/Clang/LLD 滿足。unzip se_100_linux.zip
# 產出三個文件:
# libse_hub.a # 核心靜態庫 (含 V-HUB 邏輯)
# ca.crt # CA 證書
# ca.key # CA 私鑰
mkdir se_hub && mv libse_hub.a ca.crt ca.key se_hub/ && cd se_hub/
**關鍵點**:分發包不含可執行二進制,需手動鏈接 libse_hub.a + pthread + ssl + crypto:
gcc libse_hub.a -lpthread -lssl -lcrypto -o se_hub
# -lcrypto 而非 -lcrypt (加密庫 vs 加密函數庫,OpenSSL 需前者)
# 若報錯 "undefined reference to `SSL_...`" 確認 -lssl -lcrypto 順序在 -lpthread 後
成功無報錯後,當前目錄生成 se_hub 可執行文件 (即 V-HUB 服務端)。
setcap 'cap_net_bind_service=+ep' se_hub 賦能普通用戶綁定低端口)。sudo ./se_hub
# 輸出日誌顯示監聽端口、協議初始化狀態
# Ctrl+C 停止
方案 A:nohup 臨時方案
nohup sudo ./se_hub > /var/log/softether.log 2>&1 &
# 輸出重定向到日誌文件,終端關閉不影響進程
方案 B:systemd 服務單元 (推薦,開機自啟、自動重啟、日誌集中)
# /etc/systemd/system/softether.service
[Unit]
Description=SoftEther VPN Server
After=network.target
[Service]
Type=simple
User=root
WorkingDirectory=/opt/softether
ExecStart=/opt/softether/se_hub
Restart=on-failure
RestartSec=5
StandardOutput=append:/var/log/softether.log
StandardError=append:/var/log/softether.log
# 安全加固 (可選)
# CapabilityBoundingSet=CAP_NET_BIND_SERVICE
# AmbientCapabilities=CAP_NET_BIND_SERVICE
# NoNewPrivileges=yes
[Install]
WantedBy=multi-user.target
systemctl daemon-reload
systemctl enable --now softether
systemctl status softether
journalctl -u softether -f
telnet localhost 8023 (本機) 或 telnet server_ip 8023 (遠程)。# systemd 管理
systemctl stop softether
# nohup 方式
pkill -f se_hub
# 或查找 PID
ps aux | grep se_hub
kill
./configure --with-openssl=/usr/local/openssl (若源碼構建) 或鏈接時 -L/usr/local/openssl/lib -Wl,-rpath=/usr/local/openssl/lib。logrotate 處理 /var/log/softether.log。SoftEther Linux 版的「靜態庫手動鏈接」雖顯古老,但保證了極高的跨發行版兼容性。**配合 systemd 守護進程化、OpenSSL 更新維護、管理端口訪問控制 (僅信任 IP 可連 8023)**,即可構建企業級、高穿透、多協議的 VPN 基礎設施。