====== NetworkManager command line ======
GUI: nmtui
===== NetworkManager service =====
First step, check if NetworkManager service is enable, and network service (old service) disable:
[root@centos7 ~]# systemctl list-unit-files | grep -i network
dbus-org.freedesktop.NetworkManager.service enabled
NetworkManager-dispatcher.service enabled
NetworkManager-wait-online.service disabled
NetworkManager.service enabled
network-online.target static
network.target static
[root@centos7 ~]# systemctl list-units | grep -i network
NetworkManager.service loaded active running Network Manager
rhel-import-state.service loaded active exited Import network configuration from initramfs network.target loaded active active Network
[root@centos7 ~]# chkconfig --list network
network 0:off 1:off 2:off 3:off 4:off 5:off 6:off
Else change it:
[root@centos7 ~]# chkconfig network stop
[root@centos7 ~]# chkconfig network off
[root@centos7 ~]# systemctl enable NetworkManager
[root@centos7 ~]# systemctl start NetworkManager
Common initial setup
[root@centos7 ~]# nmcli con mod eth0 ipv4.addresses 10.10.10.119/24 ipv4.gateway 10.10.10.1
[root@centos7 ~]# nmcli con mod eth0 connection.autoconnect yes
[root@centos7 ~]# nmcli con mod eth0 ipv4.dns 10.10.10.2,10.10.10.3 ipv4.dns-search "mydomain.lu"
[root@centos7 ~]# nmcli con mod eth0 ipv4.method manual
[root@centos7 ~]# nmcli con up eth0 ifname eth0
Check the Network Manager status
[root@centos7 ~]# systemctl status NetworkManager
NetworkManager.service - Network Manager
Loaded: loaded (/usr/lib/systemd/system/NetworkManager.service; enabled)
Active: active (running) since Fri 2014-10-31 13:49:20 CET; 35min ago
Main PID: 1886 (NetworkManager)
CGroup: /system.slice/NetworkManager.service
â886 /usr/sbin/NetworkManager --no-daemon
Oct 31 13:49:20 centos7 NetworkManager[1886]: Activation (eno16780032) Stage 3 of 5 (IP Configure Start) complete.
Oct 31 13:49:20 centos7 NetworkManager[1886]: Activation (eno16780032) Stage 5 of 5 (IPv4 Commit) started...
Oct 31 13:49:20 centos7 NetworkManager[1886]: (eno16780032): device state change: ip-config -> ip-check (reason 'none') [70 80 0]
Oct 31 13:49:20 centos7 NetworkManager[1886]: Activation (eno16780032) Stage 5 of 5 (IPv4 Commit) complete.
Oct 31 13:49:20 centos7 NetworkManager[1886]: (eno16780032): device state change: ip-check -> secondaries (reason 'none') [80 90 0]
Oct 31 13:49:20 centos7 NetworkManager[1886]: (eno16780032): device state change: secondaries -> activated (reason 'none') [90 100 0]
Oct 31 13:49:20 centos7 NetworkManager[1886]: NetworkManager state is now CONNECTED_LOCAL
Oct 31 13:49:20 centos7 NetworkManager[1886]: Policy set 'eth0' (eno16780032) as default for IPv4 routing and DNS.
Oct 31 13:49:20 centos7 NetworkManager[1886]: Activation (eno16780032) successful, device activated.
Oct 31 13:49:26 centos7 NetworkManager[1886]: startup complete
**Be careful, in order to apply a change in the network config using NetworManager, do a reload-or-restart, else the change won't be active !!!**
[root@centos7 ~]# systemctl reload-or-restart NetworkManager
===== NetworkManager command line =====
Help nmcli:
$ nmcli help
Usage: nmcli [OPTIONS] OBJECT { COMMAND | help }
OPTIONS
-t[erse] terse output
-p[retty] pretty output
-m[ode] tabular|multiline output mode
-f[ields] |all|common specify fields to output
-e[scape] yes|no escape columns separators in values
-n[ocheck] don't check nmcli and NetworkManager versions
-a[sk] ask for missing parameters
-w[ait] set timeout waiting for finishing operations
-v[ersion] show program version
-h[elp] print this help
OBJECT
g[eneral] NetworkManager's general status and operations
n[etworking] overall networking control
r[adio] NetworkManager radio switches
c[onnection] NetworkManager's connections
d[evice] devices managed by NetworkManager
==== Static IP configuration ====
Review the status of the devices and connections
$ nmcli device status
DEVICE TYPE STATE CONNECTION
ens3 ethernet connected my-office
ens9 ethernet connected Myeth0
lo loopback unmanaged --
To list the currently available network connections
$ nmcli con show
NAME UUID TYPE DEVICE
Auto Ethernet 9b7f2511-5432-40ae-b091-af2457dfd988 802-3-ethernet --
ens3 fb157a65-ad32-47ed-858c-102a48e064a2 802-3-ethernet Myeth1
MyWiFi 91451385-4eb8-4080-8b82-720aab8328dd 802-11-wireless wlan0
Rename connection name:
$ nmcli con mod "Auto Ethernet" connection.id ethernet1
$ nmcli con show
NAME UUID TYPE DEVICE
ethernet1 9b7f2511-5432-40ae-b091-af2457dfd988 802-3-ethernet --
...
Adding a Static Ethernet Connection
nmcli connection add type ethernet con-name connection-name ifname interface-name ip4 address gw4 address
$ nmcli con add type ethernet con-name Myeth0 ifname ens9 autoconnect yes save yes ip4 10.10.10.10/24 gw4 10.10.10.254
$ nmcli con add type ethernet con-name Myeth0 ifname ens9 autoconnect yes save yes ip4 10.10.10.10/24 gw4 10.10.10.254 ip6 abbe::cafe gw6 2001:db8::1
A file /etc/sysconfig/network-scripts/ifcfg-Myeth0 has been created
Change the IP address on eth0:
[root@fedora22 ~]# nmcli con mod eth0 ipv4.method manual ipv4.addr "10.0.102.22/24"
[root@fedora22 ~]# nmcli device disconnect eth0
[root@fedora22 ~]# nmcli device connect eth0
[root@fedora22 ~]# ip a
...
2: eth0: mtu 1500 qdisc fq_codel state UNKNOWN group default qlen 1000
link/ether fa:fc:a2:7c:71:04 brd ff:ff:ff:ff:ff:ff
inet 10.0.102.22/24 brd 10.0.102.255 scope global eth0
Add 2 IPV4 DNS
$ nmcli con mod Myeth0 ipv4.dns "8.8.8.8 8.8.4.4" ipv4.dns-search "mydomain.org"
To bring up the new Ethernet connection
$ nmcli con up Myeth0 ifname ens9
To view detailed information about the newly configured connection
$ nmcli -p con show Myeth0
===============================================================================
Connection profile details (eth0)
===============================================================================
connection.id: Myeth0
connection.uuid: ccccd47e-b214-4440-9161-addfbbff1009
connection.interface-name: eno16780032
connection.type: 802-3-ethernet
connection.autoconnect: yes
connection.timestamp: 1414764561
connection.read-only: no
connection.permissions:
connection.zone: --
connection.master: --
connection.slave-type: --
connection.secondaries:
connection.gateway-ping-timeout: 0
-------------------------------------------------------------------------------
802-3-ethernet.port: --
802-3-ethernet.speed: 0
802-3-ethernet.duplex: --
802-3-ethernet.auto-negotiate: yes
802-3-ethernet.mac-address: --
802-3-ethernet.cloned-mac-address: --
802-3-ethernet.mac-address-blacklist:
802-3-ethernet.mtu: auto
802-3-ethernet.s390-subchannels:
802-3-ethernet.s390-nettype: --
802-3-ethernet.s390-options:
-------------------------------------------------------------------------------
ipv4.method: manual
ipv4.dns: 192.168.20.1, 192.168.20.2, 192.168.20.3
ipv4.dns-search: mydomain.org
ipv4.addresses: { ip = 192.168.11.194/24, gw = 192.168.11.250 }
ipv4.routes:
ipv4.ignore-auto-routes: no
ipv4.ignore-auto-dns: no
ipv4.dhcp-client-id: --
ipv4.dhcp-send-hostname: yes
ipv4.dhcp-hostname: --
ipv4.never-default: no
ipv4.may-fail: yes
-------------------------------------------------------------------------------
ipv6.method: ignore
ipv6.dns:
ipv6.dns-search:
ipv6.addresses:
ipv6.routes:
ipv6.ignore-auto-routes: no
ipv6.ignore-auto-dns: no
ipv6.never-default: no
ipv6.may-fail: yes
ipv6.ip6-privacy: -1 (unknown)
ipv6.dhcp-hostname: --
-------------------------------------------------------------------------------
===============================================================================
Activate connection details (ccccd47e-b214-4440-9161-addfbbff1009)
===============================================================================
GENERAL.NAME: eth0
GENERAL.UUID: ccccd47e-b214-4440-9161-addfbbff1009
GENERAL.DEVICES: eno16780032
GENERAL.STATE: activated
GENERAL.DEFAULT: yes
GENERAL.DEFAULT6: no
GENERAL.VPN: no
GENERAL.ZONE: --
GENERAL.DBUS-PATH: /org/freedesktop/NetworkManager/ActiveConnection/0
GENERAL.CON-PATH: /org/freedesktop/NetworkManager/Settings/0
GENERAL.SPEC-OBJECT: --
GENERAL.MASTER-PATH: --
-------------------------------------------------------------------------------
IP4.ADDRESS[1]: ip = 192.168.11.194/24, gw = 192.168.11.250
IP4.DNS[1]: 192.168.20.1
IP4.DNS[2]: 192.168.20.2
IP4.DNS[3]: 192.168.20.3
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
To get details about all the devices
$ nmcli d show
GENERAL.DEVICE: eno16780032
GENERAL.TYPE: ethernet
GENERAL.HWADDR: 00:50:56:83:22:1E
GENERAL.MTU: 1500
GENERAL.STATE: 100 (connected)
GENERAL.CONNECTION: eth0
GENERAL.CON-PATH: /org/freedesktop/NetworkManager/ActiveConnection/0
WIRED-PROPERTIES.CARRIER: on
IP4.ADDRESS[1]: ip = 192.168.11.194/24, gw = 192.168.11.250
IP4.DNS[1]: 192.168.20.1
IP4.DNS[2]: 192.168.20.2
IP4.DNS[3]: 192.168.20.3
GENERAL.DEVICE: lo
GENERAL.TYPE: loopback
GENERAL.HWADDR: 00:00:00:00:00:00
GENERAL.MTU: 65536
GENERAL.STATE: 10 (unmanaged)
GENERAL.CONNECTION: --
GENERAL.CON-PATH: --
==== Delete a network connection from NetworkManager ====
**nmcli con del **
[root@rh73 ~]# nmcli con show
NAME UUID TYPE DEVICE
team0 e519a6d9-4bf6-438e-a193-d3d3c799c388 team team0
enP7p128s0f1 c0e9b8ed-2c91-49c7-9991-34d7fabc1556 802-3-ethernet --
enP7p128s0f3 a38fe38d-32b5-4148-b5e7-a881179517d1 802-3-ethernet --
enP7p128s0f0 848defb7-6922-40b9-a70c-a7458a991453 802-3-ethernet enP7p128s0f0
enP2p96s0f2 d267c5e8-3c5f-4c56-970c-74d823a74fe1 802-3-ethernet --
enP7p128s0f2 197de45a-0b6d-48f8-9a77-39fce3d932d8 802-3-ethernet --
enP2p96s0f0 9b50ac73-6b82-0a4a-0c2b-45f213d99656 802-3-ethernet --
enP2p96s0f1 d3c3d721-ce8d-45c2-aa8a-6cb434a7b59f 802-3-ethernet --
enP2p96s0f3 f2792d73-6ec1-4688-8a52-ad0d1c89903c 802-3-ethernet --
team0-enP4p1s0f1 0b53b68e-e89e-4fad-96c1-0023f414b4e5 802-3-ethernet enP4p1s0f1
team0-enP4p1s0f0 eec115e5-ba9c-4a35-a05b-d39699a6363b 802-3-ethernet enP4p1s0f0
[root@rh73 ~]# nmcli con del e519a6d9-4bf6-438e-a193-d3d3c799c388
==== Changing hostname ====
Show the current hostname:
$ nmcli general hostname
localhost.localdomain
To change the hostname:
$ nmcli general hostname RedHat
==== Adding a Wi-Fi Connection ====
To view the available Wi-Fi access points
$ nmcli dev wifi list
SSID MODE CHAN RATE SIGNAL BARS SECURITY
FedoraTest Infra 11 54 MB/s 98 ▂▄▆█ WPA1
Red Hat Guest Infra 6 54 MB/s 97 ▂▄▆█ WPA2
Red Hat Infra 6 54 MB/s 77 ▂▄▆_ WPA2 802.1X
* Red Hat Infra 40 54 MB/s 66 ▂▄▆_ WPA2 802.1X
VoIP Infra 1 54 MB/s 32 ▂▄__ WEP
MyCafe Infra 11 54 MB/s 39 ▂▄__ WPA2
To create a Wi-Fi connection profile with static IP configuration, but allowing automatic DNS address assignment
$ nmcli con add con-name MyCafe ifname wlan0 type wifi ssid MyCafe ip4 192.168.100.101/24 gw4 192.168.100.1
To set a WPA2 password, for example “caffeine”
$ nmcli con modify MyCafe wifi-sec.key-mgmt wpa-psk
$ nmcli con modify MyCafe wifi-sec.psk caffeine
To get the list of available wifi access points, type:
# nmcli d wifi
* SSID MODE CHAN RATE SIGNAL BARS SECURITY
AAA Infra 11 54 MB/s 55 ▂▄__ WPA2 802.1X
BBB Infra 11 54 MB/s 54 ▂▄__ WPA1
CCC Infra 1 54 MB/s 49 ▂▄__ WPA1
DDD Infra 11 54 MB/s 44 ▂▄__ WPA1 802.1X
EEE Infra 11 54 MB/s 92 ▂▄▆█ WEP
To connect to a wifi access point specified by a SSID (here EEE), type:
# nmcli d wifi connect EEE password '12345678901234567890123456'
To request that NetworkManager rescans for available access points, type:
# nmcli d wifi rescan
===== Problem with network adapter =====
Check network adapter location
# lshw -class network -short
H/W path Device Class Description
=====================================================
/0/100/3 enp0s3 network 82540EM Gigabit Ethernet Controller
/0/100/8 network 79c970 [PCnet32 LANCE]
# lspci -nn | grep Eth
00:03.0 Ethernet controller [0200]: Intel Corporation 82540EM Gigabit Ethernet Controller [8086:100e] (rev 02)
00:08.0 Ethernet controller [0200]: Advanced Micro Devices, Inc. [AMD] 79c970 [PCnet32 LANCE] [1022:2000] (rev 40)
# nmcli -f general.device,general.udi dev sh
GENERAL.DEVICE: enp0s3
GENERAL.UDI: /sys/devices/pci0000:00/0000:00:03.0/net/enp0s3
GENERAL.DEVICE: lo
GENERAL.UDI: /sys/devices/virtual/net/lo
Here I got problem with network driver, which is no more supported. You can check in /var/log/messages
==== Rename network device ====
Change from **ens192** to **eth0**
[root@ibmpvc01 ~]# lshw -class network -short
H/W path Device Class Description
===========================================================
/0/100/16/0 ens192 network VMXNET3 Ethernet Controller
Add the option **net.ifnames=0** into file **/etc/default/grub**, and rebuild grub, then reboot
[root@ibmpvc01 ~]# cat /etc/default/grub
...
GRUB_CMDLINE_LINUX="crashkernel=auto resume=/dev/mapper/rhel-swap rd.lvm.lv=rhel/root rd.lvm.lv=rhel/swap rd.lvm.lv=rhel/usr net.ifnames=0 rhgb quiet"
[root@ibmpvc01 ~]# grub2-mkconfig -o /boot/grub2/grub.cfg
[root@ibmpvc01 ~]# init 6
After reboot
[root@ibmpvc01 ~]# lshw -class network -short
H/W path Device Class Description
===========================================================
/0/100/16/0 eth0 network VMXNET3 Ethernet Controller