Debian
debian 使用者可以通過 systemd-networkd 連接到網路嗎?
Systemd提供了自行管理網路的能力,而無需其他工具,例如netctl或NetworkManager。我正在執行 debian 8,我需要使用
systemd-networkd
在 debian jessie through 下管理網路有什麼要求
systemd-networkd
?以及如何啟用服務和網路?
要通過systemd-networkd連接到網路,您需要創建一些配置文件:
對於無線連接,創建具有以下內容的wireless.network文件:
nano /etc/systemd/wireless.network
:Match] Name=wlan0 [Network] DHCP=ipv4 DNS=8.8.8.8 DNS=8.8.4.4 [DHCP] RouteMetric=20
對於有線連接,創建帶有以下內容的wired.network文件:
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
對於無線連接,請使用以下命令為您的接入點創建配置文件:
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
出口
禁用網路管理器:
sudo systemctl disable NetworkManager
啟用 systemd-networkd :
sudo systemctl enable systemd-networkd
啟用
systemd-resolved
:sudo systemctl enable systemd-resolved sudo systemctl start systemd-resolved
刪除或重命名
resolv.conf
,然後創建一個符號連結/etc/resolv.conf
:sudo ln -s /run/systemd/resolve/resolv.conf /etc/resolv.conf
重啟服務:
systemctl restart systemd-networkd
重啟
鍵入以下命令
root@root:~# sudo systemctl status systemd-networkd
輸出:
● 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