在Ubuntu 24.04 上启动WireGuard
在Ubuntu 24.04 上启动WireGuard 需要先安装WireGuard, 然后配置并启用WireGuard 接口 。 启动后,可以使用 wg show 命令来查看接口状态,并使用 journalctl 命令来查看日志进行故障排除。 以下是详细步骤: 1. 安装WireGuard: 代码 sudo apt update sudo apt install wireguard 2. 创建WireGuard 配置文件: 创建一个新的配置文件,例如 /etc/wireguard/wg0.conf (使用你喜欢的文本编辑器)。 配置文件的内容包括: [Interface] 部分: PrivateKey : 服务器的私钥(使用 wg genkey 生成)。 Address : 服务器的IP 地址(例如, 10.6.0.1/24 )。 ListenPort : 服务器监听的端口(例如, 51820 )。 [Peer] 部分: PublicKey : 客户端的公钥。 AllowedIPs : 客户端可以访问的IP 地址范围(例如, 10.6.0.2/32 )。 Endpoint : 客户端的公网IP 地址和端口(例如, client.example.com:51820 )。 PersistentKeepalive : 保持连接的频率(例如, 25 )。 3. 启用并启动WireGuard 接口: 代码 sudo systemctl enable wg-quick@wg0.service sudo systemctl start wg-quick@wg0.service 4. 验证WireGuard 接口状态: 代码 sudo wg show wg0 5. 查看日志(故障排除): 代码 sudo journalctl -u wg-quick@wg0.service 参考2: 1. 安装WireGuard: 代码 sudo apt update sudo apt install wireguard 2. 配置WireGuard 接口: 创建一个配置文件,例如 wg0.conf ,在 /etc/wireguar...