
---

服务端(公网):
默认开放UDP端口：51820
```bash

#生成公钥私钥
cd /etc/wireguard
wg genkey | tee privatekey | wg pubkey > publickey

sudo wg-quick down wgs-alycd
sudo wg-quick up wgs-alycd

sudo wg

#查看当前WireGuard状态和连接详情
sudo wg show 

sudo systemctl start wg-quick@
sudo systemctl status wg-quick@
sudo systemctl stop wg-quick@
#设置隧道开机自启
sudo systemctl enable wg-quick@

#安装更改DNS的软件包
apt install -y resolvconf
```

```bash
#中转服务器记得开启ip转发
# 永久启用 IPv4 转发
echo "net.ipv4.ip_forward = 1" | sudo tee -a /etc/sysctl.conf
echo "net.ipv4.conf.all.forwarding = 1" | sudo tee -a /etc/sysctl.conf

# 服务端确认内核转发已开启，返回值应为1
sysctl net.ipv4.ip_forward

# 应用配置
sudo sysctl -p
```

---


客户端(私网):
```bash
#生成公钥私钥
cd /etc/wireguard
sudo wg genkey | tee privatekey | wg pubkey > publickey

sudo wg-quick down wg-bigsmy
sudo wg-quick up wg-bigsmy

sudo wg

#查看当前WireGuard状态和连接详情
sudo wg show 

#设置隧道开机自启
sudo systemctl enable wg-quick@
```