前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >专栏 >WireGuard 系列文章(三):WireGuard 安装

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

作者头像
东风微鸣
发布2022-04-22 13:42:15
发布2022-04-22 13:42:15
7.6K00
代码可运行
举报
运行总次数:0
代码可运行

系列文章前情提要:

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
运行
复制
$ sudo apt install wireguard

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

1.CLI1.wg

2.wg-quick

2.Systemd

1.wg-quick@.service

2.wg-quick.target

代码语言:javascript
代码运行次数:0
运行
复制
# 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-files
UNIT FILE                              STATE           VENDOR PRESET
wg-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 %I
After=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.8
Documentation=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 UI

启动 WireGuard 后会有 2 个服务:

WireGuardManager 服务

WireGuard Tunnel 服务

Android

•Download from Play Store[6]

•Download from F-Droid[7]

WireGuard Android 客户端:

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:😏😏😏

QTS 5.0 Linux Kernel 5.10

QTS 5.0 支持 WireGuard

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

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

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

自带内容包括:

代码语言:javascript
代码运行次数:0
运行
复制
[~] # 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/

本文参与 腾讯云自媒体同步曝光计划,分享自微信公众号。
原始发表:2021-12-13,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 东风微鸣技术博客 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • Ubuntu 20.04
  • Windows 10
  • Android
  • 威联通 QTS 5.0
  • 参考资料
    • References
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档