wg-quick:未找到公共接口

wg-quick:未找到公共接口

我正在尝试在远程 Ubuntu 22.04 服务器上配置 WireGuard,并在服务器上执行以下命令

sudo apt install wireguard

在服务器上创建私钥和公钥

wg genkey | tee privatekey | wg pubkey > publickey

创建配置文件 /etc/wireguard/wg0.conf

[Interface]
PrivateKey=+******n1+uTWXU=
Address=10.0.0.1/8
SaveConfig=true
PostUp = iptables -A FORWARD -i wg0 -j ACCEPT; iptables -t nat -A POSTROUTING -o <public-interface> -j MASQUERADE;
PostDown = iptables -D FORWARD -i wg0 -j ACCEPT; iptables -t nat -D POSTROUTING -o <public-interface> -j MASQUERADE;::
ListenPort = somePort

当我使用以下命令启用 wg0 接口时

wg-quick up wg0

它说“公共接口:没有这样的文件或目录”

root@srv173:~# wg-quick up wg0
[#] ip link add wg0 type wireguard
[#] wg setconf wg0 /dev/fd/63
[#] ip -4 address add 10.0.0.1/8 dev wg0
[#] ip link set mtu 1420 up dev wg0
[#] iptables -A FORWARD -i wg0 -j ACCEPT; iptables -t nat -A POSTROUTING -o <public-interface> -j MASQUERADE;
/usr/bin/wg-quick: line 295: public-interface: No such file or directory
[#] ip link delete dev wg0
root@srv173:~#

我的配置有什么问题?

  root@srv173:~# ip a
  1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state       UNKNOWN group default qlen 1000
  link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
  inet 127.0.0.1/8 scope host lo
   valid_lft forever preferred_lft forever
  inet6 ::1/128 scope host
   valid_lft forever preferred_lft forever
  2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel  state UP group default qlen 1000
  link/ether 00:16:3c:d2:2d:42 brd ff:ff:ff:ff:ff:ff
  altname enp0s3
  altname ens3
  inet 198.244.224.67/32 brd 198.244.224.67 scope global eth0
   valid_lft forever preferred_lft forever
  inet6 2001:41d0:800:400e::de7c:4d7f/64 scope global
   valid_lft forever preferred_lft forever
  inet6 2001:41d0:800:400e::9cfb:78a5/64 scope global
   valid_lft forever preferred_lft forever
  inet6 2001:41d0:800:400e::6f9c:586e/64 scope global
   valid_lft forever preferred_lft forever
  inet6 2001:41d0:800:400e::30e6:4cdf/64 scope global
   valid_lft forever preferred_lft forever
  inet6 fe80::216:3cff:fed2:2d42/64 scope link
   valid_lft forever preferred_lft forever


  root@srv173:~# netstat -ni
  Kernel Interface table
  Iface      MTU    RX-OK RX-ERR RX-DRP RX-OVR    TX-OK TX-ERR TX-  DRP TX-OVR Flg
  eth0      1500   188775      0      0 0        129368      0      0      0 BMRU
  lo       65536       59      0      0 0            59      0      0      0 LRU

相关内容