From 04f38ee09b5ad6b8eac1655335ebd456bacea7dc Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Thu, 19 Nov 2020 19:49:00 +0100 Subject: [PATCH] [openwrt] add script to only configure the wireguard vpn --- openwrt-add-wireguard.sh | 63 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100755 openwrt-add-wireguard.sh diff --git a/openwrt-add-wireguard.sh b/openwrt-add-wireguard.sh new file mode 100755 index 0000000..d44d9e9 --- /dev/null +++ b/openwrt-add-wireguard.sh @@ -0,0 +1,63 @@ +#!/bin/sh +# Nico Schottelius +# 2020-11-19 + +if [ $# -lt 4 ]; then + echo "$0 ip-address vpn-server ipv6-network [privatekey]" + echo " ip-address: where to find the OpenWRT device" + echo " vpn-server: where to connect to" + echo " vpn-server-pubkey: public key of the server" + echo " ipv6-network: which network to use for us (/48 expected)" + echo " private-key: specify wireguard key optionally" + exit 1 +fi + +my_ip=$1; shift +vpn_endpoint_host=$1; shift +vpn_endpoint_pubkey=$1; shift +network=$1; shift + +# wireguard +if [ $# -eq 1 ]; then + private_key=$1; shift +else + private_key=$(wg genkey) +fi + +my_prefix=$(echo $network | sed 's,::/.*,,') +my_wireguard_ip=${my_prefix}::42 + +public_key=$(echo $private_key | wg pubkey) + +cat <