WireGuard搭建(第二套)

WirgerGuard一键搭建

Linux系统Ubuntu17.10(Vultr机主: https://www.vultr.com/

1:设置添加net.ipv4.ip_forward=1

sudo vi /etc/sysctl.conf
添加:
net.ipv4.ip_forward=1
运行:
sudo sysctl -p

2:安装

https://www.wireguard.com/install/

3:生成密钥

wg genkey | tee privatekey | wg pubkey > publickey

#查看私钥
cat privatekey
#查看公钥
cat publickey

服务端

    私钥:+APhXtu7QecMjC9M7Nv1y3XpvuVIgOSo0SO0BOYZuUw=
    公钥:OAoGS1iYKde4Pp7achtGo/RaJBQMh3RjW3IKJKyB40I=

客户端
    私钥:8HSW0qtVL/hkj/oN8eSAmMiSggM6uGfCew1qamMQMXs=
    公钥:/n83sQyNxrj6wgkTR/XyAfUJSmmoMDkw/e8/gQjLfj8=

4:服务端配置文件

查看interface,替换配置文件里的eth0:

    ifconfig

sudo vim /etc/wireguard/wg0.conf

内容:

    [Interface]
    Address = 192.168.2.1/24
    PostUp = iptables -A FORWARD -i wg0 -j ACCEPT; iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
    PostDown = iptables -D FORWARD -i wg0 -j ACCEPT; iptables -t nat -D POSTROUTING -o eth0 -j MASQUERADE
    ListenPort = 51820
    PrivateKey = +APhXtu7QecMjC9M7Nv1y3XpvuVIgOSo0SO0BOYZuUw=

    [Peer]
    PublicKey = /n83sQyNxrj6wgkTR/XyAfUJSmmoMDkw/e8/gQjLfj8=
    AllowedIPs = 10.0.2.1/24


启动:

    sudo wg-quick up wg0

WireGuard搭建(第二套)》有4个想法

发表评论