惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

P
Privacy International News Feed
Hacker News - Newest:
Hacker News - Newest: "LLM"
Application and Cybersecurity Blog
Application and Cybersecurity Blog
N
News and Events Feed by Topic
Hacker News: Ask HN
Hacker News: Ask HN
V2EX - 技术
V2EX - 技术
L
LINUX DO - 最新话题
Google Online Security Blog
Google Online Security Blog
www.infosecurity-magazine.com
www.infosecurity-magazine.com
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Stack Overflow Blog
Stack Overflow Blog
Recent Commits to openclaw:main
Recent Commits to openclaw:main
P
Proofpoint News Feed
A
Arctic Wolf
Forbes - Security
Forbes - Security
Spread Privacy
Spread Privacy
Security Latest
Security Latest
C
CXSECURITY Database RSS Feed - CXSecurity.com
C
CERT Recently Published Vulnerability Notes
Latest news
Latest news
AWS News Blog
AWS News Blog
M
MIT News - Artificial intelligence
GbyAI
GbyAI
V
Visual Studio Blog
T
The Blog of Author Tim Ferriss
有赞技术团队
有赞技术团队
Help Net Security
Help Net Security
博客园 - Franky
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
S
Schneier on Security
S
SegmentFault 最新的问题
Microsoft Security Blog
Microsoft Security Blog
Y
Y Combinator Blog
PCI Perspectives
PCI Perspectives
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
博客园_首页
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
P
Palo Alto Networks Blog
SecWiki News
SecWiki News
TaoSecurity Blog
TaoSecurity Blog
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
K
Kaspersky official blog
G
Google Developers Blog
H
Hacker News: Front Page
T
Tailwind CSS Blog
aimingoo的专栏
aimingoo的专栏
博客园 - 叶小钗
T
Troy Hunt's Blog
F
Full Disclosure
T
Threat Research - Cisco Blogs

泠泫凝的异次元空间

