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 | 4884b45a70e10c8ea78d0c02888ef3c8bc768ce3 (patch) | |
tree | 4e5ae4fc8ce8af3e7b91b996ffb0e78dcae3647f /contrib/examples/ncat-client-server/client-quick.sh | |
parent | wg-quick: add darwin implementation (diff) | |
download | wireguard-monolithic-historical-4884b45a70e10c8ea78d0c02888ef3c8bc768ce3.tar.xz wireguard-monolithic-historical-4884b45a70e10c8ea78d0c02888ef3c8bc768ce3.zip |
ncat-client-server: add wg-quick variant
Diffstat (limited to '')
-rwxr-xr-x | contrib/examples/ncat-client-server/client-quick.sh | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/contrib/examples/ncat-client-server/client-quick.sh b/contrib/examples/ncat-client-server/client-quick.sh new file mode 100755 index 0000000..25ff615 --- /dev/null +++ b/contrib/examples/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." |