#!/bin/bash -e address=$(ip address show dev eth0 scope global | grep -F 'inet ' | perl -pe 's#.*inet (.*?)/.*#$1#') gateway=$(ip route list dev eth0 default | perl -pe 's#.*via (.*) #$1#') # $interface differs from the live system because of different naming schemes # see https://wiki.debian.org/NetworkInterfaceNames for more details interface='enp35s0' echo "[Match] Name=$interface [Network] Gateway=$gateway Address=116.202.199.132/32 Address=116.202.199.133/32 Address=116.202.199.134/32 Address=116.202.199.141/32 Address=116.202.199.142/32 Address=116.202.199.143/32 Address=176.9.141.113/32 Address=176.9.141.119/32 Address=176.9.141.124/32 Address=176.9.141.125/32 Address=5.9.203.242/32 Address=5.9.203.246/32 Address=5.9.203.247/32 [Address] Address=${address}/32 Peer=${gateway}/32" > "/etc/systemd/network/${interface}.network"