1
0
mirror of https://github.com/vimagick/dockerfiles.git synced 2024-12-10 11:10:27 +02:00
dockerfiles/wireguard
2019-07-10 04:08:34 +08:00
..
data add wireguard 2019-07-10 04:08:34 +08:00
docker-compose.yml add wireguard 2019-07-10 04:08:34 +08:00
Dockerfile add wireguard 2019-07-10 04:08:34 +08:00
README.md add wireguard 2019-07-10 04:08:34 +08:00

wireguard

Install Kernel Module

$ apt update
$ apt install -y dirmngr raspberrypi-kernel-headers
$ echo 'deb http://deb.debian.org/debian/ unstable main' > /etc/apt/sources.list.d/unstable-wireguard.list
$ printf 'Package: *\nPin: release a=unstable\nPin-Priority: 150\n' > /etc/apt/preferences.d/limit-unstable
$ apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 04EE7237B7D453EC
$ apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 648ACFD622F3D138
$ apt update
$ apt install -y wireguard-dkms
$ modprobe wireguard
$ lsmod | grep wireguard

Generate Keys

$ umask 077
$ wg genkey | tee privatekey | wg pubkey > publickey

Create Config

[Interface]
Address = 192.168.32.1/24
ListenPort = 51820
PrivateKey = SMDPkZPE6R9VyqT3ucxE5v//GnIzzruYC0MPD5efr3w=
PostUp = iptables -t nat -A POSTROUTING -s 192.168.32.0/24 -j MASQUERADE; iptables -t filter -A FORWARD -j ACCEPT
PreDown = iptables -t nat -D POSTROUTING -s 192.168.32.0/24 -j MASQUERADE; iptables -t filter -D FORWARD -j ACCEPT

# [Peer]
# PublicKey = VMK48tEcTLBwzxS+2gx3MH4IRlE7upTKPkYIE/xa7S0=
# AllowedIPs = 192.168.32.2/32