通过串口安装Linux | 泠泫凝的异次元空间 curl自编译 | 泠泫凝的异次元空间 Minecraft 认证服务器代理 | 泠泫凝的异次元空间 飞塔分流配置实战 | 泠泫凝的异次元空间 Windows 安全启动证书检查 | 泠泫凝的异次元空间 Lxn-OneDriveCLI | 泠泫凝的异次元空间 华三交换机配置 ERPS 环网 | 泠泫凝的异次元空间 PVE 配置 VLAN 感知 | 泠泫凝的异次元空间 MT7922 无线网卡安装 | 泠泫凝的异次元空间 无显示输出 Linux 主机配置桌面显示 | 泠泫凝的异次元空间 Wireguard 部署 SOP 手册(自用) | 泠泫凝的异次元空间 Zabbix 7.4 通过钉钉发送告警提醒 | 泠泫凝的异次元空间 Debian with xfce 通过 VNC 共享屏幕 华三S6860 IRF堆叠 | 泠泫凝的异次元空间 iPad 应用侧载 | 泠泫凝的异次元空间 Smart DNS 分区解析 | 泠泫凝的异次元空间 建立 NFS 服务器并挂载到客户端 | 泠泫凝的异次元空间 将 Android 以 MTP 方式连接至 Debian PVE 虚拟机迁移至 vCenter | 泠泫凝的异次元空间 vCenter 虚拟机迁移至 PVE | 泠泫凝的异次元空间 PVE迁移时提示密钥验证失败 | 泠泫凝的异次元空间 修改Windows设备设置区域 | 泠泫凝的异次元空间 恢复 SecureCRT 7.x 保存的密码 | 泠泫凝的异次元空间 PVE 超融合下电与上电流程 | 泠泫凝的异次元空间 记一次Zabbix异常处理 | 泠泫凝的异次元空间 苹果设备保存SHSH2 | 泠泫凝的异次元空间 PVE超融合部署 | 泠泫凝的异次元空间 树莓派启用zram | 泠泫凝的异次元空间 在 Hyper-V 上安装 EVE-NG | 泠泫凝的异次元空间 Zabbix 部署与 Windows 硬件信息收集 | 泠泫凝的异次元空间 在WSL2中安装CUDA支持 | 泠泫凝的异次元空间 MinIO 集群部署 | 泠泫凝的异次元空间 vmware 虚拟化平台备份工具 Veeam 12 安装及配置 ubuntu 24.04 安装 nVidia 驱动后网卡消失 XMRig 自编译 | 泠泫凝的异次元空间 云桌面通过组策略统一体验配置 | 泠泫凝的异次元空间 Fortigate SSLVPN 无法连接内网 VNC 服务器 CentOS 7 使用镜像作为本地源并将自身作为YUM源服务器 | 泠泫凝的异次元空间 CentOS 7 离线更新 OpenSSH 服务 使用KubeKey离线部署Kubernetes | 泠泫凝的异次元空间 使用PGP对消息进行签名 | 泠泫凝的异次元空间 禁止MinIO展示桶内文件列表 | 泠泫凝的异次元空间 华为 Fusion Access 云桌面部署 | 泠泫凝的异次元空间 vmware Horizon 模板机部署 | 泠泫凝的异次元空间 vmware Horizon 云桌面与云应用部署 | 泠泫凝的异次元空间 Citrix XenApp 云应用交付 | 泠泫凝的异次元空间 Citrix XenDesktop 云桌面部署 | 泠泫凝的异次元空间 PVE LVM 扩容 | 泠泫凝的异次元空间 Linux 网络聚合(bond方式) | 泠泫凝的异次元空间 Citrix XenServer 7.2 部署教程 | 泠泫凝的异次元空间 在 Windows Server 2019 上安装 AMD 显卡驱动 openEuler 安装并使用 EPEL 源 | 泠泫凝的异次元空间 从已有Linux系统创建带桌面环境的Docker镜像 | 泠泫凝的异次元空间 下载联想原厂镜像及解密 | 泠泫凝的异次元空间 在基于 arm 架构的服务器上安装 PVE | 泠泫凝的异次元空间 自制 EVE-NG 镜像 | 泠泫凝的异次元空间 不使用 Snap 在 ubuntu 上安装 Chromium 浏览器 Fortigate 6.2 固件从 PPPoE 获得 IPv6 地址 Fortigate 手记 | 泠泫凝的异次元空间 Fortigate 通过命令行自定义 NTP 服务器 | 泠泫凝的异次元空间 arm 架构 CentOS 7 安装 MySQL 5.7 版本 ubuntu 20 安装计算卡驱动和 CUDA Toolkit 锐捷诺客云添加设备后一直显示“等待同步” | 泠泫凝的异次元空间 Windows 10 自动登录 | 泠泫凝的异次元空间 OpenWRT IPv6 防火墙设置 | 泠泫凝的异次元空间 k8s 部署踩坑合集 | 泠泫凝的异次元空间 改变 Ubuntu TTY 终端字体 | 泠泫凝的异次元空间 Parted 无损扩容磁盘分区 | 泠泫凝的异次元空间 NTP服务器测试 | 泠泫凝的异次元空间 【相亲相爱】2024祝大家!新年快乐!!! ESXi中重新挂载数据盘 | 泠泫凝的异次元空间 使用 MediaMTX + RTSP 搭建低延迟直播服务器 Firewalld 手记 | 泠泫凝的异次元空间 Ubuntu 上不使用 snapd 安装 Firefox 在 armbian 上安装 xfce 和 VNC 做远程桌面 在 ubuntu 20 上使用 TigerVNC 做远程桌面 在 openEuler 上部署安装 openGauss | 泠泫凝的异次元空间 让特定IP(段)走VPN连接 | 泠泫凝的异次元空间 在Wireguard中排除部分IP(段) | 泠泫凝的异次元空间 CentOS 7 上升级 OpenSSL | 泠泫凝的异次元空间 将黑群晖部署到ESXi(笔记) | 泠泫凝的异次元空间 apk 代码反编译笔记 | 泠泫凝的异次元空间 Windows 搭建 iSCSI 服务器全攻略 | 泠泫凝的异次元空间 CentOS 7 编译安装 Python 3 开源语音识别工具 Whisper | 泠泫凝的异次元空间 Ubuntu 下 Python 编译安装及关联问题解决 | 泠泫凝的异次元空间 Ansible Tower 安装 | 泠泫凝的异次元空间 提高 PowerPoint 导出到图片时的分辨率 | 泠泫凝的异次元空间 利用亚马逊云服务器和VPC 构建安全可靠的虚拟网络 | 泠泫凝的异次元空间 Windows Server 多网卡链路聚合 | 泠泫凝的异次元空间 MT3000路由+移远EC20模块体验 | 泠泫凝的异次元空间 Python安装依赖时出现ctype问题 | 泠泫凝的异次元空间 GL-MT3000日用设置 | 泠泫凝的异次元空间 解除 vCenter 的最低内存限制 | 泠泫凝的异次元空间 跳过Windows 11的强制联网和账户登录 | 泠泫凝的异次元空间 Cloudflare Trace API 信息详解 | 泠泫凝的异次元空间 在CentOS中搭建由nginx反代和Apache2作为后端的Wordpress | 泠泫凝的异次元空间 通过nginx进行文件共享 | 泠泫凝的异次元空间 禁用 sudo 时密码认证 | 泠泫凝的异次元空间 在docker中一键搭建IPSec/IKEv2 VPN | 泠泫凝的异次元空间
Wireguard 组网笔记 | 泠泫凝的异次元空间
Lxn's Area · 2023-11-20 · via 泠泫凝的异次元空间

