文章介绍:使用vyos本身的wireguard interfases接口使能WireGuard SSL VPN功能,让用户支持电脑或者手机拨号连接到vyos系统然后访问内网资源。
一、搭建准备
1.1、博主网盘
1.2、GitHub站
1.3、VMware 安装 VyOS 指导
1.4、VyOS 基础配置指导
1.5、WireGuard 客户端下载
二、Windows配置WireGuard(阶段一)
三、VyOS配置WireGuard
3.1、生成公钥私钥
generate pki wireguard key-pair
3.2、生成共享密钥
generate pki wireguard preshared-key
3.3、配置WireGuard接口
set interfaces wireguard wg20000 address '10.20.20.1/24'
set interfaces wireguard wg20000 peer win10 allowed-ips '10.20.20.2/32'
set interfaces wireguard wg20000 peer win10 preshared-key 'opu0kWmI6SoHJ83xmAIqj+MIX+lix2yy7whr/NIFsp0='
set interfaces wireguard wg20000 peer win10 public-key '76IHuz8gyXj9Y9/o00FEko2RxnQ679YQF9T3qLgduV4='
set interfaces wireguard wg20000 peer ios15 allowed-ips '10.20.20.3/32'
set interfaces wireguard wg20000 peer ios15 preshared-key 'opu0kWmI6SoHJ83xmAIqj+MIX+lix2yy7whr/NIFsp0='
set interfaces wireguard wg20000 peer ios15 public-key '2RxnQ679YQF976IT3qLgduV4Huz8gyXj9Y9/o00FEko='
set interfaces wireguard wg20000 port '20000'
set interfaces wireguard wg20000 private-key 'KFAvL6bCOvV2mWTrQ8i/FGDRnSe1Whgh2kSwkBWoemw='
-
设置接口地址:
10.20.20.1/24
:为wg20000
接口分配 IP 地址10.20.20.1
,子网掩码为255.255.255.0
。
-
配置对等端的允许 IP 地址:
0.0.0.0/0
:指定对等端win10
可以通过wg20000
接口访问所有 IP 地址。
-
配置预共享密钥:
'opu0kWmI6SoHJ83xmAIqj+MIX+lix2yy7whr/NIFsp0='
:设置与对等端win10
共享的预共享密钥。
-
配置对等端的公钥:
'76IHuz8gyXj9Y9/o00FEko2RxnQ679YQF9T3qLgduV4='
:设置对等端win10
的公钥。
-
设置 WireGuard 接口端口:
20000
:配置wg20000
接口使用的监听端口为 20000。
-
配置 WireGuard 私钥:
'KFAvL6bCOvV2mWTrQ8i/FGDRnSe1Whgh2kSwkBWoemw='
:设置wg20000
接口的私钥。
3.4、VyOS完整配置
run show conf com
四、配置WireGuard(阶段二)
4.1、Windwos
[Interface]
PrivateKey = 0PR/y11xhw2N+qXj3SVNZVFj14sg8efyw0P53D8+UFU=
Address = 10.20.20.2/32
DNS = 223.5.5.5,223.6.6.6
[Peer]
PublicKey = jH92uDeEHGKOf/N7bNvlIXp+ul1u7Sy2jo7LzE9lSSY=
PresharedKey = opu0kWmI6SoHJ83xmAIqj+MIX+lix2yy7whr/NIFsp0=
AllowedIPs = 0.0.0.0/1, 128.0.0.0/1
Endpoint = 192.168.65.191:10000
4.2、iOS
[Interface]
PrivateKey = 0PR/y11xhw2N+qXj3SVNZVFj14sg8efyw0P53D8+UFU=
Address = 10.20.20.3/32
DNS = 223.5.5.5,223.6.6.6
[Peer]
PublicKey = jH92uDeEHGKOf/N7bNvlIXp+ul1u7Sy2jo7LzE9lSSY=
PresharedKey = opu0kWmI6SoHJ83xmAIqj+MIX+lix2yy7whr/NIFsp0=
AllowedIPs = 0.0.0.0/1, 128.0.0.0/1
Endpoint = 192.168.65.191:10000