Created
December 19, 2023 22:48
-
-
Save 7marcus9/7e70781671a1bfbb811f5af802babaed to your computer and use it in GitHub Desktop.
Script to create P2P Wiregaurd Config
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
privA=$(wg genkey) | |
privB=$(wg genkey) | |
pubA=$(echo $privA | wg pubkey) | |
pubB=$(echo $privB | wg pubkey) | |
echo Public IP A: | |
read publicIPA | |
echo Public Port A | |
read publicPortA | |
echo Private IPv4 A | |
read privateIPv4A | |
echo Private IPv4 B | |
read privateIPv4B | |
echo Private IPv6 A | |
read privateIPv6A | |
echo Private IPv6 B | |
read privateIPv6B | |
echo | |
echo ====================================================== | |
echo | |
cat << EOF | |
[Interface] | |
ListenPort = $publicPortA | |
PrivateKey = $privA | |
PostUp = /sbin/ip addr add dev %i $privateIPv4A/32 peer $privateIPv4B/32 | |
PostUp = /sbin/ip addr add dev %i $privateIPv6A/128 peer $privateIPv6B/128 | |
Table = off | |
[Peer] | |
PublicKey = $pubB | |
AllowedIPs = 0.0.0.0/0, ::/0 | |
EOF | |
echo | |
echo ====================================================== | |
echo | |
cat << EOF | |
[Interface] | |
PrivateKey = $privB | |
PostUp = /sbin/ip addr add dev %i $privateIPv4B/32 peer $privateIPv4A/32 | |
PostUp = /sbin/ip addr add dev %i $privateIPv6B/128 peer $privateIPv6A/128 | |
Table = off | |
[Peer] | |
Endpoint = $publicIPA:$publicPortA | |
PublicKey = $pubA | |
AllowedIPs = 0.0.0.0/0, ::/0 | |
PersistentKeepalive = 15 | |
EOF | |
echo | |
echo ====================================================== | |
echo |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment