bin/addtovpn: init
This commit is contained in:
parent
7c79b16e22
commit
de54096f14
1 changed files with 31 additions and 0 deletions
31
bin/addtovpn.sh
Executable file
31
bin/addtovpn.sh
Executable file
|
@ -0,0 +1,31 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
name=$1
|
||||||
|
number=$2
|
||||||
|
address="192.168.200.$number/32"
|
||||||
|
|
||||||
|
private=$(wg genkey)
|
||||||
|
public=$(echo "$private" | wg pubkey)
|
||||||
|
psk=$(wg genpsk)
|
||||||
|
|
||||||
|
cat << EOF > /tmp/$name.conf
|
||||||
|
[Interface]
|
||||||
|
Address = $address
|
||||||
|
PrivateKey = $private
|
||||||
|
DNS = 1.1.1.1
|
||||||
|
|
||||||
|
[Peer]
|
||||||
|
PublicKey = $(cat /etc/secrets/wireguard/public)
|
||||||
|
PresharedKey = $psk
|
||||||
|
Endpoint = vpn.inx.moe:51820
|
||||||
|
AllowedIPs = 0.0.0.0/0
|
||||||
|
EOF
|
||||||
|
|
||||||
|
cat << EOF >> /tmp/wireguard-config.nix
|
||||||
|
{
|
||||||
|
name = "$name";
|
||||||
|
publicKey = "$public";
|
||||||
|
presharedKey = "$psk";
|
||||||
|
allowedIPs = ip $number;
|
||||||
|
}
|
||||||
|
EOF
|
Loading…
Add table
Add a link
Reference in a new issue