WireGuard
- 0
#讨论区
00条评论
实时对话
loading...
最近将所有服务器更换为Debian,并在其上安装WireGuard
首先访问WireGuard官方网站获取安装信息:https://www.wireguard.com/install/#installation
bash
bash
bash
bash
bash
wg0.conf
文件中的PrivateKey
字段。ini
bash
bash
bash
ini
利用wireguard实现远程访问家里网络内任意设备
我是在openwrt
上安装的wireguard
,你也可以在家里其他路由器上安装
bash
如果该命令返回 net.ipv4.ip_forward = 1,那么 IP 转发功能已经启用了。如果没有,需要修改/etc/sysctl.conf
,在该文件中添加
bash
然后,运行sysctl -p
命令应用更改。
待完善
apt update
apt install wireguard
cd /etc/wireguard/
umask 077
wg genkey > server.key
wg pubkey < server.key > server.key.pub
vim /etc/wireguard/wg0.conf
[Interface]
Address = 192.168.0.1/16
PostUp = iptables -A FORWARD -i %i -j ACCEPT;iptables -A FORWARD -o %i -j ACCEPT; iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
PostDown = iptables -D FORWARD -i %i -j ACCEPT;iptables -D FORWARD -o %i -j ACCEPT; iptables -t nat -D POSTROUTING -o eth0 -j MASQUERADE
ListenPort = 51820
PrivateKey = {Server_PrivateKey}
[Peer]
PublicKey = {Client1_PublicKey}
AllowedIPs = 192.168.0.2/32
PersistentKeepalive = 25
[Peer]
PublicKey = {Client2_PublicKey}
AllowedIPs = 192.168.0.3/32
PersistentKeepalive = 25
sudo wg-quick up wg0
sudo wg-quick down wg0
sudo wg show
vim /etc/wireguard/wg0.conf
wg genkey > client.key
wg pubkey < client.key > client.key.pub
[Interface]
PrivateKey = {Client_PrivateKey}
Address = 192.168.0.2/16
[Peer]
PublicKey = {Server_PublicKey}
Endpoint = {Server_IP}:51820
AllowedIPs = 192.168.0.0/16
PersistentKeepalive = 25
sysctl net.ipv4.ip_forward
net.ipv4.ip_forward=1