Hello World

吞风吻雨葬落日 欺山赶海踏雪径

0%

WireGuard 安装

WireGuard 安装

服务端

使用安装脚本

1
2
3
wget -O wireguard.sh https://get.vpnsetup.net/wg
sudo chmod +x wireguard.sh
sudo bash wireguard.sh

或者使用我的修改版本 wget -O wireguard.sh https://blog.forgives.top/htm/wg.txt

dns 可以使用阿里云的 223.5.5.5, 223.6.6.6

默认端口是 51820,可以修改/etc/wireguard/wg0.conf文件。

客户端

使用脚本自动生成客户端配置,每个客户端生成一个单独的配置wg0.conf (wg0 是 虚拟网络接口的名称):

1
2
3
4
5
6
7
8
9
10
11
[Interface]
Address = 10.7.0.3/24
DNS = 223.5.5.5, 223.6.6.6
PrivateKey = [PrivateKey]

[Peer]
PublicKey = [PublicKey]
PresharedKey = [PresharedKey]
AllowedIPs = 0.0.0.0/0
Endpoint = [ip]:51820
PersistentKeepalive = 25

客户端的 AllowedIPs 的都含义是哪些 ip 流量路由到 wg 的服务端,这里只需要网段内的流量,所以可以设置为 10.7.0.0/24

macOS 客户端安装

1
2
3
4
# mac 客户端安装
brew install wireguard-tools
# 启动服务
wg-quick up wg0.conf

Ubuntu 客户端安装

1
2
3
4
5
6
7
8
9
10
11
12
13
# root 权限执行
# ubuntu 客户端安装
apt install wireguard

# 写入配置
nano /etc/wireguard/wg0.conf

# 执行
wg-quick up wg0

# 配置服务
systemctl enable wg-quick@wg0
systemctl status wg-quick@wg0

Android/Windows 客户端安装
https://www.wireguard.com/install/