From Fedora Project Wiki
 
(15 intermediate revisions by the same user not shown)
Line 1: Line 1:
==Description==
==Description==
nmcli is a tool that allows NetworkManager management from command line. This tool is useful in those cases in which a graphical frontend is not available.
nmcli is a tool that allows NetworkManager management from command line.


==Connect/disconnect to an already configured connection==
==NetworkManager status==
List already configured connections
 
<pre>nmcli con list</pre>
Display overall status of NetworkManager
<pre>nmcli general status</pre>


Connect to a configured connection by name or uuid
Display active connections
<pre>nmcli con up id <connection name></pre>
<pre>nmcli connection show active</pre>
<pre>nmcli con up uuid <uuid></pre>


Disconnection by name or uuid
Display all configured connections
<pre>nmcli con down id <connection name></pre>
<pre>nmcli connection show configured</pre>
<pre>nmcli con down uuid <uuid></pre>


==Network interfaces==
==Connect/disconnect to an already configured connection==
List available devices and their status
 
<pre>nmcli dev status</pre>
Connect to a configured connection by name
<pre>nmcli connection up id <connection name></pre>


Disconnect an interface
Disconnection by name
<pre>nmcli dev disconnect iface <interface></pre>
<pre>nmcli connection down id <connection name></pre>


==Wifi==
==Wifi==
Get Wifi status
Get Wifi status
<pre>nmcli nm wifi</pre>
<pre>nmcli radio wifi</pre>


Turn wifi on or off
Turn wifi on or off
<pre>nmcli nm wifi <on|off></pre>
<pre>nmcli radio wifi <on|off></pre>


List available access points(AP) to connect to
List available access points(AP) to connect to
<pre>nmcli dev wifi list</pre>
<pre>nmcli device wifi list</pre>
 
Refresh previous list
<pre>nmcli device wifi rescan</pre>


Create a new connection to an open AP
Create a new connection to an open AP
<pre>nmcli dev wifi connect <SSID|BSSID></pre>
<pre>nmcli device wifi connect <SSID|BSSID></pre>
 
Create a new connection to a password protected AP
<pre>nmcli device wifi connect <SSID|BSSID> password <password></pre>
 
==Network interfaces==
List available devices and their status
<pre>nmcli device status</pre>
 
Disconnect an interface
<pre>nmcli device disconnect iface <interface></pre>
 
==Create or modify a connection==
 
To create a new connection using an interactive editor
<pre>nmcli connection edit con-name <name of new connection></pre>
 
To edit an already existing connection using an interactive editor
<pre>nmcli connection edit <connection name></pre>
 
===Example/Tutorial===


==Modify an already configured connection==
Let's create a new connection
Open with a text editor the configuration file of the connection. The file is located in "/etc/sysconfig/network-scripts/" under the name of "ifcfg-<connection name>"
<pre>nmcli connection edit con-name <name of new connection></pre>


===Connect automatically to that connection===
It will ask us to define a connection type
<pre>Valid connection types: 802-3-ethernet (ethernet), 802-11-wireless (wifi), wimax, gsm, cdma, infiniband, adsl, bluetooth, vpn, 802-11-olpc-mesh (olpc-mesh), vlan, bond, team, bridge, bond-slave, team-slave, bridge-slave
Enter connection type: </pre>


Edit to or add the line "ONBOOT=yes"
In this example we will use ethernet
<pre>Enter connection type: ethernet</pre>


===Make the connection available only to one user===
Next this will appear, note that "nmcli>" is a prompt and that it lists the main settings available
<pre>===| nmcli interactive connection editor |===


Edit or add the line "USERS=<username>"
Adding a new '802-3-ethernet' connection


===Spoof MAC address===
Type 'help' or '?' for available commands.
Type 'describe [<setting>.<prop>]' for detailed property description.


Edit or add the line "MACADDR=<spoofed MAC>". Don't change the line "HWADDR=<real MAC>" to spoof your MAC address.
You may edit the following settings: connection, 802-3-ethernet (ethernet), 802-1x, ipv4, ipv6
nmcli> </pre>


We will edit the setting "ipv4"
<pre>nmcli> goto ipv4</pre>


Finally save the file and to apply changes to an already active connection execute
Note that after this our promt has changed to this to indicate that we are currently editing the "ipv4" setting
<pre>nmcli con up id <connection name></pre>
<pre>nmcli ipv4></pre>


===Edit a connection password===
List available properties under the setting "ipv4" and describe the property "method"
<pre>nmcli ipv4> describe</pre>
<pre>Available properties: method, dns, dns-search, addresses, routes, ignore-auto-routes, ignore-auto-dns, dhcp-client-id, dhcp-send-hostname, dhcp-hostname, never-default, may-fail
Property name?</pre>
<pre>Property name? method</pre>


To modify a connection password open with a text editor and edit the file "keys-<connection id>" located in "/etc/sysconfig/network-scripts/". The password is stored in plain text
Let's set property "method" to "auto"
<pre>nmcli ipv4> set method auto</pre>


===Delete a connection===
Now that we have finished editing the "ipv4" setting let's go back to the main level. Execute the following command until the prompt looks like this "nmcli>"
<pre>nmcli con delete id <connection name></pre>
<pre>nmcli> back</pre>
 
If you need to list again the main settings use the "goto" command without any arguments. After that just press enter and ignore the error.
<pre>nmcli> goto</pre>
<pre>Available settings: connection, 802-3-ethernet (ethernet), 802-1x, ipv4, ipv6
Setting name?</pre>
 
It is possible to set a value for a property directly from the main level
<pre>nmcli> set <setting>.<property> <value></pre>
 
For example
<pre>nmcli> set connection.autoconnect TRUE</pre>
<pre>nmcli> set connection.interface-name <interface name this connection is bound to></pre>
<pre>nmcli> set ethernet.cloned-mac-address <Spoofed MAC address></pre>
 
Finally check the connection details, save and exit
<pre>nmcli> print</pre>
<pre>nmcli> save</pre>
<pre>nmcli> quit</pre>
 
===Manually editing===
 
To manually edit a connection configuration open or create with a text editor the configuration file of the connection located in "/etc/sysconfig/network-scripts/ifcfg-<connection name>"
 
A description of most common configuration options is available at:
http://access.redhat.com/site/documentation/en-US/Red_Hat_Enterprise_Linux/6/html/Deployment_Guide/s1-networkscripts-interfaces.html
 
To modify a connection password open with a text editor and edit the file "keys-<connection id>" located in "/etc/sysconfig/network-scripts/". The password is stored in plain text. For example
<pre>$ cat /etc/sysconfig/network-scripts/keys-<connection name>
WPA_PSK='password'</pre>
 
Or if using keyfile, simply edit the connection file located inside "/etc/NetworkManager/system-connections/"
 
Finally save the files and to apply changes to an already active connection execute
<pre>nmcli connection up id <connection name></pre>
 
==For versions previous to NetworkManager 0.9.9.0==
These versions lack some features described in this page and some of the commands may vary. If your current version is lower than 0.9.9.0 update NetworkManager. If you decide not to do so check the info pages for more information about your current version.
<pre>info nmcli</pre>
 
However as those previous version lack the support for interactive connection editing, this have to be done manually as explained above
 
==Delete a connection configuration==
In case that the connection is active
<pre>nmcli connection down id <connection name></pre>
 
Delete the connection
<pre>nmcli connection delete id <connection name></pre>


==Notes==
==Notes==
Line 64: Line 147:
nmcli maybe contain some bugs and lack some features graphical tools for NetworkManager have.
nmcli maybe contain some bugs and lack some features graphical tools for NetworkManager have.


To see available options for nmcli deeper
To see all available options for your version of nmcli
<pre>man nmcli</pre>
<pre>info nmcli</pre>
 
==Links==
 
[http://wiki.gnome.org/NetworkManager/SystemSettings]

Latest revision as of 22:30, 18 December 2013

Description

nmcli is a tool that allows NetworkManager management from command line.

NetworkManager status

Display overall status of NetworkManager

nmcli general status

Display active connections

nmcli connection show active

Display all configured connections

nmcli connection show configured

Connect/disconnect to an already configured connection

Connect to a configured connection by name

nmcli connection up id <connection name>

Disconnection by name

nmcli connection down id <connection name>

Wifi

Get Wifi status

nmcli radio wifi

Turn wifi on or off

nmcli radio wifi <on|off>

List available access points(AP) to connect to

nmcli device wifi list

Refresh previous list

nmcli device wifi rescan

Create a new connection to an open AP

nmcli device wifi connect <SSID|BSSID>

Create a new connection to a password protected AP

nmcli device wifi connect <SSID|BSSID> password <password>

Network interfaces

List available devices and their status

nmcli device status

Disconnect an interface

nmcli device disconnect iface <interface>

Create or modify a connection

To create a new connection using an interactive editor

nmcli connection edit con-name <name of new connection>

To edit an already existing connection using an interactive editor

nmcli connection edit <connection name>

Example/Tutorial

Let's create a new connection

nmcli connection edit con-name <name of new connection>

It will ask us to define a connection type

Valid connection types: 802-3-ethernet (ethernet), 802-11-wireless (wifi), wimax, gsm, cdma, infiniband, adsl, bluetooth, vpn, 802-11-olpc-mesh (olpc-mesh), vlan, bond, team, bridge, bond-slave, team-slave, bridge-slave
Enter connection type: 

In this example we will use ethernet

Enter connection type: ethernet

Next this will appear, note that "nmcli>" is a prompt and that it lists the main settings available

===| nmcli interactive connection editor |===

Adding a new '802-3-ethernet' connection

Type 'help' or '?' for available commands.
Type 'describe [<setting>.<prop>]' for detailed property description.

You may edit the following settings: connection, 802-3-ethernet (ethernet), 802-1x, ipv4, ipv6
nmcli> 

We will edit the setting "ipv4"

nmcli> goto ipv4

Note that after this our promt has changed to this to indicate that we are currently editing the "ipv4" setting

nmcli ipv4>

List available properties under the setting "ipv4" and describe the property "method"

nmcli ipv4> describe
Available properties: method, dns, dns-search, addresses, routes, ignore-auto-routes, ignore-auto-dns, dhcp-client-id, dhcp-send-hostname, dhcp-hostname, never-default, may-fail
Property name?
Property name? method

Let's set property "method" to "auto"

nmcli ipv4> set method auto

Now that we have finished editing the "ipv4" setting let's go back to the main level. Execute the following command until the prompt looks like this "nmcli>"

nmcli> back

If you need to list again the main settings use the "goto" command without any arguments. After that just press enter and ignore the error.

nmcli> goto
Available settings: connection, 802-3-ethernet (ethernet), 802-1x, ipv4, ipv6
Setting name?

It is possible to set a value for a property directly from the main level

nmcli> set <setting>.<property> <value>

For example

nmcli> set connection.autoconnect TRUE
nmcli> set connection.interface-name <interface name this connection is bound to>
nmcli> set ethernet.cloned-mac-address <Spoofed MAC address>

Finally check the connection details, save and exit

nmcli> print
nmcli> save
nmcli> quit

Manually editing

To manually edit a connection configuration open or create with a text editor the configuration file of the connection located in "/etc/sysconfig/network-scripts/ifcfg-<connection name>"

A description of most common configuration options is available at: http://access.redhat.com/site/documentation/en-US/Red_Hat_Enterprise_Linux/6/html/Deployment_Guide/s1-networkscripts-interfaces.html

To modify a connection password open with a text editor and edit the file "keys-<connection id>" located in "/etc/sysconfig/network-scripts/". The password is stored in plain text. For example

$ cat /etc/sysconfig/network-scripts/keys-<connection name>
WPA_PSK='password'

Or if using keyfile, simply edit the connection file located inside "/etc/NetworkManager/system-connections/"

Finally save the files and to apply changes to an already active connection execute

nmcli connection up id <connection name>

For versions previous to NetworkManager 0.9.9.0

These versions lack some features described in this page and some of the commands may vary. If your current version is lower than 0.9.9.0 update NetworkManager. If you decide not to do so check the info pages for more information about your current version.

info nmcli

However as those previous version lack the support for interactive connection editing, this have to be done manually as explained above

Delete a connection configuration

In case that the connection is active

nmcli connection down id <connection name>

Delete the connection

nmcli connection delete id <connection name>

Notes

nmcli maybe contain some bugs and lack some features graphical tools for NetworkManager have.

To see all available options for your version of nmcli

info nmcli