ubuntu_debian上配置Wireguard
17 December 2023
Ubuntu/Debian上配置Wireguard客户端
安装Wireguard
#root权限
sudo -i
#安装wireguard软件
apt install wireguard resolvconf -y
#开启IP转发
echo "net.ipv4.ip_forward = 1" >> /etc/sysctl.conf
sysctl -p
调整配置目录权限
参考:https://gitee.com/spoto/wireguard
cd /etc/wireguard/
chmod 0777 /etc/wireguard
#调整目录默认权限
umask 077
然后再在/etc/wireguard下添加一个wg0.conf配置文件
[Interface]
PrivateKey = IXXXXXXXXXXXXXXXXXXXxxxxxxxxxxxxxxxw=
Address = 10.10.10.9/24
DNS = 8.8.8.8
[Peer]
PublicKey = 7SZXXXXXXXXXXXXXXXXXXXXXXxxxxxxxxxxxx=
PresharedKey = zzXXXXXXXXXXXXXXXXXXXXXXXXXXXxxxxx=
AllowedIPs = 10.10.10.0/24
PersistentKeepalive = 25
Endpoint = x.x.x.x:51820
设置服务器开机自启动
systemctl enable wg-quick@wg0
启动wireguard
#启动wg0
wg-quick up wg0
#关闭wg0
wg-quick down wg0
#查状态
wg show wg0
