Created
June 6, 2019 19:12
Wireguard client/server config generator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -eu | |
set -o pipefail | |
dns_server=172.24.100.250 | |
client_ip=$1 | |
psk=$(wg genpsk) | |
client_privkey=$(wg genkey) | |
client_pubkey=$(wg pubkey <<<"$client_privkey") | |
server_pubkey=$(cat publickey) | |
server_endpoint=$(cat endpoint) | |
client_config=" | |
[Interface] | |
PrivateKey = $client_privkey | |
Address = $client_ip | |
DNS = $dns_server | |
[Peer] | |
PublicKey = $server_pubkey | |
AllowedIPs = 172.16.0.0/12, 192.168.0.0/16, 10.0.0.0/8 | |
Endpoint = $server_endpoint | |
PresharedKey = $psk | |
" | |
cat <<EOF | |
[Peer] | |
AllowedIPs=$client_ip/32 | |
PublicKey=$client_pubkey | |
PresharedKey=$psk | |
EOF | |
qrencode -tansiutf8 <<< "$client_config" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment