Skip to content

Instantly share code, notes, and snippets.

@stvhay
Created October 7, 2022 08:44
Show Gist options
  • Save stvhay/885db7b55783a85a612f5ff10333d2b9 to your computer and use it in GitHub Desktop.
Save stvhay/885db7b55783a85a612f5ff10333d2b9 to your computer and use it in GitHub Desktop.
Linode Network Setup with systemd-networkd

Linode Network Setup with systemd-networkd

When you get into having multiple subnets routed to your machine, you have to turn off Linode's automatic network configuration service and do it yourself. This example is using systemd-networkd.

/etc/systemd/network/99-default.link

# This machine is most likely a virtualized guest, where the old persistent
# network interface mechanism (75-persistent-net-generator.rules) did not work.
# This file disables /lib/systemd/network/99-default.link to avoid
# changing network interface names on upgrade. Please read
# /usr/share/doc/udev/README.Debian.gz about how to migrate to the currently
# supported mechanism.

/etc/systemd/network/50-virtio-kernel-names.link

# udev 226 introduced predictable interface names for virtio;
# disable this for upgrades. You can remove this file if you update your
# network configuration to move to the ens* names instead.
# See /usr/share/doc/udev/README.Debian.gz for details about predictable
# network interface names.
[Match]
Driver=virtio_net

[Link]
NamePolicy=onboard kernel

/etc/systemd/network/99-wg0.netdev

[NetDev]
Name=wg0
Kind=wireguard
Description=WireGuard tunnel wg0

[WireGuard]
ListenPort=51820
PrivateKey=

# Macbook 16
[WireGuardPeer]
PublicKey = 
AllowedIPs = 10.251.0.101/32, 2a06:a004:c019:3::101/128

# cell phone
[WireGuardPeer]
PublicKey = 
AllowedIPs = 10.251.0.102/32, 2a06:a004:c019:3::102/128

# blue-ridge-mountains
[WireGuardPeer]
PublicKey = 
AllowedIPs = 192.168.1.0/24, 2a06:a004:c019::/48, 2600:3c03:e002:a000::/56
PersistentKeepalive = 25

/etc/systemd/network/99-wg0.network

[Match]
Name=wg0

[Network]
Address=10.251.0.1/25
Address=2600:3c03:e002:a201::1/64
Address=2a06:a004:c019:3::2/64

# Home
[Route]
Destination=2a06:a004:c019::/48
Scope=link

# Home v4
[Route]
Destination=192.168.1.0/24
Scope=link

/etc/systemd/network/05-eth0.network

#  - https://cloud.linode.com/linodes/29863617/advanced
#
# For more information on Network Helper:
#  - https://www.linode.com/docs/platform/network-helper
#
# A backup of the previous config is at /etc/systemd/network/.05-eth0.network.linode-last
# A backup of the original config is at /etc/systemd/network/.05-eth0.network.linode-orig
#
# /etc/systemd/network/05-eth0.network

[Match]
Name=eth0

[Network]
DHCP=no
DNS=139.162.135.5 139.162.131.5 139.162.137.5
Domains=members.linode.com
IPv6PrivacyExtensions=false
#IPv6AcceptRA=false

Gateway=198.74.58.1
Address=198.74.58.28/24

[Address]
Address=2600:3c03:e000:0381::1/64
#HomeAddress=true

[Route]
Destination=::/0
Gateway=fe80::1
PreferredSource=2600:3c03:e000:0381::1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment