
---

服务端(公网):
默认开放UDP端口：51820
```bash
# 服务端确认内核转发已开启，返回值应为1
sysctl net.ipv4.ip_forward
# 如果返回值是0，需要开启并使其生效
sudo sed -i 's/#net.ipv4.ip_forward=1/net.ipv4.ip_forward=1/' /etc/sysctl.conf
sudo sysctl -p

#生成公钥私钥
cd /etc/wireguard
sudo wg genkey | tee client_privatekey | wg pubkey > client_publickey

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

sudo wg

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

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

```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

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

---


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

sudo wg-quick down wg-bigmengya
sudo wg-quick up wg-bigmengya

sudo wg

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

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