wireguard: use custom wg-quick

This removes things we do not need and expects the interface to
already be created.

Signed-off-by: Justin Cormack <justin.cormack@docker.com>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
This commit is contained in:
Jason A. Donenfeld 2017-08-23 17:02:58 +01:00
parent ed8d367e2a
commit 8f3847e985
5 changed files with 24 additions and 14 deletions

View File

@ -1,5 +1,5 @@
kernel:
image: linuxkit/kernel:4.9.43
image: linuxkit/kernel:4.9.49
cmdline: "console=tty0 console=ttyS0 console=ttyAMA0"
init:
- linuxkit/init:6d11a1f9d299d3425e78cce80dfba8b236d20412
@ -13,11 +13,11 @@ onboot:
image: linuxkit/dhcpcd:f3f5413abb78fae9020e35bd4788fa93df4530b7
command: ["/sbin/dhcpcd", "--nobackground", "-f", "/dhcpcd.conf", "-1"]
- name: wg0
image: linuxkit/ip:b084fd2ada446015e00e43a441bb0ae41ff8b227
image: linuxkit/ip:044287be54a62d1590dcd4d22543c1a1031479e6
net: new
binds:
- /etc/wireguard:/etc/wireguard
command: ["sh", "-c", "ip link set dev wg0 up; ip address add dev wg0 192.168.2.1/24; wg setconf wg0 /etc/wireguard/wg0.conf; wg show wg0"]
command: ["/usr/bin/lk-wg-config", "configure", "/etc/wireguard/wg0.conf"]
runtime:
interfaces:
- name: wg0
@ -26,11 +26,11 @@ onboot:
bindNS:
net: /run/netns/wg0
- name: wg1
image: linuxkit/ip:b084fd2ada446015e00e43a441bb0ae41ff8b227
image: linuxkit/ip:044287be54a62d1590dcd4d22543c1a1031479e6
net: new
binds:
- /etc/wireguard:/etc/wireguard
command: ["sh", "-c", "ip link set dev wg1 up; ip address add dev wg1 192.168.2.2/24; wg setconf wg1 /etc/wireguard/wg1.conf; wg show wg1"]
command: ["/usr/bin/lk-wg-config", "configure", "/etc/wireguard/wg1.conf"]
runtime:
interfaces:
- name: wg1
@ -40,7 +40,7 @@ onboot:
net: /run/netns/wg1
services:
- name: getty
image: linuxkit/getty:797cb79e0a229fcd16ebf44a0da74bcec03968ec
image: linuxkit/getty:48870d0f92c65fecd6ddb18004d68d85f9b9cde3
env:
- INSECURE=true
net: /run/netns/wg1
@ -58,7 +58,9 @@ services:
files:
- path: etc/wireguard/wg0.conf
contents: |
[Interface]
[Interface]
Address = 192.168.2.1/24
DNS = 192.168.2.2
PrivateKey = KG7EKkHDkp7THfW5mOXcZzo3RbGAjq+ARMfJGFm5G1s=
ListenPort = 51820
[Peer]
@ -68,6 +70,7 @@ files:
- path: etc/wireguard/wg1.conf
contents: |
[Interface]
Address = 192.168.2.2/24
PrivateKey = SCGCKDuTm4PMOw+LXdK/2s8mxnv145QHOohKRq3vc2A=
ListenPort = 51821
[Peer]

View File

@ -1,4 +1,4 @@
FROM linuxkit/alpine:87a0cd10449d72f374f950004467737dbf440630 AS mirror
FROM linuxkit/alpine:1e67b8fdba849ed2f7e8537c13b7f280639623d6 AS mirror
RUN mkdir -p /out/etc/apk && cp -r /etc/apk/* /out/etc/apk/
RUN apk add --no-cache --initdb -p /out \

View File

@ -1,5 +1,6 @@
FROM linuxkit/alpine:a120ad6aead3fe583eaa20e9b75a05ac1b3487da AS mirror
FROM linuxkit/alpine:1e67b8fdba849ed2f7e8537c13b7f280639623d6 AS mirror
RUN mkdir -p /out/etc/apk && cp -r /etc/apk/* /out/etc/apk/
RUN apk add curl
RUN apk add --no-cache --initdb -p /out \
alpine-baselayout \
bash \
@ -8,6 +9,9 @@ RUN apk add --no-cache --initdb -p /out \
musl \
wireguard-tools
# We grab our version of wg-quick, called lk-wg-config.sh
RUN curl -sSL -o /out/usr/bin/lk-wg-config https://gist.githubusercontent.com/zx2c4/3624de869ab7eaef3de5ea8f2b867be9/raw/de72b018f4f4548858ce6aae2898b34db0474221/lk-wg-config.sh && chmod 755 /out/usr/bin/lk-wg-config
# Remove apk residuals
RUN rm -rf /out/etc/apk /out/lib/apk /out/var/cache

View File

@ -1,3 +1,4 @@
IMAGE=ip
NETWORK=1
include ../package.mk

View File

@ -11,11 +11,11 @@ onboot:
image: linuxkit/dhcpcd:f3f5413abb78fae9020e35bd4788fa93df4530b7
command: ["/sbin/dhcpcd", "--nobackground", "-f", "/dhcpcd.conf", "-1"]
- name: wg0
image: linuxkit/ip:b084fd2ada446015e00e43a441bb0ae41ff8b227
image: linuxkit/ip:044287be54a62d1590dcd4d22543c1a1031479e6
net: new
binds:
- /etc/wireguard:/etc/wireguard
command: ["sh", "-c", "ip link set dev wg0 up; ip address add dev wg0 192.168.2.1/24; wg setconf wg0 /etc/wireguard/wg0.conf; wg show wg0"]
command: ["/usr/bin/lk-wg-config", "configure", "/etc/wireguard/wg0.conf"]
runtime:
interfaces:
- name: wg0
@ -24,11 +24,11 @@ onboot:
bindNS:
net: /run/netns/wg0
- name: wg1
image: linuxkit/ip:b084fd2ada446015e00e43a441bb0ae41ff8b227
image: linuxkit/ip:044287be54a62d1590dcd4d22543c1a1031479e6
net: new
binds:
- /etc/wireguard:/etc/wireguard
command: ["sh", "-c", "ip link set dev wg1 up; ip address add dev wg1 192.168.2.2/24; wg setconf wg1 /etc/wireguard/wg1.conf; wg show wg1"]
command: ["/usr/bin/lk-wg-config", "configure", "/etc/wireguard/wg1.conf"]
runtime:
interfaces:
- name: wg1
@ -66,7 +66,8 @@ services:
files:
- path: etc/wireguard/wg0.conf
contents: |
[Interface]
[Interface]
Address = 192.168.2.1/24
PrivateKey = KG7EKkHDkp7THfW5mOXcZzo3RbGAjq+ARMfJGFm5G1s=
ListenPort = 51820
[Peer]
@ -76,6 +77,7 @@ files:
- path: etc/wireguard/wg1.conf
contents: |
[Interface]
Address = 192.168.2.2/24
PrivateKey = SCGCKDuTm4PMOw+LXdK/2s8mxnv145QHOohKRq3vc2A=
ListenPort = 51821
[Peer]