Linux Networkd(systemd-networkd)

Posted on Sep 13, 2024
Linux Networkd(systemd-networkd) & wpa_supplicant

DESCRIPTION

enable and start systemd-networkd sudo systemctl enable --now systemd-networkd

systemd-networkd config file in /etc/systemd/network/ directory.

DHCP

/etc/systemd/network/eno1.network

[Match]
Name=eno1

[Network]
DHCP=ipv4
IPv6AcceptRA=yes

STATIC IP

/etc/systemd/network/wlp1s0.network

[Match]
Name=wlp1s0

[Network]
# DHCP=yes
IPv6AcceptRA=yes
Domains=farm.net
Address=10.20.2.11/16
DNS=10.20.0.1

[Route]
Gateway=10.20.0.1
Metric=300

BRIDGE

/etc/systemd/network/bridge0.netdev

[NetDev]
Name=bridge0
Kind=bridge
MACAddress=3c:52:82:01:fd:3f

/etc/systemd/network/bridge0.network

[Match]
Name=bridge0

[Network]
DHCP=yes
IPv6AcceptRA=yes
Domains=farm.net
DNS=10.20.0.1

/etc/systemd/network/wlp1s0.network

[Match]
Name=wlp1s0

[Network]
Bridge=bridge0

WPA_SUPPLICANT

/etc/wpa_supplicant/wpa_supplicant-wlp1s0.conf

ctrl_interface=/run/wpa_supplicant

update_config=1
network={
    ssid="ASUS"
    key_mgmt=NONE
}

/usr/lib/systemd/system/[email protected]

[Unit]
Description=WPA supplicant daemon (for interface %I)
Requires=sys-subsystem-net-devices-%i.device
After=sys-subsystem-net-devices-%i.device
Before=network.target
Wants=network.target
# NetworkManager users will probably want the dbus version instead.
[Service]
Type=simple
ExecStart=/usr/sbin/wpa_supplicant -c/etc/wpa_supplicant/wpa_supplicant-%I.conf -i%I
ExecReload=/bin/kill -HUP $MAINPID

[Install]
WantedBy=multi-user.target

start wpa_supplicant service sudo systemctl enable --now wpa_supplicant@wlp1s0