标签: wireguard

无法设置 WireGuard VPN

我的目标是创建一个 VPN,以便

  1. 客户端拥有静态 IP 地址。
  2. 客户端能够相互通信以及与服务器通信,
  3. 客户可以通过VPN访问全球互联网。
  4. 另外,我想设置 DNS 和私有域名(与 NginX 一起使用)。

这是服务器的配置:

[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)

ubuntu vpn wireguard

12
推荐指数
2
解决办法
6万
查看次数

如何查看 WireGuard 的调试日志(例如查看身份验证尝试)

我已经在我的 Debian 10 服务器上成功设置了WireGuard VPN。与 OpenVPN 的设置相比,它非常简单,而且运行良好。

但是,除了来自journalctl -u wg-quick@wg0.service. 例如,我想知道什么时候认证尝试失败。有没有办法监控?例如,使用 openvpn 我可以使用基于身份验证尝试的 fail2ban。

wireguard debian-buster

11
推荐指数
1
解决办法
2万
查看次数

无需重启即可添加 Wireguard 客户端

我正在构建 Wireguard VPN 网络,我想在其中添加和删除服务器上的对等点,而无需重新启动服务或丢失与现有对等点的连接。尝试搜索结果,但我没有找到任何可以满足我需求的解决方案(所有解决方案都会导致几秒钟的冻结或需要客户端与服务器重做握手)。是否可以使用 Wireguard 来实现这一点?如果可以,如何实现?

linux configuration wireguard

9
推荐指数
2
解决办法
2万
查看次数

Wiregurd 覆盖 wg0.conf

我已在 Debian Buster 上成功安装 Wireguard。现在我想稍后配置 IPv6。我已经这么做了。[Peer]但-Section内的设置wg0.conf似乎并不持久。

systemctl stop wg-quick@wg0.service
nano /etc/wireguard/wg0.conf
Run Code Online (Sandbox Code Playgroud)

结果:

[Peer]
PublicKey = xxxxx
AllowedIPs = 10.200.200.2/32, xxx:xxxx:xx:xxx:100::2/72
Run Code Online (Sandbox Code Playgroud)

保存并重新启动服务后,systemctl start wg-quick@wg0.service看起来wg0.conf不错。

当我再次重新启动虚拟机或服务时,所有其他设置都会丢失。

[Peer]
PublicKey = xxxxx
AllowedIPs = 10.200.200.2/32
Run Code Online (Sandbox Code Playgroud)

任何想法?

这就是我wg0.conf应该的样子

[Interface]
Address = 10.200.200.1/24
Address = xxxx:xxx:xx:xxx::1/72
DNS = 10.200.200.1
SaveConfig = true
PostUp = iptables -A FORWARD -i wg0 -j ACCEPT; iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE; ip6tables -A FORWARD -i wg0 -j …
Run Code Online (Sandbox Code Playgroud)

debian wireguard

8
推荐指数
1
解决办法
5025
查看次数

Wireguard - 如何仅隧道部分流量

是否可以设置 Wireguard 服务器,以便仅通过 Wireguard 传输 ips [A、B、C、...] 列表 - 而其余流量将被忽略并通过非 Wireguard 接口?

换句话说,我试图向某些外部人员授予对 Wireguard VPN 的访问权限,但我不希望他们能够使用 VPN 浏览我指定的其他 ip/站点(同时让他们可以访问任何他们想要的内容)想要自己的非 VPN 接口/连接。

谢谢

networking security vpn ip wireguard

8
推荐指数
1
解决办法
2万
查看次数

Wireguard VPN 无法访问互联网和 LAN

我有一台运行Ubuntu 20.04和wireguard 1.0.20200513-1~20.04.2的服务器。我在手机(Android Samsung S20+)上安装了wireguard应用程序并禁用了WIFI并连接到4G。当 VPN 处于活动状态时,我可以访问服务器,而无法访问家庭网络 (192.168.1.X) 或互联网上的其他内容。服务器具有 10.0.0.1 (VPN) 和 192.168.1.171 (LAN) 接口。电话获得 10.0.0.2 接口。我想我需要设置一条路线。服务器防火墙(ufw 状态)处于非活动状态。任何帮助将非常感激。

/etc/wireguard/wg0.conf

[Interface]
Address = 10.0.0.1/24
Address = <MAC>::1/64
SaveConfig = true    
ListenPort = 51820
PrivateKey = <SERVER_KEY>

[Peer]
PublicKey = <CELL_PUB_KEY>
AllowedIPs = 10.0.0.2/32, 
Endpoint = <EXTERNAL_IP>:8598
Run Code Online (Sandbox Code Playgroud)

客户端配置

Cellphone config
[Interface]
PrivateKey =<CELL_KEY>
Address = 10.0.0.2/24
DNS = 1.1.1.1, 1.0.0.1

[Peer]
PublicKey = <SERVER_PUB_KEY>
AllowedIPs = 10.0.0.0/24, 192.168.1.0/24
Endpoint = <EXTERNAL_IP>:51820
Run Code Online (Sandbox Code Playgroud)

/etc/sysctl.conf

net.ipv4.ip_forward=1
net.ipv6.conf.all.forwarding=1
Run Code Online (Sandbox Code Playgroud)

路线-n

Destination     Gateway         Genmask         Flags Metric Ref    Use …
Run Code Online (Sandbox Code Playgroud)

ubuntu vpn routing wireguard

7
推荐指数
1
解决办法
2万
查看次数

使用wireguard进行端口转发

使用 qbittorrent 和 airdcpp 等应用程序来共享文件。它们都需要转发一些端口才能“可连接”。

在家庭连接中,我会进入路由器设置192.168.1.1,然后转发端口,例如。56000到我的电脑的本地 IP 地址:192.168.1.124。而且服务会正常工作。

后来在Linode VPS 上设置了wireguard,希望我可以VPN 进入它并屏蔽我的IP。但是当我这样做时,当我访问https://whoer.net这样的地方时,我的 IP 地址会发生变化。但使用的端口,例如。 56000未转发,因此应用程序不可“连接”。

为了让 VPS 像我的家庭路由器一样转发这些端口,我需要在 iptables 中添加哪些内容?

端口56000设置为allow活动 VPSufw防火墙中的端口。

非常感谢您的浏览。

这是我的 VPS 线卫配置的样子:

Address = 10.66.66.1/24,fd42:42:42::1/64
ListenPort = 49503
PrivateKey = ***


[Peer]
PublicKey = ***
PresharedKey = ***
AllowedIPs = 10.66.66.2/32,fd42:42:42::2/128
Run Code Online (Sandbox Code Playgroud)

port-forwarding wireguard

7
推荐指数
1
解决办法
4万
查看次数

是否可以在 WireGuard VPN 客户端中禁用默认网关?

是否可以在 WireGuard VPN 客户端中禁用默认网关?我对自己的子网使用了“允许的 IP”,但每当我尝试连接到 VPN 服务器时,客户端都会将默认网关设置为 WireGuard 服务器 IP。

还有其他方法可以禁用 WireGuard 中的默认网关吗?

vpn vpn-client wireguard

6
推荐指数
1
解决办法
2万
查看次数

Wireguard 无缘无故失去连接。没有连接问题

我在 ubuntu 18.04.6 LTS 上有一个 WG“服务器”,托管在 oracle 免费层中。

\n

我已经使用众所周知的https://github.com/angristan/wireguard-install脚本安装了wireguard。然后我为我的台式机、手机等生成了几个配置。它可以完美连接并运行,但有时它会无缘无故地冻结。不存在连接问题或类似问题。客户端的日志与 Win 桌面上的内容类似:

\n
2022-06-21 03:01:01.845: [TUN] [win] Keypair 17 created for peer 1\n2022-06-21 03:01:01.846: [TUN] [win] Sending keepalive packet to peer 1 (SERVER_IP:SERVER_PORT)\n2022-06-21 03:03:01.822: [TUN] [win] Sending handshake initiation to peer 1 (SERVER_IP:SERVER_PORT)\n2022-06-21 03:03:01.884: [TUN] [win] Receiving handshake response from peer 1 (SERVER_IP:SERVER_PORT)\n2022-06-21 03:03:01.884: [TUN] [win] Keypair 16 destroyed for peer 1\n2022-06-21 03:03:01.884: [TUN] [win] Keypair 18 created for peer 1\n2022-06-21 03:03:01.884: [TUN] [win] Sending keepalive packet to …
Run Code Online (Sandbox Code Playgroud)

wireguard

6
推荐指数
1
解决办法
5271
查看次数

通过 WireGuard 广播 UPnP

我的设备很少:VDS、Linux 上的定制 NAS、笔记本电脑。所有这些都成功连接到一个本地子网 10.1.1.0/24

服务器配置:

[Interface]
Address = 10.1.1.1/24
ListenPort = 5182
PrivateKey = ***

[Peer]
PublicKey = ***
AllowedIPs = 10.1.1.2/32

[Peer]
PublicKey = ***
AllowedIPs = 10.1.1.12/32
Run Code Online (Sandbox Code Playgroud)

典型客户:

[Interface]
Address = 10.1.1.2/32
PrivateKey = ***

[Peer]
PublicKey = ***
AllowedIPs = 10.1.1.0/24,224.0.0.0/4
Endpoint = host.name:5182
Run Code Online (Sandbox Code Playgroud)

客户端接口(服务器相同)

wg0: <POINTOPOINT,NOARP,UP,LOWER_UP> mtu 1420 qdisc noqueue state UNKNOWN group default qlen 1000
    link/none
    inet 10.1.1.2/24 scope global hub0
       valid_lft forever preferred_lft forever
Run Code Online (Sandbox Code Playgroud)

服务器监听任意地址和端口

UNCONN 0      0                         239.255.255.250:1900       0.0.0.0:*     users:((minidlnad,pid=456,fd=5))
Run Code Online (Sandbox Code Playgroud)

无法发现 DLNA 服务器,当我使用 …

upnp wireguard

5
推荐指数
1
解决办法
4563
查看次数