Quantcast
Channel: 可丁丹尼 @ 一路往前走2.0
Viewing all articles
Browse latest Browse all 79

Networking to NetworkManager

$
0
0

Networking to NetworkManager

安裝Debian過程,有選定桌面程式如:Gnome,Kde,xfce等,會被內定安裝NetworkManager來管理網路連線,這是後期很方便的網路連線管理程式,它連Wifi一樣也能管理的很棒,但如果你安裝過程未選擇桌面程式,那預設安裝是不會幫你安裝這套NetworkManager,會使用傳統透過interfaces設定方式來設定,用法參照Debian NetworkConfiguration

安裝NetworkManager

更動網路管理功能有可能會造成網路斷線、IP無法自動取得等問題,在之前先前缺少的套件先安裝:

sudo apt-get install NetworkManager

變更預設網路管理程式

確保要被NetworkManager管理介面時,需要開啟/etc/network/interfaces讓被管理介面卡不在之中,假設介面名稱ens33如:

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

source /etc/network/interfaces.d/*

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
allow-hotplug 
iface ens33 inet dhcp

刪掉與ens33有關的設定,使它不再被Networking管理:

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

source /etc/network/interfaces.d/*

# The loopback network interface
auto lo
iface lo inet loopback

重新啟動管理networking

sudo systemctl restart networking

啟動NetworkManager

sudo systemctl start NetworkManager

指定管理介面卡

真正連立連線之前要將介面卡設定被NetworkManager管理:

nmcli device set ens33 managed yes

啟動NetworkManager

sudo systemctl start NetworkManager

確認連線

NetworkManager正確接手網路連線管理時,會自動替要管理的介面建立一個連線設定檔:

nmcli connection show

結果:

NAME                UUID                                  TYPE            DEVICE
Wired connection 1  b9b5976c-8372-3438-beda-98700652fca2  802-3-ethernet  ens33

查看一下IP是否取得:

ip a

結果:

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 00:0c:29:37:fd:d0 brd ff:ff:ff:ff:ff:ff
    inet 192.168.19.45/24 brd 192.168.19.255 scope global dynamic ens33
       valid_lft 3193sec preferred_lft 3193sec
    inet6 fe80::f82a:20d5:149e:f2a2/64 scope link
       valid_lft forever preferred_lft forever

手動建立連線設定檔

nmcli connection add type ethernet conn-name [設定檔名稱] ifname [介面名稱]

如:

nmcli connection add type ethernet con-name Wired ifname ens33

啟動此設定檔

nmcli connection up Wired

參考資料

How to Configure and Manage Network Connections Using ‘nmcli’ Tool

Connecting to a Network Using nmcli

[Ethernet device not managed](https://askubuntu.com/questions/882806/ethernet-device-not-managed)

nmcli 修改網卡設定

網絡配置之nmcli

The post Networking to NetworkManager appeared first on 可丁丹尼 @ 一路往前走2.0.


Viewing all articles
Browse latest Browse all 79

Trending Articles