= Setup


== Intro

networkd is a small and lean service to configure network interfaces, designed mostly for server use cases in a world with hotplugged and virtualized networking. Its configuration is similar in spirit and abstraction level to ifupdown, but you don't need any extra packages to configure bridges, bonds, vlan etc. It is not very suitable for managing WLANs yet; NetworkManager is still much more appropriate for such Desktop use cases.

== Install systemd-networkd

=== deinstall classic networking and install it!

* *sudo su*   # if not already done

.deinstall
[source,sh]
----
systemctl daemon-reload
systemctl disable --now ifupdown dhcpcd dhcpcd5 isc-dhcp-client isc-dhcp-common rsyslog
apt --autoremove purge -f ifupdown dhcpcd dhcpcd5 isc-dhcp-client isc-dhcp-common rsyslog
rm -r /etc/network /etc/dhcp

# setup/enable systemd-resolved and systemd-networkd

systemctl disable --now avahi-daemon libnss-mdns
apt --autoremove -f purge avahi-daemon
apt install -f libnss-resolve
ln -sf /run/systemd/resolve/stub-resolv.conf /etc/resolv.conf
apt-mark hold avahi-daemon dhcpcd dhcpcd5 ifupdown isc-dhcp-client isc-dhcp-common libnss-mdns openresolv raspberrypi-net-mods rsyslog
systemctl enable systemd-networkd.service systemd-resolved.service
----

=== setup wired connection

.wired connection
[source,sh]
----
cat > /etc/systemd/network/04-wired.network <<EOF
[Match]
Name=e*

[Network]
## Uncomment only one option block
# Option: using a DHCP server and multicast DNS
LLMNR=no
LinkLocalAddressing=no
MulticastDNS=yes
DHCP=ipv4

# Option: using link-local ip addresses and multicast DNS
#LLMNR=no
#LinkLocalAddressing=yes
#MulticastDNS=yes

# Option: using static ip address and multicast DNS
Address=192.168.1.18/24 // <1>
Gateway=192.168.1.1     // <2>
DNS=8.8.8.8 1.1.1.1     // <3>
MulticastDNS=yes
EOF
----
<1> use your settings
<2> use your settings
<2> use your settings


=== Reboot

NOTE: reboot

== Config 


=== NSS

.config nss
[source,sh]
----
apt --autoremove purge avahi-daemon
apt-mark hold avahi-daemon
apt install -f libnss-resolve

echo ""
echo "For troubleshooting you may have a look at /etc/nsswitch.conf. It should contain a line like this:"
echo ""
echo "hosts:          files resolve [!UNAVAIL=return] dns"
echo ""
echo ""
echo ""
echo ""
----


=== DNS


.config dns
[source,sh]
----

echo ""
echo "Configure DNS stub listener interface"
echo ""

echo "Here we have to symlink /etc/resolv.conf to the stub listener:"
echo ""
echo " exec4you ln -sf /run/systemd/resolve/stub-resolv.conf /etc/resolv.conf"
ln -sf /run/systemd/resolve/stub-resolv.conf /etc/resolv.conf
echo ""

echo "Check name resolution"


resolvectl status
----



