wireguard

系统 ubuntu16

sudo apt-get install libmnl-dev libelf-dev linux-headers-$(uname -r) build-essential pkg-config git
git clone https://git.zx2c4.com/WireGuard
cd WireGuard/src
make
make install

cd ~
mkdir wg
cd wg
wg genkey | tee private | wg pubkey > public
cat private
cat public
[Interface]
PrivateKey = 你的私钥
Address = 10.10.10.1/24
ListenPort = 54321
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

[Peer]
PublicKey = 客户端公钥
AllowedIPs = 10.10.10.2/32

vi /etc/sysctl.conf

net.ipv4.ip_forward = 1

posted on 2022-03-16 11:03  开心种树  阅读(255)  评论(0编辑  收藏  举报