34 lines
688 B
Bash
34 lines
688 B
Bash
echo Client Name:
|
|
read name
|
|
echo Client Matching IP: \(10.10.0.?\)
|
|
read ip
|
|
echo Server PubKey:
|
|
read server_pubkey
|
|
|
|
mkdir $name
|
|
cd $name
|
|
export PRIVKEY=$(wg genkey)
|
|
echo $PRIVKEY | tee $name"_privkey"
|
|
export PUBKEY=$(echo $PRIVKEY | wg pubkey)
|
|
echo $PUBKEY | tee $name"_pubkey"
|
|
|
|
cat > $name".conf" <<EOF
|
|
[Interface]
|
|
PrivateKey = $PRIVKEY
|
|
Address = 10.10.0.$ip/32, fd86:ea04:1111::$ip/128
|
|
DNS = 3.14.2.100
|
|
|
|
[Peer]
|
|
PublicKey = $server_pubkey
|
|
Endpoint = wireguard.ducoterra.net:51820
|
|
AllowedIPs = 0.0.0.0/0, ::/0
|
|
EOF
|
|
|
|
cat >> /etc/wireguard/wg0.conf <<EOF
|
|
[Peer]
|
|
PublicKey = $PUBKEY
|
|
AllowedIPs = 10.10.0.$ip/32
|
|
EOF
|
|
|
|
wg set wg0 peer $PUBKEY allowed-ips 10.10.0.$ip/32,fd86:ea04:1111::$ip/128
|
|
wg |