我的目标是创建一个 VPN,以便
这是服务器的配置:
[Interface]
Address = 10.0.0.1/24
ListenPort = 5555
PrivateKey = xxxxx
[Peer]
PublicKey = xxxxx
AllowedIPs = 0.0.0.0/0
Run Code Online (Sandbox Code Playgroud)
和客户端的配置:
[Interface]
PrivateKey = xxxxx
ListenPort = 5555
Address = 10.0.0.2/32
DNS = 8.8.8.8
[Peer]
PublicKey = xxxxx
AllowedIPs = 0.0.0.0/0, ::/0
Endpoint = <server ip>:5555
Run Code Online (Sandbox Code Playgroud)
但是当我尝试加载服务器的配置时,wg setconf wg0 /etc/wireguard/wg0.conf
出现此错误:
Line unrecognized: `Address=10.0.0.1/24'
Configuration parsing error
Run Code Online (Sandbox Code Playgroud)
因此我评论了这一行。但它可能会让 WG 为服务器和客户端选择随机 IP 地址。
为了使 WireGuard 工作,我还运行了以下命令:
ip link add dev …
Run Code Online (Sandbox Code Playgroud)