nmcli usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# nmcli dev status
DEVICE  TYPE      STATE      CONNECTION
eth0    ethernet  connected  System eth0
eth1    ethernet  unmanaged  --
eth2    ethernet  unmanaged  --
lo      loopback  unmanaged  --

# nmcli dev set eth1 managed yes
# nmcli dev set eth2 managed yes
# nmcli con add type ethernet con-name eth2 ifname eth2
# nmcli con add type ethernet con-name eth1 ifname eth1
# nmcli dev status
DEVICE  TYPE      STATE                                  CONNECTION
eth0    ethernet  connected                              eth0
eth1    ethernet  connecting (getting IP configuration)  eth1
eth2    ethernet  connecting (getting IP configuration)  eth2
lo      loopback  unmanaged                              --
# nmcli con show
NAME  UUID                                  TYPE      DEVICE
eth0  8c9f74d3-8b59-4331-a690-6467d44d1da8  ethernet  eth0
eth1  13b1d0d6-8b59-4eec-a65c-1cde9116b73b  ethernet  eth1
eth2  8349d843-45fe-4fbb-ad5d-9b3932744806  ethernet  eth2


# nmcli connection add type bond con-name bond0 ifname bond0 bond.options "mode=active-backup,miimon=100"
# nmcli connection add type ethernet slave-type bond con-name bond0-eth1 ifname eth1 master bond0
# nmcli connection add type ethernet slave-type bond con-name bond0-eth2 ifname eth2 master bond0
# nmcli con modify bond0 ipv4.addresses "192.168.100.156/24" ipv4.method manual
# nmcli con up bond0
# nmcli con show
NAME        UUID                                  TYPE      DEVICE
bond0       4995acd3-4e79-418f-afa3-a00939b904a5  bond      bond0
bond0-eth1  e14695b7-7587-48d3-8dee-20d8bb1bfa8b  ethernet  eth1
bond0-eth2  bebad310-7795-4336-8977-bb79378d8664  ethernet  eth2
eth0        8c9f74d3-8b59-4331-a690-6467d44d1da8  ethernet  eth0
eth1        13b1d0d6-8b59-4eec-a65c-1cde9116b73b  ethernet  --
eth2        8349d843-45fe-4fbb-ad5d-9b3932744806  ethernet  --
# nmcli dev status
DEVICE  TYPE      STATE      CONNECTION
eth0    ethernet  connected  eth0
bond0   bond      connected  bond0
eth1    ethernet  connected  bond0-eth1
eth2    ethernet  connected  bond0-eth2
lo      loopback  unmanaged  --

Issues

  1. The interface state is unmanaged even after setting managed yes

A device can be unmanaged for multiple reasons. Only some of those reasons can be undone via nmcli dev set. for example, if it’s unmanaged due to NM_CONTROLLED=no in an ifcfg file, then you cannot overrule that. on the other hand, if the device is unmanaged due to an udev rule or due to “device.managed” in NetworkManager.conf, then it can be overruled via D-Bus/nmcli.

Even you have a ifcfg-eth2 which doesn’t has NM_CONTROLLED=no. If you have a file ifcfg-eth2.bak with NM_CONTROLLED=no. You will also got this issue.

  1. What’s the difference between DEVICE=eth2 and NAME=eth2?

NAME= is the (optional) name of the profile. DEVICE= is the (optional) name of the interface to which it applies (or, in case of software devices like bridge/bond, it’s the name of the created device)

  1. Is it possible to make it connected without config any ip address? to avoid state connecting (getting IP configuration).

nmcli c modify eth2 ipv4.addresses "192.168.2.1/24" ipv4.method manual doesn’t work as modifying a profile does not change the device. We need also do nmcli connection up eth2 to make the changed applied.