ansible/setup-additional-wireguard-...

31 lines
752 B
Bash
Raw Normal View History

#!/bin/bash
WG_KEY_SERVER=$(wg showconf wg0 | grep PrivateKey | awk '{ print $3 }' | wg pubkey)
WG_KEY_PRIVATE=$(wg genkey)
WG_KEY_PUBLIC=$(echo $WG_KEY_PRIVATE | wg pubkey)
echo "
----------
Update the name and ip below and then add to the 'host_vars/dispatcher' file
wg_additional_host_keys:
- name: name
public_key: $WG_KEY_PUBLIC
wireguard_ip: 192.168.254.n
wireguard_persistent_keepalive: 30
----------
Use the following wireguard config on the new client
Update the server endpoint IP in Peer and the Interface Address
[Interface]
PrivateKey = $WG_KEY_PRIVATE
ListenPort = 51820
Address = 192.168.254.n/32
[Peer]
PublicKey = $WG_KEY_SERVER
AllowedIPs = 192.168.254.0/24
Endpoint = ip:51821
PersistentKeepalive = 30
----------
"