commit 0f68dc56f26621c567034bf2127e25fde292fc27 Author: ducoterra Date: Sun Dec 29 20:11:28 2019 -0500 init diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..065ac44 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,25 @@ +FROM debian:buster + +RUN 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: 90\n' > /etc/apt/preferences.d/limit-unstable + +RUN apt update && \ + apt install -y --no-install-recommends wireguard-tools iptables nano net-tools procps && \ + apt clean + +# Copy configs +COPY wg0.conf /etc/wireguard/wg0.conf +COPY sysctl.conf /etc/systctl.conf + +# generate keys +RUN cd /etc/wireguard && \ +umask 077 && \ +export PRIVKEY=$(wg genkey) && \ +echo $PRIVKEY | tee privatekey | wg pubkey | tee publickey && \ +echo $PRIVKEY | tee /etc/wireguard/wg0.conf + +RUN sysctl -p +RUN wg-quick up wg0 +RUN wg + +CMD sleep infinity \ No newline at end of file diff --git a/docker-compose.yaml b/docker-compose.yaml new file mode 100644 index 0000000..0a614c9 --- /dev/null +++ b/docker-compose.yaml @@ -0,0 +1,7 @@ +version: '3' +services: + wg: + build: . + image: ducoterra/wireguard:0.0.1 + cap_add: + - sys_module \ No newline at end of file diff --git a/sysctl.conf b/sysctl.conf new file mode 100644 index 0000000..8dedfbe --- /dev/null +++ b/sysctl.conf @@ -0,0 +1,2 @@ +net.ipv4.ip_forward=1 +net.ipv6.conf.all.forwarding=1 \ No newline at end of file diff --git a/wg0.conf b/wg0.conf new file mode 100644 index 0000000..30af5b8 --- /dev/null +++ b/wg0.conf @@ -0,0 +1,7 @@ +[Interface] +Address = 10.10.0.1/24 +Address = fd86:ea04:1111::1/64 +SaveConfig = true +PostUp = iptables -A FORWARD -i wg0 -j ACCEPT; iptables -t nat -A POSTROUTING -o ens3 -j MASQUERADE; ip6tables -A FORWARD -i wg0 -j ACCEPT; ip6tables -t nat -A POSTROUTING -o ens3 -j MASQUERADE +PostDown = iptables -D FORWARD -i wg0 -j ACCEPT; iptables -t nat -D POSTROUTING -o ens3 -j MASQUERADE; ip6tables -D FORWARD -i wg0 -j ACCEPT; ip6tables -t nat -D POSTROUTING -o ens3 -j MASQUERADE +ListenPort = 51820 \ No newline at end of file