dn42/scripts/addinternal.sh
2020-04-04 17:31:43 +02:00

50 lines
955 B
Bash

#!/bin/bash
source vars.sh
read -p "Interface > " iface
read -p "Local WG ListenPort > " port
read -p "Peer WG Pubkey > " pubkey
read -p "Peer WG Endpoint > " endpoint
read -p "Peer DN42 IPv4 > " tun4
read -p "Peer DN42 IPv6 > " tun6
read -p "Peer node hostname > " host
node="AS${asn}_${mynick}_${host}"
sudo tee -a /etc/systemd/network/$iface.netdev << END
[NetDev]
Name = $iface
Kind = wireguard
Description = WireGuard
[WireGuard]
ListenPort = $port
PrivateKeyFile = /etc/wireguard/private.key
[WireGuardPeer]
PublicKey = $pubkey
Endpoint = $endpoint
AllowedIPs = 172.16.0.0/12,10.0.0.0/8,fd00::/8,fe80::/10,ff00::/8
END
sudo tee -a /etc/systemd/network/$iface.network << END
[Match]
Name = $iface
[Address]
Address = $int6/128
Peer = $tun6/128
[Address]
Address = $ip4/32
Peer = $tun4/32
END
sudo tee -a /etc/bird/peers/$node.conf << END
protocol bgp ${node} from ipeers {
neighbor $tun6%$iface;
}
END