是自己弄wireguard的时候记的东西,有错误也别找我

基础环境

操作系统:CentOS 7.9-2009

步骤

懒得写开场白和结束语了,反正是笔记凑活看吧

  1. 首先升级 CentOS 内核:

    1
    yum update -y
  2. 安装 Wireguard ,这是一切罪恶的开始:

    1
    2
    3
    yum -y install epel-release https://www.elrepo.org/elrepo-release-7.el7.elrepo.noarch.rpm
    yum -y install yum-plugin-elrepo
    yum -y install kmod-wireguard wireguard-tools

    虽然不知道什么意思,但是他说如果是非标准内核还需要安装DKMS包:

    1
    2
    3
    yum -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
    curl -o /etc/yum.repos.d/jdoss-wireguard-epel-7.repo https://copr.fedorainfracloud.org/coprs/jdoss/wireguard/repo/epel-7/jdoss-wireguard-epel-7.repo
    yum -y install wireguard-dkms wireguard-tools

    最后查看一下内核是否已支持Wireguard:

    1
    modinfo wireguard

    如果支持会有如下返回:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    [root@VM-0-11-centos ~]# modinfo wireguard
    filename: /lib/modules/3.10.0-1160.99.1.el7.x86_64/weak-updates/wireguard/wireguard.ko
    intree: Y
    alias: net-pf-16-proto-16-family-wireguard
    alias: rtnl-link-wireguard
    version: 1.0.20220627
    author: Jason A. Donenfeld <Jason@zx2c4.com>
    description: WireGuard secure network tunnel
    license: GPL v2
    retpoline: Y
    rhelversion: 7.9
    srcversion: F54A3416733E9644E7DE623
    depends: udp_tunnel,ip6_udp_tunnel
    vermagic: 3.10.0-1160.el7.x86_64 SMP mod_unload modversions
    signer: The ELRepo Project (http://elrepo.org): ELRepo.org Secure Boot Key
    sig_key: F3:65:AD:34:81:A7:B2:0E:34:27:B6:1B:2A:26:63:5B:83:FE:42:7B
    sig_hashalgo: sha256
  3. 开启内核转发
    在中转服务器上打开内核转发。

    1
    2
    3
    echo "net.ipv4.ip_forward = 1" >> /etc/sysctl.conf
    echo "net.ipv4.conf.all.proxy_arp = 1" >> /etc/sysctl.conf
    sysctl -p /etc/sysctl.conf
  4. 安装docker
    参见Docker CE 软件仓库
    装好了需要手动起一下:

    1
    2
    systemctl start docker
    systemctl enable docker
  5. 装一下docker-compose:
    详见docker手记

  6. 安装Wireguard WebUI:
    新建文件夹新建docker-compose.yml

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    version: '3.6'
    services:
    wg-gen-web-demo:
    image: vx3r/wg-gen-web:latest
    container_name: wg-gen-web
    restart: unless-stopped
    ports:
    - "58080:8080"
    environment:
    - WG_CONF_DIR=/data
    - WG_INTERFACE_NAME=wg0.conf
    volumes:
    - /etc/wireguard:/data

    里面 SMTP 啥的都没配,具体看官方文档吧。

  7. 等起完了打开http://<ip>:58080改一下服务器配置:

    • Public endpoint for clients to connect to:指定末端IP地址,填服务器地址;
    • DNS servers for clients:DNS服务器

    然后改一下下面PostUP和PostDown做转发:

    • PostUP:
      1
      iptables -A FORWARD -i %i -j ACCEPT; iptables -A FORWARD -o %i -j ACCEPT; iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
    • PostDown:
      1
      iptables -D FORWARD -i %i -j ACCEPT; iptables -D FORWARD -o %i -j ACCEPT; iptables -t nat -D POSTROUTING -o eth0 -j MASQUERADE

    其中eth0作为上行口记得根据实际情况改一下,最后update一下配置文件

  8. 在首页新建Peer,然后下载对应的配置文件导入到客户端。

  9. 启动接口,并在每次添加新Peer后都需要重启一下:

    1
    systemctl start wg-quick@wg0

配置文件修改后自动重载

Reload命令

首先原理是这样的:改变配置文件后通过systemctl restart wg-quick@wg0进行重启Wireguard接口,但是重启的话会导致Peers断连,不过可以通过如下方式不中断当前活跃链接且重载配置文件:

1
wg syncconf wg0 <(wg-quick strip wg0)

那么可以将这条指令加入到wireguard的service文件中,使得我们在执行systemctl reload wg-quick@wg0时进行重载接口:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23

[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

需要注意的是如果是按照上面提到的Wireguard的方式安装,那么该条命令应该如上已经默认加到service文件中了,不需要任何操作。

自动重载

首先先创建个自动重载的逻辑:

1
2
3
4
5
6
7
8
9
10
11

[Unit]
Description=Restart WireGuard
After=network.target

[Service]
Type=oneshot
ExecStart=/usr/bin/systemctl reload wg-quick@wg0.service

[Install]
WantedBy=multi-user.target

然后再监听配置文件所在路径,当路径对应的文件变化时直接触发自动重载,该path文件必须与service文件同名:

1
2
3
4
5
6
7
8
9

[Unit]
Description=Watch /etc/wireguard for changes

[Path]
PathModified=/etc/wireguard

[Install]
WantedBy=multi-user.target

最后启用开机自启并立即启用:

1
systemctl enable wg-reload.service wg-reload.path --now

后面如果再到 Web 页面上更新配置信息,会立即触发 reload,不需要再自己手动 reload 了。

客户端连接

有用户界面的客户端就不写了,毫无难度。主要写一下没用户界面的Linux如何连接。

我这里客户端以Ubuntu 20.04为例,实际上和服务端的操作方法差不多。

  1. 安装Wireguard:
    1
    apt install -y iptables wireguard
    看一下是否已支持Wireguard:
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    root@node3:~# modinfo wireguard
    filename: /lib/modules/5.4.0-167-generic/kernel/wireguard/wireguard.ko
    intree: Y
    alias: net-pf-16-proto-16-family-wireguard
    alias: rtnl-link-wireguard
    version: 1.0.20201112
    author: Jason A. Donenfeld <Jason@zx2c4.com>
    description: WireGuard secure network tunnel
    license: GPL v2
    srcversion: 790E33D90B7386D123E9A74
    depends: udp_tunnel,ip6_udp_tunnel
    retpoline: Y
    name: wireguard
    vermagic: 5.4.0-167-generic SMP mod_unload modversions
    sig_id: PKCS#7
    signer: Build time autogenerated kernel key
    sig_key: 09:1A:1D:62:86:05:77:4D:5D:98:92:42:66:47:AF:D4:AA:DD:35:21
    sig_hashalgo: sha512
    signature: 77:0C:F9:1A:8D:57:54:74:1A:5D:F7:EE:82:4D:10:A3:18:12:28:D2:
  2. 将文件传入/etc/wireguard,并重命名为你需要的接口名称,通常都是wg+接口号(例如wg0wg1等)。
  3. 开启内核转发(对的,“客户端”也需要开启内核转发):
    1
    2
    3
    echo "net.ipv4.ip_forward = 1" >> /etc/sysctl.conf
    echo "net.ipv4.conf.all.proxy_arp = 1" >> /etc/sysctl.conf
    sysctl -p /etc/sysctl.conf
  4. Wireguard,启动!
    1
    2
    systemctl start wg-quick@wg0
    systemctl enable wg-quick@wg0

地狱难度进阶:Windows做中转

暂时没有什么头猪,先咕了。

参考资料

 上一篇

Linux