OpenVPN
Linux/macOS
# 后台运行 sudo openvpn --daemon --config /path/to/config.ovpn # 查看运行状态 systemctl status openvpn
Windows (命令行)
# 安装 OpenVPN 后,使用配置文件启动 openvpn-gui.exe --connect config.ovpn
WireGuard
Linux
# 激活 WireGuard 隧道 sudo wg-quick up wg0 # wg0 是配置文件(通常位于 /etc/wireguard/wg0.conf) # 关闭隧道 sudo wg-quick down wg0 # 查看状态 sudo wg show
Windows/macOS
- 使用官方 GUI 工具(WireGuard 应用程序)直接导入
.conf文件。
IPsec (StrongSwan)
Linux
# 启动 IPsec 服务 sudo systemctl start strongswan # 查看连接状态 sudo ipsec status
通用网络命令
检查 VPN 连接
# 查看网络接口(如 tun0、wg0) ip a # Linux ifconfig # macOS # 检查路由表 ip route # Linux netstat -rn # macOS/Windows # 测试 VPN 是否生效(查看出口 IP) curl ifconfig.me
断开 VPN
# 根据 VPN 类型停止服务 sudo systemctl stop openvpn # OpenVPN sudo wg-quick down wg0 # WireGuard
防火墙规则(Linux)
# 允许 VPN 端口(如 OpenVPN 的 1194/UDP) sudo ufw allow 1194/udp
注意事项
- 需要管理员权限(
sudo或管理员命令行)。 - 配置文件路径和命令可能因系统或 VPN 提供商而异。
- 部分 VPN(如商业服务)可能提供自定义客户端,无需手动输入命令。
如果需要具体场景的配置(如企业 VPN、AWS VPC 等),请补充说明!








