mercoledì 18 dicembre 2024

Ubuntu 22.04 networking only using systemd-networkd

AH AH AH AH!! GODO!!!

Ubuntu 22.04: time to get rid of NetworkManager, the annoying, buggy, bloated, overrated, chaotic NetworkManager:

systemctl stop NetworkManager
apt-get remove NetworkManager

Network cards configuration files: everything will go in /etc/systemd/network except wifi WPA stuff.

Internet via wifi - identify the network card wlxxx...:

networkctl | grep wlan

Configuration file wifi.network, using dynamic addressing (DHCP), adding route metrics to let wired connections take over when needed:

[Match]
Name=wlxxx

[Network]
DHCP=yes

[DHCPv4]
RouteMetric=9

[IPv6AcceptRA]
RouteMetric=9

Configuration of WPA supplicant to let the wifi card autoconnect to myhomewifi/myhomepassword:

TMP=/etc/wpa_supplicant/wpa_supplicant-wlxxx.conf
echo ctrl_interface=/var/run/wpa_supplicant > $TMP
echo eapol_version=1                        >>$TMP
echo ap_scan=1                              >>$TMP
echo fast_reauth=1                          >>$TMP

wpa_passphrase myhomewifi myhomepassword    >>$TMP
systemctl restart wpa_supplicant@wlxxx

Ethernet configuration using static addressing, in ethernet.network - just doesn't need DHCP; DNS not actually needed here until I add a gateway:

[Match]
Name=enp1s0

[Network]
Address=192.168.1.3/24
DNS=208.67.222.222

Wireguard requires two configuration files: a wireguard.network file just for the address:

[Match]
Name=wg0

[Network]
Address=192.168.7.77/24

...and a wireguard.netdev file containing the public and private keys, IP addresses and ports; allowed IP's from anywhere because I can "phone home" via ssh on the endpoint:

[NetDev]
Name=wg0
Kind=wireguard
# this file has to be chmod 640 root.systemd-network

[WireGuard]
PrivateKey = eD0Wxxxxxxxxx...
ListenPort = 51821

[WireGuardPeer]
PublicKey = d1LZxxxxx...
AllowedIPs = 0.0.0.0/0
Endpoint = 9.9.9.9:9999

Cellphone(s) configured as USB network cards appearing as ethxa4 here and sporting static addresses; example of xa4.network file:

[Match]
Name=ethxa4

[Network]
Address=192.168.5.11/24
Gateway=192.168.5.2
DNS=1.1.1.1
DNS=9.9.9.9

Enable everything at boot, and restart to apply changes:

systemctl enable systemd-networkd
systemctl restart systemd-networkd
So long, NetworkManager. You never had anything more than systemd-networkd.

martedì 17 dicembre 2024

mercoledì 11 dicembre 2024