nixos-config/scripts/wireguard-client.sh
2024-06-06 10:31:44 +02:00

42 lines
677 B
Bash

#!/usr/bin/env bash
#
# Create a new wireguard client
client_name="iphone tina"
client_ip=10.100.0.103
private_key=$(wg genkey)
public_key=$(echo "$private_key" | wg pubkey)
cat <<EOF >client.conf
[Interface]
Address = ${client_ip}/32
MTU = 1280
ListenPort = 51820
PrivateKey = ${private_key}
[Peer]
PublicKey = txECSpa5HeIWgRtcZNxBUzkdN72rsA2w6Is6gIp0Tlc=
Endpoint = ingolf-wagner.de:51820
AllowedIPs = 10.100.0.1/24
EOF
cat <<EOF
## nixos configuration:
{
# ${client_name}
publicKey = "${public_key}";
allowedIPs = [ "${client_ip}/32" ];
}
## client configuration
is in ./client.conf
### QR Code
for quick configuration
EOF
qrencode -t ansiutf8 <client.conf