-
-
Save guerrerocarlos/ecd205ca21caa7c40ca9fb820aba0314 to your computer and use it in GitHub Desktop.
Wireguard client/server config generator
This file contains hidden or 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