29
2025
03
02:09:27

WireGuard 系列文章(三):WireGuard 安装

系列文章前情提要:

1.WireGuard系列文章

(一):什么是V**[1]2.WireGuard 系列文章

(二):WireGuard 简介 - 快速、现代、安全的 V** 隧道[2]

WireGuard 的安装都不难,这里以我用到的设备为例,包括:

1.Linux - Ubuntu 20.04

2.Windows 10

3.NAS - 威联通 QTS 5.0

4.安卓

Ubuntu 20.04

⚠️ 注意: WireGuard 对 Linux 内核版本有要求,5.4 以上内核才将其纳入其中。如果内核低于该版本(典型如:RHEL 和 CentOS),就需要比较复杂的涉及内核编译的过程,请自行登录官网[3]查找详细信息。

代码语言:javascript
代码运行次数:0
运行
AI代码解释
$ sudo apt install wireguard

安装成功后,有以下文件:

1.CLI1.wg

2.wg-quick

2.Systemd

1.wg-quick@.service

2.wg-quick.target

代码语言:javascript
代码运行次数:0
运行
AI代码解释
# which wg/usr/bin/wg # WireGuard CLI# which wg-quick/usr/bin/wg-quick # WireGuard 快速 CLI# sudo ls -l /etc/drwx------ 2 root root       4096 Aug  4  2020 wireguard    # WireGuard 默认配置文件位置

# sudo systemctl list-unit-filesUNIT FILE                              STATE           VENDOR PRESETwg-quick@.service                      disabled        enabled
wg-quick.target                        static          enabled

# pwd/lib/systemd/system # WireGuard 2 个 Service 所在的目录

# cat wg-quick@.service
# /usr/lib/systemd/system/wg-quick@.service[Unit]Description=WireGuard via wg-quick(8) for %IAfter=network-online.target nss-lookup.target
Wants=network-online.target nss-lookup.target
PartOf=wg-quick.target
Documentation=man:wg-quick(8)Documentation=man:wg(8)Documentation=https://www.wireguard.com/Documentation=https://www.wireguard.com/quickstart/Documentation=https://git.zx2c4.com/wireguard-tools/about/src/man/wg-quick.8Documentation=https://git.zx2c4.com/wireguard-tools/about/src/man/wg.8[Service]Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/bin/wg-quick up %i
ExecStop=/usr/bin/wg-quick down %i
ExecReload=/bin/bash -c 'exec /usr/bin/wg syncconf %i <(exec /usr/bin/wg-quick strip %i)'Environment=WG_ENDPOINT_RESOLUTION_RETRIES=infinity[Install]WantedBy=multi-user.target

# cat wg-quick.target[Unit]Description=WireGuard Tunnels via wg-quick(8)

✔️ 实用技巧: 可以在 WireGuard 的 Service 文件中加入如下一行,重新加载配置流量不中断。 ExecReload=/bin/bash -c 'exec /usr/bin/wg syncconf %i <(exec /usr/bin/wg-quick strip %i)'

Windows 10

•Download Windows Installer[4]

•Browse MSIs[5]

安装后 WireGuard UI 如下:


WireGuard 系列文章(三):WireGuard 安装


WireGuard UI

启动 WireGuard 后会有 2 个服务:


WireGuard 系列文章(三):WireGuard 安装


WireGuardManager 服务


WireGuard 系列文章(三):WireGuard 安装


WireGuard Tunnel 服务

Android" class="zit" style="margin: 16px 0px 8px; padding: 0px; box-sizing: border-box; outline: none; color: rgb(255, 255, 255); background: rgb(255, 255, 255); line-height: 26px; position: relative; z-index: 2; min-width: 2em; display: inline-block; min-height: 1em; font-size: 16px; box-shadow: rgba(0, 0, 0, 0.3) 0.5em 0.5em 0.5em -0.3em; white-space: pre-wrap; overflow-wrap: break-word; list-style: inherit; font-family: "pingfang SC", "helvetica neue", arial, "hiragino sans gb", "microsoft yahei ui", "microsoft yahei", simsun, sans-serif;">Android

•Download from Play Store[6]

•Download from F-Droid[7]

WireGuard Android 客户端:


WireGuard 系列文章(三):WireGuard 安装


WireGuard Android 客户端

威联通 QTS 5.0

我为啥会捣鼓 WireGuard,其实事情是这样滴:

1.家里的电信网,没有公网 IPv4,之前打电话要求有公网地址,给了个公网 IPv4,结果多一段时间发现又偷偷被收回了? 虽然有 IPv6 公网地址,但是很多应用不支持

