To connect to network through systemd-networkd you need to create some configuration files:
For wireless connections create wireless.network file with the following content:
nano /etc/systemd/wireless.network:
Match]
Name=wlan0
[Network]
DHCP=ipv4
DNS=8.8.8.8
DNS=8.8.4.4
[DHCP]
RouteMetric=20
For wired connections create wired.network file with the following content:
nano /etc/systemd/network/wired.network :
[Match]
Name=eth0
[Network]
DHCP=ipv4
DNS=8.8.8.8
DNS=8.8.4.4
[DHCP]
RouteMetric=10
For wireless connections, create a configuration file for your access point by using:
sudo -i
echo "ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=sudo" > /etc/wpa_supplicant/wpa_supplicant-wlan0.conf
wpa_passphrase SSID password >> /etc/wpa_supplicant/wpa_supplicant-wlan0.conf
exit
disable network-manager:
sudo systemctl disable NetworkManager
Enable systemd-networkd :
sudo systemctl enable systemd-networkd
Enable the systemd-resolved :
sudo systemctl enable systemd-resolved
sudo systemctl start systemd-resolved
delete or rename resolv.conf then create a symlink to /etc/resolv.conf:
sudo ln -s /run/systemd/resolve/resolv.conf /etc/resolv.conf
Restart the srvice:
systemctl restart systemd-networkd
Reboot
Type the following command
root@root:~# sudo systemctl status systemd-networkd
The output:
● systemd-networkd.service - Network Service
Loaded: loaded (/lib/systemd/system/systemd-networkd.service; enabled)
Active: active (running) since lun. 2016-02-29 13:42:53 CET; 35min ago
Docs: man:systemd-networkd.service(8)
Main PID: 531 (systemd-network)
Status: "Processing requests..."
CGroup: /system.slice/systemd-networkd.service
└─531 /lib/systemd/systemd-networkd
févr. 29 13:42:53 debian systemd-networkd[531]: wlan0 : gained carrier
févr. 29 13:42:53 debian systemd-networkd[531]: lo : gained carrier