diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2018-05-15 02:26:55 +0200 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2018-05-15 02:26:55 +0200 |
commit | 2f34f3efe7dc720d86c107eabf5ce6e09d93c2e8 (patch) | |
tree | f5c0220370e5a02082e3580a9d23968b7ddacd25 /contrib/ncat-client-server/client-quick.sh | |
parent | wg-quick: add darwin implementation (diff) | |
download | wireguard-tools-2f34f3efe7dc720d86c107eabf5ce6e09d93c2e8.tar.xz wireguard-tools-2f34f3efe7dc720d86c107eabf5ce6e09d93c2e8.zip |
ncat-client-server: add wg-quick variant
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'contrib/ncat-client-server/client-quick.sh')
-rwxr-xr-x | contrib/ncat-client-server/client-quick.sh | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/contrib/ncat-client-server/client-quick.sh b/contrib/ncat-client-server/client-quick.sh new file mode 100755 index 0000000..25ff615 --- /dev/null +++ b/contrib/ncat-client-server/client-quick.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-2.0 +# +# Copyright (C) 2015-2018 Jason A. Donenfeld <Jason@zx2c4.com>. All Rights Reserved. + +set -e + +echo "[!] Warning: This server is for testing purposes only. You may not use this server for abusive or illegal purposes." + +echo "[+] Generating private key." +privatekey="$(wg genkey)" + +echo "[+] Sending public key to server." +exec 7<>/dev/tcp/demo.wireguard.com/42912 +wg pubkey <<<"$privatekey" >&7 + +echo "[+] Parsing server response." +IFS=: read -r status server_pubkey server_port internal_ip <&7 +[[ $status == OK ]] || exit 1 + +echo "[+] Writing config file." +sudo sh -c 'umask 077; mkdir -p /etc/wireguard; cat > /etc/wireguard/demo.conf' <<_EOF +[Interface] +PrivateKey = $privatekey +Address = $internal_ip/24 +DNS = 8.8.8.8, 8.8.4.4, 1.1.1.1, 1.0.0.1 + +[Peer] +PublicKey = $server_pubkey +Endpoint = demo.wireguard.com:$server_port +AllowedIPs = 0.0.0.0/0 +_EOF + +echo "[+] Success. Run \`wg-quick up demo\` to turn on the tunnel to the demo server and \`wg-quick down demo\` to turn it off." |