2.威联通提供的 QnapCloud 在没有公网 IPv4 的前提下,使用体验差极了

3.用 OpenV** 和 IPsec 都搭建过家庭 V**,性能、使用体验确实不行

4.前端时间 NAS 升级到 QTS 5.0(出于安全目的,会紧跟厂商升级),发现它 Linux Kernel 已经升级到 5.10,自带 WireGuard:???


WireGuard 系列文章(三):WireGuard 安装


QTS 5.0 Linux Kernel 5.10


WireGuard 系列文章(三):WireGuard 安装


QTS 5.0 支持 WireGuard

5.「全新 QV** 3.0 整合广受好评、更轻量、更稳定的 WireGuard V** 服务,让您通过简单的用户接口轻松设置,享受快速安全联机,是居家工作与移动办公的不二选择。」好家伙,这么牛逼吗?那必须得试一试。

6.所以才有这一个多月捣鼓 WireGuard 的过程。

综上,QTS 5.0 内置 WireGuard,无需安装。

自带内容包括:

代码语言:javascript
代码运行次数:0
运行
AI代码解释
[~] # which wg/usr/bin/wg[~] # which wg-quick/usr/bin/wg-quick[~] # find / -name *wireguard* -type d 2>/dev/null/share/CACHEDEV1_DATA/.qpkg/CodexPack/sys/module/wireguard/share/CACHEDEV1_DATA/.qpkg/QVPN/wireguard_log  # wg 日志目录/sys/module/wireguard    
/mnt/HDA_ROOT/.config/qvpn/wireguard    # wg 默认配置目录,就是 `/etc/config/qvpn/wireguard/` 这个目录[~] # ll /share/CACHEDEV1_DATA/.qpkg/QVPN/wireguard_log
total 16K
drwxr-xr-x  2 admin administrators 4.0K 2021-11-12 23:01 ./drwxr-xr-x 13 admin administrators 4.0K 2021-11-15 23:00 ../-rw-rw-rw-  1 admin administrators 6.8K 2021-12-07 21:14 wg_server.log[~] # find / -name *wireguard* -type f 2>/dev/null/share/CACHEDEV1_DATA/.qpkg/container-station/usr/local/container-station/python/lib/python2.7/site-packages/pyroute2/netlink/generic/wireguard.pyc/share/CACHEDEV1_DATA/.qpkg/container-station/usr/local/container-station/python/lib/python2.7/site-packages/pyroute2/netlink/generic/wireguard.py/share/CACHEDEV1_DATA/.qpkg/container-station/usr/local/container-station/python/lib/python2.7/site-packages/scapy/contrib/wireguard.pyc/share/CACHEDEV1_DATA/.qpkg/container-station/usr/local/container-station/python/lib/python2.7/site-packages/scapy/contrib/wireguard.py/share/CACHEDEV1_DATA/.qpkg/QVPN/etc/init.d/vpn_wireguard_client.sh # 如果是用 qvpn 配置的 wireguard,那么这是qvpn 调用 wireguard 的启动脚本/share/CACHEDEV1_DATA/.qpkg/QVPN/etc/init.d/vpn_wireguard.sh # 如果是用 qvpn 配置的 wireguard,那么这是qvpn 调用 wireguard 的启动脚本/lib/modules/5.10.60-qnap/wireguard.ko

参考资料

•Installation - WireGuard[8]

References

[1] WireGuard系列文章(一):什么是V**: http://ewhisper.cn/posts/32152/[2] WireGuard 系列文章(二):WireGuard 简介 - 快速、现代、安全的 V** 隧道: http://ewhisper.cn/posts/23685/[3] 官网: https://www.wireguard.com/install/[4] Download Windows Installer: https://download.wireguard.com/windows-client/wireguard-installer.exe[5] Browse MSIs: https://download.wireguard.com/windows-client/[6] Download from Play Store: https://play.google.com/store/apps/details?id=com.wireguard.android[7] Download from F-Droid: https://f-droid.org/en/packages/com.wireguard.android/[8] Installation - WireGuard: https://www.wireguard.com/install/




推荐本站淘宝优惠价购买喜欢的宝贝:

WireGuard 系列文章(三):WireGuard 安装

本文链接:https://hqyman.cn/post/9958.html 非本站原创文章欢迎转载,原创文章需保留本站地址!

分享到:
打赏





休息一下~~


« 上一篇 下一篇 »

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

请先 登录 再评论,若不是会员请先 注册

您的IP地址是: