Sunday, February 8, 2015

nmcli basics and examples

nmcli  is the  cli for network manager which is the new way to configure network and network adaptors in Redhat/Centos 7 and Fedora 21

Here are some basic nmcli commands to get you going.

The nice thing with nmcli is that you can tab through all options ie you don't need to remember all the commands, tab completion will bring them up.

nmcli hitting tab here brings up the following options
con  -- NetworkManager connections
dev  -- devices managed by NetworkManager
nm   -- NetworkManager status

nmcli dev  hitting tab here will bring up the following options
disconnect  -- disconnect device and prevent it from automatically activating
list        -- get detailed information about devices
status      -- print status of devices
wifi        -- list available WiFi access points

similarly
nmcli con  hit tab will bring up the following
delete  -- delete a connection
down    -- deactivate a connection
list down   -- list configured connections
status  -- print status of active connections
up      -- activate a connection

nmcli nm
enable  -- get status or enable/disable networking
sleep   -- get sleep status or put to sleep/awake NetworkManager
status  -- show overall status of NetworkManager
wifi    -- inquire or set status of WiFi in NetworkManager
wwan    -- inquire or set status of WWAN in NetworkManager

To show all configured connections
nmcli con 


To connect to a wifi network

first nmcli dev wifi
to see list of available networks then

nmcli dev wifi connect networkname password inputpassword

switch wifi off
nmcli nm wifi off

Bring eth0 adaptor up

nmcli -p con up id "My wired connection" iface eth0

activates the connection with name "My wired connection" on interface eth0. The -p option makes nmcli show progress of the activation.

Get list
nmcli con

Stop interface
nmcli con down id 'Connection'

Start interface
nmcli con up id 'Connection'

No comments: