Para se conectar à rede através do systemd-networkd você precisa criar alguns arquivos de configuração:
Para conexões sem fio, crie o arquivo wireless.network com o seguinte conteúdo:
nano /etc/systemd/wireless.network
:
Match]
Name=wlan0
[Network]
DHCP=ipv4
DNS=8.8.8.8
DNS=8.8.4.4
[DHCP]
RouteMetric=20
Para conexões com fio, crie o arquivo wired.network com o seguinte conteúdo:
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
Para conexões sem fio, crie um arquivo de configuração para seu ponto de acesso usando:
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
sair
desativar o gerenciador de rede:
sudo systemctl disable NetworkManager
Ativar systemd-networkd:
sudo systemctl enable systemd-networkd
Ativar o systemd-resolved
:
sudo systemctl enable systemd-resolved
sudo systemctl start systemd-resolved
exclua ou renomeie resolv.conf
e crie um link simbólico para /etc/resolv.conf
:
sudo ln -s /run/systemd/resolve/resolv.conf /etc/resolv.conf
Reinicie o srvice:
systemctl restart systemd-networkd
Reiniciar
Digite o seguinte comando
root@root:~# sudo systemctl status systemd-networkd
A saída:
● 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