Thursday, May 9, 2013

Network devices comes with UUID? What is nmcli? PART 1

Network devices comes with UUID? What is nmcli? PART 1

The whole notion to explore on the network configuration was because of the curiosity when I bounced the network services and found out "something" new.

 [root@localhost network-scripts]# /etc/init.d/network restart
Shutting down interface eth0:  Device state: 3 (disconnected)
                                                           [  OK  ]
Shutting down loopback interface:                          [  OK  ]
Bringing up loopback interface:                            [  OK  ]
Bringing up interface eth0:  Active connection state: activating
Active connection path: /org/freedesktop/NetworkManager/ActiveConnection/10
state: activated
Connection activated

                                                           [  OK  ]


So, what is the highlighted lines telling me? I have never seen this before in my past 10 years using Linux. So, when I dig more on it, I found out it was actually invoked by the /sbin/ifup command at the /etc/init.d/network script, something like ifup eth0 boot. If you drill down the script in the debug mode, then you will realize ifup is another wrapper script on top of nmcli command, where it called out something like this

nmcli con up UUID 2b58ae6b-8ad0-4fcc-ad99-582fa16d2fd9

Well, this is pretty new to me. Network configuration that ties to a UUID? That's awesome. Is nmcli (network manager cli) going to replace ifconfig command? Personally, I have a lot of doubts. Let's find out more..

This is how a ifcfg-eth0 looks like in Centos6.4

[root@localhost network-scripts]# cat ifcfg-eth0
DEVICE="eth0"
BOOTPROTO="dhcp"
HWADDR="00:0C:29:10:6A:D3"
IPV6INIT="yes"
NM_CONTROLLED="yes"
ONBOOT="yes"
TYPE="Ethernet"
UUID="2b58ae6b-8ad0-4fcc-ad99-582fa16d2fd9"



Now, nmcli tagging each of the NIC with a UUID. With that in place, nmcli make use of this and prints out something like this for you as a more user-friendly format. From the man file, it tells us that there are three main objects that governed by nmcli which is nm, con, dev.

nm: Network Manager. Use this object to inquire and change state of NetworkManager.

con: Connection. Get information about NetworkManager's connections.

dev: Device. Get information about devices.

[root@localhost network-scripts]# nmcli nm status
RUNNING         STATE           WIFI-HARDWARE   WIFI       WWAN-HARDWARE   WWAN
running         connected       enabled         enabled    enabled         enabled


[root@localhost network-scripts]# nmcli con status
NAME                      UUID                                   DEVICES    SCOPE    DEFAULT  VPN
System eth0               2b58ae6b-8ad0-4fcc-ad99-582fa16d2fd9   eth0       system   yes      no


[root@localhost network-scripts]# nmcli dev
DEVICE     TYPE              STATE
eth0       802-3-ethernet    connected


[root@localhost network-scripts]# nmcli dev list
GENERAL.DEVICE:                 eth0
GENERAL.TYPE:                   802-3-ethernet
GENERAL.DRIVER:                 e1000
GENERAL.HWADDR:                 00:0C:29:10:6A:D3
GENERAL.STATE:                  connected
CAPABILITIES.CARRIER-DETECT:    yes
CAPABILITIES.SPEED:             1000 Mb/s
WIRED-PROPERTIES.CARRIER:       on
IP4-SETTINGS.ADDRESS:           192.168.195.133
IP4-SETTINGS.PREFIX:            24 (255.255.255.0)
IP4-SETTINGS.GATEWAY:           192.168.195.2
IP4-DNS1.DNS:                   192.168.195.2


In sync with this command, there is another cool command, called, nm-tool.

[root@localhost network-scripts]# nm-tool

NetworkManager Tool

State: connected

- Device: eth0  [System eth0] --------------------------------------------------
  Type:              Wired
  Driver:            e1000
  State:             connected
  Default:           yes
  HW Address:        00:0C:29:10:6A:D3

  Capabilities:
    Carrier Detect:  yes
    Speed:           1000 Mb/s

  Wired Properties
    Carrier:         on

  IPv4 Settings:
    Address:         192.168.195.133
    Prefix:          24 (255.255.255.0)
    Gateway:         192.168.195.2

    DNS:             192.168.195.2



From here, we can see there are a lot of useful information, e.g  kernel module, e1000 is used, speed, carrier state,  HW address.

Conclusion: I don't really see the need of nmcli, why it is being used? Isn't that another command to the native the command like ip? But, it is worth to reread the ifup script, and do a comparison between the old ifup and the new ifup script.

No comments: