|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
<html>
|
|
Packit |
5756e2 |
<head>
|
|
Packit |
5756e2 |
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
|
Packit |
5756e2 |
<title>nmcli-examples: NetworkManager Reference Manual</title>
|
|
Packit |
5756e2 |
<meta name="generator" content="DocBook XSL Stylesheets Vsnapshot">
|
|
Packit |
5756e2 |
<link rel="home" href="index.html" title="NetworkManager Reference Manual">
|
|
Packit |
5756e2 |
<link rel="up" href="manpages.html" title="Part I. Manual Pages">
|
|
Packit |
5756e2 |
<link rel="prev" href="nmcli.html" title="nmcli">
|
|
Packit |
5756e2 |
<link rel="next" href="nmtui.html" title="nmtui">
|
|
Packit |
5756e2 |
<meta name="generator" content="GTK-Doc V1.32 (XML mode)">
|
|
Packit |
5756e2 |
<link rel="stylesheet" href="style.css" type="text/css">
|
|
Packit |
5756e2 |
</head>
|
|
Packit |
5756e2 |
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
nmcli-examples
|
|
Packit |
5756e2 |
nmcli-examples — usage examples of nmcli
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
Synopsis
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
Description
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
nmcli is a command-line client for NetworkManager. It
|
|
Packit |
5756e2 |
allows controlling NetworkManager and reporting its status. For more information
|
|
Packit |
5756e2 |
please refer to nmcli(1)
|
|
Packit |
5756e2 |
manual page.
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
The purpose of this manual page is to provide you with various examples and
|
|
Packit |
5756e2 |
usage scenarios of nmcli.
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
Examples
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
Example 1. Listing available Wi-Fi APs
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
$ nmcli device wifi list
|
|
Packit |
5756e2 |
* SSID MODE CHAN RATE SIGNAL BARS SECURITY
|
|
Packit |
5756e2 |
netdatacomm_local Infra 6 54 Mbit/s 37 ▂▄__ WEP
|
|
Packit |
5756e2 |
* F1 Infra 11 54 Mbit/s 98 ▂▄▆█ WPA1
|
|
Packit |
5756e2 |
LoremCorp Infra 1 54 Mbit/s 62 ▂▄▆_ WPA2 802.1X
|
|
Packit |
5756e2 |
Internet Infra 6 54 Mbit/s 29 ▂___ WPA1
|
|
Packit |
5756e2 |
HPB110a.F2672A Ad-Hoc 6 54 Mbit/s 22 ▂___ --
|
|
Packit |
5756e2 |
Jozinet Infra 1 54 Mbit/s 19 ▂___ WEP
|
|
Packit |
5756e2 |
VOIP Infra 1 54 Mbit/s 20 ▂___ WEP
|
|
Packit |
5756e2 |
MARTINA Infra 4 54 Mbit/s 32 ▂▄__ WPA2
|
|
Packit |
5756e2 |
N24PU1 Infra 7 11 Mbit/s 22 ▂___ --
|
|
Packit |
5756e2 |
alfa Infra 1 54 Mbit/s 67 ▂▄▆_ WPA2
|
|
Packit |
5756e2 |
bertnet Infra 5 54 Mbit/s 20 ▂___ WPA1 WPA2
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
This command shows how to list available Wi-Fi networks (APs). You can also use
|
|
Packit |
5756e2 |
--fields option for displaying different columns.
|
|
Packit |
5756e2 |
nmcli -f all dev wifi list will show all of them.
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
Example 2. Connect to a password-protected wifi network
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
$ nmcli device wifi connect "$SSID" password "$PASSWORD"
|
|
Packit |
5756e2 |
$ nmcli --ask device wifi connect "$SSID"
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
Example 3. Showing general information and properties for a Wi-Fi interface
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
$ nmcli -p -f general,wifi-properties device show wlan0
|
|
Packit |
5756e2 |
===========================================================================
|
|
Packit |
5756e2 |
Device details (wlan0)
|
|
Packit |
5756e2 |
===========================================================================
|
|
Packit |
5756e2 |
GENERAL.DEVICE: wlan0
|
|
Packit |
5756e2 |
GENERAL.TYPE: wifi
|
|
Packit |
5756e2 |
GENERAL.VENDOR: Intel Corporation
|
|
Packit |
5756e2 |
GENERAL.PRODUCT: PRO/Wireless 5100 AGN [Shiloh] Network Connection
|
|
Packit |
5756e2 |
GENERAL.DRIVER: iwlwifi
|
|
Packit |
5756e2 |
GENERAL.DRIVER-VERSION: 3.8.13-100.fc17.x86_64
|
|
Packit |
5756e2 |
GENERAL.FIRMWARE-VERSION: 8.83.5.1 build 33692
|
|
Packit |
5756e2 |
GENERAL.HWADDR: 00:1E:65:37:A1:D3
|
|
Packit |
5756e2 |
GENERAL.MTU: 1500
|
|
Packit |
5756e2 |
GENERAL.STATE: 100 (connected)
|
|
Packit |
5756e2 |
GENERAL.REASON: 0 (No reason given)
|
|
Packit |
5756e2 |
GENERAL.UDI: /sys/devices/pci0000:00/0000:00:1c.1/net/wlan0
|
|
Packit |
5756e2 |
GENERAL.IP-IFACE: wlan0
|
|
Packit |
5756e2 |
GENERAL.IS-SOFTWARE: no
|
|
Packit |
5756e2 |
GENERAL.NM-MANAGED: yes
|
|
Packit |
5756e2 |
GENERAL.AUTOCONNECT: yes
|
|
Packit |
5756e2 |
GENERAL.FIRMWARE-MISSING: no
|
|
Packit |
5756e2 |
GENERAL.CONNECTION: My Alfa WiFi
|
|
Packit |
5756e2 |
GENERAL.CON-UUID: 85194f4c-d496-4eec-bae0-d880b4cbcf26
|
|
Packit |
5756e2 |
GENERAL.CON-PATH: /org/freedesktop/NetworkManager/ActiveConnection/
|
|
Packit |
5756e2 |
10
|
|
Packit |
5756e2 |
---------------------------------------------------------------------------
|
|
Packit |
5756e2 |
WIFI-PROPERTIES.WEP: yes
|
|
Packit |
5756e2 |
WIFI-PROPERTIES.WPA: yes
|
|
Packit |
5756e2 |
WIFI-PROPERTIES.WPA2: yes
|
|
Packit |
5756e2 |
WIFI-PROPERTIES.TKIP: yes
|
|
Packit |
5756e2 |
WIFI-PROPERTIES.CCMP: yes
|
|
Packit |
5756e2 |
WIFI-PROPERTIES.AP: no
|
|
Packit |
5756e2 |
WIFI-PROPERTIES.ADHOC: yes
|
|
Packit |
5756e2 |
---------------------------------------------------------------------------
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
This command shows information about a Wi-Fi device.
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
Example 4. Listing NetworkManager polkit permissions
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
$ nmcli general permissions
|
|
Packit |
5756e2 |
PERMISSION VALUE
|
|
Packit |
5756e2 |
org.freedesktop.NetworkManager.enable-disable-network yes
|
|
Packit |
5756e2 |
org.freedesktop.NetworkManager.enable-disable-wifi yes
|
|
Packit |
5756e2 |
org.freedesktop.NetworkManager.enable-disable-wwan yes
|
|
Packit |
5756e2 |
org.freedesktop.NetworkManager.enable-disable-wimax yes
|
|
Packit |
5756e2 |
org.freedesktop.NetworkManager.sleep-wake no
|
|
Packit |
5756e2 |
org.freedesktop.NetworkManager.network-control yes
|
|
Packit |
5756e2 |
org.freedesktop.NetworkManager.wifi.share.protected yes
|
|
Packit |
5756e2 |
org.freedesktop.NetworkManager.wifi.share.open yes
|
|
Packit |
5756e2 |
org.freedesktop.NetworkManager.settings.modify.system yes
|
|
Packit |
5756e2 |
org.freedesktop.NetworkManager.settings.modify.own yes
|
|
Packit |
5756e2 |
org.freedesktop.NetworkManager.settings.modify.hostname auth
|
|
Packit |
5756e2 |
org.freedesktop.NetworkManager.settings.modify.global-dns auth
|
|
Packit |
5756e2 |
org.freedesktop.NetworkManager.reload auth
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
This command shows configured polkit permissions for various NetworkManager
|
|
Packit |
5756e2 |
operations. These permissions or actions (using polkit language) are configured
|
|
Packit |
5756e2 |
by a system administrator and are not meant to be changed by users. The usual
|
|
Packit |
5756e2 |
place for the polkit configuration is /usr/share/polkit-1/actions/org.freedesktop.NetworkManager.policy.
|
|
Packit |
5756e2 |
pkaction command can display description for polkit actions.
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
pkaction --action-id org.freedesktop.NetworkManager.network-control --verbose
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
More information about polkit can be found at http://www.freedesktop.org/wiki/Software/polkit.
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
Example 5. Listing NetworkManager log level and domains
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
$ nmcli general logging
|
|
Packit |
5756e2 |
LEVEL DOMAINS
|
|
Packit |
5756e2 |
INFO PLATFORM,RFKILL,ETHER,WIFI,BT,MB,DHCP4,DHCP6,PPP,WIFI_SCAN,IP4,IP6,A
|
|
Packit |
5756e2 |
UTOIP4,DNS,VPN,SHARING,SUPPLICANT,AGENTS,SETTINGS,SUSPEND,CORE,DEVICE,OLPC,
|
|
Packit |
5756e2 |
WIMAX,INFINIBAND,FIREWALL,ADSL,BOND,VLAN,BRIDGE,DBUS_PROPS,TEAM,CONCHECK,DC
|
|
Packit |
5756e2 |
B,DISPATCH
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
This command shows current NetworkManager logging status.
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
Example 6. Changing NetworkManager logging
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
$ nmcli g log level DEBUG domains CORE,ETHER,IP
|
|
Packit |
5756e2 |
$ nmcli g log level INFO domains DEFAULT
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
The first command makes NetworkManager log in DEBUG level, and only for CORE, ETHER and
|
|
Packit |
5756e2 |
IP domains. The second command restores the default logging state. Please refer to the
|
|
Packit |
5756e2 |
NetworkManager.conf(5) manual page
|
|
Packit |
5756e2 |
for available logging levels and domains.
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
Example 7. Activating a VPN connection profile requiring interactive password input
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
$ nmcli --ask con up my-vpn-con
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
This command activates a VPN connection profile enabling nmcli to interact with the user
|
|
Packit |
5756e2 |
('--ask'): this will allow nmcli to prompt for the VPN password on the command line when
|
|
Packit |
5756e2 |
the password-flags are set to '0x02' ('always ask', see
|
|
Packit |
5756e2 |
nm-settings(5)
|
|
Packit |
5756e2 |
).
|
|
Packit |
5756e2 |
This is particularly useful for OTP based VPNs, as the user needs to be prompted for the
|
|
Packit |
5756e2 |
password each time the connection is activated.
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
Example 8. Adding a bonding master and two slave connection profiles
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
$ nmcli con add type bond ifname mybond0 mode active-backup
|
|
Packit |
5756e2 |
$ nmcli con add type ethernet ifname eth1 master mybond0
|
|
Packit |
5756e2 |
$ nmcli con add type ethernet ifname eth2 master mybond0
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
This example demonstrates adding a bond master connection and two slaves. The
|
|
Packit |
5756e2 |
first command adds a master bond connection, naming the bonding interface
|
|
Packit |
5756e2 |
mybond0 and using active-backup mode.
|
|
Packit |
5756e2 |
The next two commands add slaves connections, both enslaved to mybond0.
|
|
Packit |
5756e2 |
The first slave will be bound to eth1 interface, the second to
|
|
Packit |
5756e2 |
eth2.
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
Example 9. Adding a team master and two slave connection profiles
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
$ nmcli con add type team con-name Team1 ifname Team1 config team1-master-json.conf
|
|
Packit |
5756e2 |
$ nmcli con add type ethernet con-name Team1-slave1 ifname em1 master Team1
|
|
Packit |
5756e2 |
$ nmcli con add type ethernet con-name Team1-slave2 ifname em2 master Team1
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
This example demonstrates adding a team master connection profile and two slaves. It is
|
|
Packit |
5756e2 |
very similar to the bonding example. The first command adds a master team profile, naming
|
|
Packit |
5756e2 |
the team interface and the profile Team1. The team configuration
|
|
Packit |
5756e2 |
for the master is read from team1-master-json.conf file. Later, you can
|
|
Packit |
5756e2 |
change the configuration with modify command
|
|
Packit |
5756e2 |
(nmcli con modify Team1 team.config team1-master-another-json.conf).
|
|
Packit |
5756e2 |
The last two commands add slaves profiles, both enslaved to Team1.
|
|
Packit |
5756e2 |
The first slave will be bound to the em1 interface, the second to
|
|
Packit |
5756e2 |
em2. The slaves don't specify config and thus
|
|
Packit |
5756e2 |
teamd will use its default configuration. You will activate the whole setup
|
|
Packit |
5756e2 |
by activating both slaves:
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
$ nmcli con up Team1-slave1
|
|
Packit |
5756e2 |
$ nmcli con up Team1-slave2
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
By default, the created profiles are marked for auto-activation. But if another
|
|
Packit |
5756e2 |
connection has been activated on the device, the new profile won't activate
|
|
Packit |
5756e2 |
automatically and you need to activate it manually.
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
Example 10. Adding a bridge and two slave profiles
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
$ nmcli con add type bridge con-name TowerBridge ifname TowerBridge
|
|
Packit |
5756e2 |
$ nmcli con add type ethernet con-name br-slave-1 ifname ens3 master TowerBridge
|
|
Packit |
5756e2 |
$ nmcli con add type ethernet con-name br-slave-2 ifname ens4 master TowerBridge
|
|
Packit |
5756e2 |
$ nmcli con modify TowerBridge bridge.stp no
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
This example demonstrates adding a bridge master connection and two slaves. The
|
|
Packit |
5756e2 |
first command adds a master bridge connection, naming the bridge interface and
|
|
Packit |
5756e2 |
the profile as TowerBridge.
|
|
Packit |
5756e2 |
The next two commands add slaves profiles, both will be enslaved to
|
|
Packit |
5756e2 |
TowerBridge.
|
|
Packit |
5756e2 |
The first slave will be tied to ens3 interface, the second to
|
|
Packit |
5756e2 |
ens4.
|
|
Packit |
5756e2 |
The last command will disable 802.1D STP for the TowerBridge profile.
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
Example 11. Adding an ethernet connection profile with manual IP configuration
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
$ nmcli con add con-name my-con-em1 ifname em1 type ethernet \
|
|
Packit |
5756e2 |
ip4 192.168.100.100/24 gw4 192.168.100.1 ip4 1.2.3.4 ip6 abbe::cafe
|
|
Packit |
5756e2 |
$ nmcli con mod my-con-em1 ipv4.dns "8.8.8.8 8.8.4.4"
|
|
Packit |
5756e2 |
$ nmcli con mod my-con-em1 +ipv4.dns 1.2.3.4
|
|
Packit |
5756e2 |
$ nmcli con mod my-con-em1 ipv6.dns "2001:4860:4860::8888 2001:4860:4860::8844"
|
|
Packit |
5756e2 |
$ nmcli -p con show my-con-em1
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
The first command adds an Ethernet connection profile named my-con-em1
|
|
Packit |
5756e2 |
that is bound to interface name em1. The profile is configured
|
|
Packit |
5756e2 |
with static IP addresses. Three addresses are added, two IPv4 addresses and one IPv6.
|
|
Packit |
5756e2 |
The first IP 192.168.100.100 has a prefix of 24 (netmask equivalent of 255.255.255.0).
|
|
Packit |
5756e2 |
Gateway entry will become the default route if this profile is activated on em1 interface
|
|
Packit |
5756e2 |
(and there is no connection with higher priority). The next two addresses do not
|
|
Packit |
5756e2 |
specify a prefix, so a default prefix will be used, i.e. 32 for IPv4 and 128 for IPv6.
|
|
Packit |
5756e2 |
The second, third and fourth commands modify DNS parameters of the new connection profile.
|
|
Packit |
5756e2 |
The last con show command displays the profile so that all
|
|
Packit |
5756e2 |
parameters can be reviewed.
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
Example 12. Convenient field values retrieval for scripting
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
$ nmcli -g ip4.address connection show my-con-eth0
|
|
Packit |
5756e2 |
192.168.1.12/24
|
|
Packit |
5756e2 |
$ nmcli -g ip4.address,ip4.dns connection show my-con-eth0
|
|
Packit |
5756e2 |
192.168.1.12/24
|
|
Packit |
5756e2 |
192.168.1.1
|
|
Packit |
5756e2 |
$ nmcli -g ip4 connection show my-con-eth0
|
|
Packit |
5756e2 |
IP4:192.168.1.12/24:192.168.1.1::192.168.1.1::
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
This example shows retrieval of ip4 connection field values via the --get-values
|
|
Packit |
5756e2 |
option. Multiple comma separated fields can be provided: they will be printed one
|
|
Packit |
5756e2 |
per line. If a whole section is provided instead of a single field, the name of the
|
|
Packit |
5756e2 |
section will be printed followed by all the related field values on the same line.
|
|
Packit |
5756e2 |
See also --terse, --mode, --fields and --escape options in nmcli(1)
|
|
Packit |
5756e2 |
manual page for more customized output.
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
Example 13. Adding an Ethernet connection and configuring SR-IOV VFs
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
$ nmcli con add type ethernet con-name EthernetPF ifname em1
|
|
Packit |
5756e2 |
$ nmcli con modify EthernetPF sriov.total-vfs 3 sriov.autoprobe-drivers false
|
|
Packit |
5756e2 |
$ nmcli con modify EthernetPF sriov.vfs '0 mac=00:11:22:33:44:55 vlans=10, 1 trust=true spoof-check=false'
|
|
Packit |
5756e2 |
$ nmcli con modify EthernetPF +sriov.vfs '2 max-tx-rate=20'
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
This example demonstrates adding an Ethernet connection for
|
|
Packit |
5756e2 |
physical function (PF) ens4 and
|
|
Packit |
5756e2 |
configuring 3 SR-IOV virtual functions (VFs) on it. The first
|
|
Packit |
5756e2 |
VF is configured with MAC address 00:11:22:33:44:55 and VLAN
|
|
Packit |
5756e2 |
10, the second one has the trust and
|
|
Packit |
5756e2 |
spoof-check features respectively enabled
|
|
Packit |
5756e2 |
and disabled. VF number 2 has a maximum transmission rate of
|
|
Packit |
5756e2 |
20Mbps. The kernel is instructed to not automatically
|
|
Packit |
5756e2 |
instantiate a network interface for the VFs.
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
Example 14. Escaping colon characters in tabular mode
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
$ nmcli -t -f general -e yes -m tab dev show eth0
|
|
Packit |
5756e2 |
GENERAL:eth0:ethernet:Intel Corporation:82567LM Gigabit Network Connection:
|
|
Packit |
5756e2 |
e1000e:2.1.4-k:1.8-3:00\:22\:68\:15\:29\:21:1500:100 (connected):0 (No reas
|
|
Packit |
5756e2 |
on given):/sys/devices/pci0000\:00/0000\:00\:19.0/net/eth0:eth0:yes:yes:no:
|
|
Packit |
5756e2 |
ethernet-13:89cbcbc6-dc85-456c-9c8b-bd828fee3917:/org/freedesktop/NetworkMa
|
|
Packit |
5756e2 |
nager/ActiveConnection/9
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
This example shows escaping colon characters in tabular mode. It may be
|
|
Packit |
5756e2 |
useful for script processing, because ':' is used as a field separator.
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
Example 15. nmcli usage in a NetworkManager dispatcher script to make Ethernet and Wi-Fi mutually exclusive
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
#!/bin/bash
|
|
Packit |
5756e2 |
export LC_ALL=C
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
enable_disable_wifi ()
|
|
Packit |
5756e2 |
{
|
|
Packit |
5756e2 |
result=$(nmcli dev | grep "ethernet" | grep -w "connected")
|
|
Packit |
5756e2 |
if [ -n "$result" ]; then
|
|
Packit |
5756e2 |
nmcli radio wifi off
|
|
Packit |
5756e2 |
else
|
|
Packit |
5756e2 |
nmcli radio wifi on
|
|
Packit |
5756e2 |
fi
|
|
Packit |
5756e2 |
}
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
if [ "$2" = "up" ]; then
|
|
Packit |
5756e2 |
enable_disable_wifi
|
|
Packit |
5756e2 |
fi
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
if [ "$2" = "down" ]; then
|
|
Packit |
5756e2 |
enable_disable_wifi
|
|
Packit |
5756e2 |
fi
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
This dispatcher script makes Wi-Fi mutually exclusive with wired
|
|
Packit |
5756e2 |
networking. When a wired interface is connected, Wi-Fi will be set
|
|
Packit |
5756e2 |
to airplane mode (rfkilled). When the wired interface is disconnected,
|
|
Packit |
5756e2 |
Wi-Fi will be turned back on.
|
|
Packit |
5756e2 |
Name this script e.g. 70-wifi-wired-exclusive.sh and put it into /etc/NetworkManager/dispatcher.d/
|
|
Packit |
5756e2 |
directory.
|
|
Packit |
5756e2 |
See NetworkManager(8)
|
|
Packit |
5756e2 |
manual page for more information about NetworkManager dispatcher scripts.
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
Example sessions of interactive connection editor
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
Example 16. Adding an ethernet connection profile in interactive editor (a)
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
$ nmcli connection edit type ethernet
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
===| nmcli interactive connection editor |===
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
Adding a new '802-3-ethernet' connection
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
Type 'help' or '?' for available commands.
|
|
Packit |
5756e2 |
Type 'describe [<setting>.<prop>]' for detailed property description.
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
You may edit the following settings: connection, 802-3-ethernet (ethernet),
|
|
Packit |
5756e2 |
802-1x, ipv4, ipv6, dcb
|
|
Packit |
5756e2 |
nmcli> print
|
|
Packit |
5756e2 |
===========================================================================
|
|
Packit |
5756e2 |
Connection details
|
|
Packit |
5756e2 |
===========================================================================
|
|
Packit |
5756e2 |
connection.id: ethernet-4
|
|
Packit |
5756e2 |
connection.uuid: de89cdeb-a3e1-4d53-8fa0-c22546c775f4
|
|
Packit |
5756e2 |
connection.interface-name: --
|
|
Packit |
5756e2 |
connection.type: 802-3-ethernet
|
|
Packit |
5756e2 |
connection.autoconnect: yes
|
|
Packit |
5756e2 |
connection.autoconnect-priority: 0
|
|
Packit |
5756e2 |
connection.timestamp: 0
|
|
Packit |
5756e2 |
connection.read-only: no
|
|
Packit |
5756e2 |
connection.permissions:
|
|
Packit |
5756e2 |
connection.zone: --
|
|
Packit |
5756e2 |
connection.master: --
|
|
Packit |
5756e2 |
connection.slave-type: --
|
|
Packit |
5756e2 |
connection.secondaries:
|
|
Packit |
5756e2 |
connection.gateway-ping-timeout: 0
|
|
Packit |
5756e2 |
---------------------------------------------------------------------------
|
|
Packit |
5756e2 |
802-3-ethernet.port: --
|
|
Packit |
5756e2 |
802-3-ethernet.speed: 0
|
|
Packit |
5756e2 |
802-3-ethernet.duplex: --
|
|
Packit |
5756e2 |
802-3-ethernet.auto-negotiate: yes
|
|
Packit |
5756e2 |
802-3-ethernet.mac-address: --
|
|
Packit |
5756e2 |
802-3-ethernet.cloned-mac-address: --
|
|
Packit |
5756e2 |
802-3-ethernet.mac-address-blacklist:
|
|
Packit |
5756e2 |
802-3-ethernet.mtu: auto
|
|
Packit |
5756e2 |
802-3-ethernet.s390-subchannels:
|
|
Packit |
5756e2 |
802-3-ethernet.s390-nettype: --
|
|
Packit |
5756e2 |
802-3-ethernet.s390-options:
|
|
Packit |
5756e2 |
---------------------------------------------------------------------------
|
|
Packit |
5756e2 |
ipv4.method: auto
|
|
Packit |
5756e2 |
ipv4.dns:
|
|
Packit |
5756e2 |
ipv4.dns-search:
|
|
Packit |
5756e2 |
ipv4.addresses:
|
|
Packit |
5756e2 |
ipv4.gateway: --
|
|
Packit |
5756e2 |
ipv4.routes:
|
|
Packit |
5756e2 |
ipv4.route-metric: -1
|
|
Packit |
5756e2 |
ipv4.ignore-auto-routes: no
|
|
Packit |
5756e2 |
ipv4.ignore-auto-dns: no
|
|
Packit |
5756e2 |
ipv4.dhcp-client-id: --
|
|
Packit |
5756e2 |
ipv4.dhcp-send-hostname: yes
|
|
Packit |
5756e2 |
ipv4.dhcp-hostname: --
|
|
Packit |
5756e2 |
ipv4.never-default: no
|
|
Packit |
5756e2 |
ipv4.may-fail: yes
|
|
Packit |
5756e2 |
---------------------------------------------------------------------------
|
|
Packit |
5756e2 |
ipv6.method: auto
|
|
Packit |
5756e2 |
ipv6.dns:
|
|
Packit |
5756e2 |
ipv6.dns-search:
|
|
Packit |
5756e2 |
ipv6.addresses:
|
|
Packit |
5756e2 |
ipv6.gateway: --
|
|
Packit |
5756e2 |
ipv6.routes:
|
|
Packit |
5756e2 |
ipv6.route-metric: -1
|
|
Packit |
5756e2 |
ipv6.ignore-auto-routes: no
|
|
Packit |
5756e2 |
ipv6.ignore-auto-dns: no
|
|
Packit |
5756e2 |
ipv6.never-default: no
|
|
Packit |
5756e2 |
ipv6.may-fail: yes
|
|
Packit |
5756e2 |
ipv6.ip6-privacy: -1 (unknown)
|
|
Packit |
5756e2 |
ipv6.dhcp-hostname: --
|
|
Packit |
5756e2 |
---------------------------------------------------------------------------
|
|
Packit |
5756e2 |
nmcli> goto ethernet
|
|
Packit |
5756e2 |
You may edit the following properties: port, speed, duplex, auto-negotiate,
|
|
Packit |
5756e2 |
mac-address, cloned-mac-address, mac-address-blacklist, mtu, s390-subchann
|
|
Packit |
5756e2 |
els, s390-nettype, s390-options
|
|
Packit |
5756e2 |
nmcli 802-3-ethernet> set mtu 1492
|
|
Packit |
5756e2 |
nmcli 802-3-ethernet> b
|
|
Packit |
5756e2 |
nmcli> goto ipv4.addresses
|
|
Packit |
5756e2 |
nmcli ipv4.addresses> desc
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
=== [addresses] ===
|
|
Packit |
5756e2 |
[NM property description]
|
|
Packit |
5756e2 |
Array of IP addresses.
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
[nmcli specific description]
|
|
Packit |
5756e2 |
Enter a list of IPv4 addresses formatted as:
|
|
Packit |
5756e2 |
ip[/prefix], ip[/prefix],...
|
|
Packit |
5756e2 |
Missing prefix is regarded as prefix of 32.
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
Example: 192.168.1.5/24, 10.0.0.11/24
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
nmcli ipv4.addresses> set 192.168.1.100/24
|
|
Packit |
5756e2 |
Do you also want to set 'ipv4.method' to 'manual'? [yes]: yes
|
|
Packit |
5756e2 |
nmcli ipv4.addresses>
|
|
Packit |
5756e2 |
nmcli ipv4.addresses> print
|
|
Packit |
5756e2 |
addresses: 192.168.1.100/24
|
|
Packit |
5756e2 |
nmcli ipv4.addresses> back
|
|
Packit |
5756e2 |
nmcli ipv4> b
|
|
Packit |
5756e2 |
nmcli> set ipv4.gateway 192.168.1.1
|
|
Packit |
5756e2 |
nmcli> verify
|
|
Packit |
5756e2 |
Verify connection: OK
|
|
Packit |
5756e2 |
nmcli> print
|
|
Packit |
5756e2 |
===========================================================================
|
|
Packit |
5756e2 |
Connection details
|
|
Packit |
5756e2 |
===========================================================================
|
|
Packit |
5756e2 |
connection.id: ethernet-4
|
|
Packit |
5756e2 |
connection.uuid: de89cdeb-a3e1-4d53-8fa0-c22546c775f4
|
|
Packit |
5756e2 |
connection.interface-name: --
|
|
Packit |
5756e2 |
connection.type: 802-3-ethernet
|
|
Packit |
5756e2 |
connection.autoconnect: yes
|
|
Packit |
5756e2 |
connection.autoconnect-priority: 0
|
|
Packit |
5756e2 |
connection.timestamp: 0
|
|
Packit |
5756e2 |
connection.read-only: no
|
|
Packit |
5756e2 |
connection.permissions:
|
|
Packit |
5756e2 |
connection.zone: --
|
|
Packit |
5756e2 |
connection.master: --
|
|
Packit |
5756e2 |
connection.slave-type: --
|
|
Packit |
5756e2 |
connection.secondaries:
|
|
Packit |
5756e2 |
connection.gateway-ping-timeout: 0
|
|
Packit |
5756e2 |
---------------------------------------------------------------------------
|
|
Packit |
5756e2 |
802-3-ethernet.port: --
|
|
Packit |
5756e2 |
802-3-ethernet.speed: 0
|
|
Packit |
5756e2 |
802-3-ethernet.duplex: --
|
|
Packit |
5756e2 |
802-3-ethernet.auto-negotiate: yes
|
|
Packit |
5756e2 |
802-3-ethernet.mac-address: --
|
|
Packit |
5756e2 |
802-3-ethernet.cloned-mac-address: --
|
|
Packit |
5756e2 |
802-3-ethernet.mac-address-blacklist:
|
|
Packit |
5756e2 |
802-3-ethernet.mtu: 1492
|
|
Packit |
5756e2 |
802-3-ethernet.s390-subchannels:
|
|
Packit |
5756e2 |
802-3-ethernet.s390-nettype: --
|
|
Packit |
5756e2 |
802-3-ethernet.s390-options:
|
|
Packit |
5756e2 |
---------------------------------------------------------------------------
|
|
Packit |
5756e2 |
ipv4.method: manual
|
|
Packit |
5756e2 |
ipv4.dns:
|
|
Packit |
5756e2 |
ipv4.dns-search:
|
|
Packit |
5756e2 |
ipv4.addresses: 192.168.1.100/24
|
|
Packit |
5756e2 |
ipv4.gateway: 192.168.1.1
|
|
Packit |
5756e2 |
ipv4.routes:
|
|
Packit |
5756e2 |
ipv4.route-metric: -1
|
|
Packit |
5756e2 |
ipv4.ignore-auto-routes: no
|
|
Packit |
5756e2 |
ipv4.ignore-auto-dns: no
|
|
Packit |
5756e2 |
ipv4.dhcp-client-id: --
|
|
Packit |
5756e2 |
ipv4.dhcp-send-hostname: yes
|
|
Packit |
5756e2 |
ipv4.dhcp-hostname: --
|
|
Packit |
5756e2 |
ipv4.never-default: no
|
|
Packit |
5756e2 |
ipv4.may-fail: yes
|
|
Packit |
5756e2 |
---------------------------------------------------------------------------
|
|
Packit |
5756e2 |
ipv6.method: auto
|
|
Packit |
5756e2 |
ipv6.dns:
|
|
Packit |
5756e2 |
ipv6.dns-search:
|
|
Packit |
5756e2 |
ipv6.addresses:
|
|
Packit |
5756e2 |
ipv6.routes:
|
|
Packit |
5756e2 |
ipv6.route-metric: -1
|
|
Packit |
5756e2 |
ipv6.ignore-auto-routes: no
|
|
Packit |
5756e2 |
ipv6.ignore-auto-dns: no
|
|
Packit |
5756e2 |
ipv6.never-default: no
|
|
Packit |
5756e2 |
ipv6.may-fail: yes
|
|
Packit |
5756e2 |
ipv6.ip6-privacy: -1 (unknown)
|
|
Packit |
5756e2 |
ipv6.dhcp-hostname: --
|
|
Packit |
5756e2 |
---------------------------------------------------------------------------
|
|
Packit |
5756e2 |
nmcli> set ipv4.dns 8.8.8.8 8.8.4.4
|
|
Packit |
5756e2 |
nmcli> print
|
|
Packit |
5756e2 |
===========================================================================
|
|
Packit |
5756e2 |
Connection details
|
|
Packit |
5756e2 |
===========================================================================
|
|
Packit |
5756e2 |
connection.id: ethernet-4
|
|
Packit |
5756e2 |
connection.uuid: de89cdeb-a3e1-4d53-8fa0-c22546c775f4
|
|
Packit |
5756e2 |
connection.interface-name: --
|
|
Packit |
5756e2 |
connection.type: 802-3-ethernet
|
|
Packit |
5756e2 |
connection.autoconnect: yes
|
|
Packit |
5756e2 |
connection.autoconnect-priority: 0
|
|
Packit |
5756e2 |
connection.timestamp: 0
|
|
Packit |
5756e2 |
connection.read-only: no
|
|
Packit |
5756e2 |
connection.permissions:
|
|
Packit |
5756e2 |
connection.zone: --
|
|
Packit |
5756e2 |
connection.master: --
|
|
Packit |
5756e2 |
connection.slave-type: --
|
|
Packit |
5756e2 |
connection.secondaries:
|
|
Packit |
5756e2 |
connection.gateway-ping-timeout: 0
|
|
Packit |
5756e2 |
---------------------------------------------------------------------------
|
|
Packit |
5756e2 |
802-3-ethernet.port: --
|
|
Packit |
5756e2 |
802-3-ethernet.speed: 0
|
|
Packit |
5756e2 |
802-3-ethernet.duplex: --
|
|
Packit |
5756e2 |
802-3-ethernet.auto-negotiate: yes
|
|
Packit |
5756e2 |
802-3-ethernet.mac-address: --
|
|
Packit |
5756e2 |
802-3-ethernet.cloned-mac-address: --
|
|
Packit |
5756e2 |
802-3-ethernet.mac-address-blacklist:
|
|
Packit |
5756e2 |
802-3-ethernet.mtu: 1492
|
|
Packit |
5756e2 |
802-3-ethernet.s390-subchannels:
|
|
Packit |
5756e2 |
802-3-ethernet.s390-nettype: --
|
|
Packit |
5756e2 |
802-3-ethernet.s390-options:
|
|
Packit |
5756e2 |
---------------------------------------------------------------------------
|
|
Packit |
5756e2 |
ipv4.method: manual
|
|
Packit |
5756e2 |
ipv4.dns: 8.8.8.8,8.8.4.4
|
|
Packit |
5756e2 |
ipv4.dns-search:
|
|
Packit |
5756e2 |
ipv4.addresses: 192.168.1.100/24
|
|
Packit |
5756e2 |
ipv4.gateway: 192.168.1.1
|
|
Packit |
5756e2 |
ipv4.routes:
|
|
Packit |
5756e2 |
ipv4.route-metric: -1
|
|
Packit |
5756e2 |
ipv4.ignore-auto-routes: no
|
|
Packit |
5756e2 |
ipv4.ignore-auto-dns: no
|
|
Packit |
5756e2 |
ipv4.dhcp-client-id: --
|
|
Packit |
5756e2 |
ipv4.dhcp-send-hostname: yes
|
|
Packit |
5756e2 |
ipv4.dhcp-hostname: --
|
|
Packit |
5756e2 |
ipv4.never-default: no
|
|
Packit |
5756e2 |
ipv4.may-fail: yes
|
|
Packit |
5756e2 |
---------------------------------------------------------------------------
|
|
Packit |
5756e2 |
ipv6.method: auto
|
|
Packit |
5756e2 |
ipv6.dns:
|
|
Packit |
5756e2 |
ipv6.dns-search:
|
|
Packit |
5756e2 |
ipv6.addresses:
|
|
Packit |
5756e2 |
ipv6.gateway: --
|
|
Packit |
5756e2 |
ipv6.routes:
|
|
Packit |
5756e2 |
ipv6.route-metric: -1
|
|
Packit |
5756e2 |
ipv6.ignore-auto-routes: no
|
|
Packit |
5756e2 |
ipv6.ignore-auto-dns: no
|
|
Packit |
5756e2 |
ipv6.never-default: no
|
|
Packit |
5756e2 |
ipv6.may-fail: yes
|
|
Packit |
5756e2 |
ipv6.ip6-privacy: -1 (unknown)
|
|
Packit |
5756e2 |
ipv6.dhcp-hostname: --
|
|
Packit |
5756e2 |
---------------------------------------------------------------------------
|
|
Packit |
5756e2 |
nmcli> verify
|
|
Packit |
5756e2 |
Verify connection: OK
|
|
Packit |
5756e2 |
nmcli> save
|
|
Packit |
5756e2 |
Connection 'ethernet-4' (de89cdeb-a3e1-4d53-8fa0-c22546c775f4) successfully
|
|
Packit |
5756e2 |
saved.
|
|
Packit |
5756e2 |
nmcli> quit
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
Example session in the nmcli interactive connection editor.
|
|
Packit |
5756e2 |
The scenario creates an Ethernet connection profile with static addressing (IPs and DNS).
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
Example 17. Bluetooth connection profiles
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
NetworkManger supports both connecting to NAP and DUN devices as a client. It also
|
|
Packit |
5756e2 |
supports sharing the network via a NAP server.
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
For NAP client connections, NetworkManager automatically creates a suitable in-memory profile
|
|
Packit |
5756e2 |
for paired devices if none is available. You may use that generated profile directly, but you may also modify
|
|
Packit |
5756e2 |
and persist it, which will prevent to automatically re-create it. You may also create a profile from scratch.
|
|
Packit |
5756e2 |
For example, the following uses DHCP and IPv6 autoconf for address configuration:
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
$ nmcli connection add type bluetooth con-name "Profile for My Bluetooth Device (NAP)" autoconnect no bluetooth.type panu bluetooth.bdaddr "$BDADDR"
|
|
Packit |
5756e2 |
For DUN connections, the user needs to configure modem settings and hence no profile
|
|
Packit |
5756e2 |
gets created automatically. The modem settings depend on your device and you either need
|
|
Packit |
5756e2 |
a "gsm" or a "csma" section. For example,
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
$ nmcli connection add type bluetooth con-name "Profile for My Bluetooth Device (DUN)" autoconnect no bluetooth.type dun bluetooth.bdaddr "$BDADDR" gsm.apn apn.com
|
|
Packit |
5756e2 |
Finally, you can create a bluetooth hotspot. BlueZ implements those as a bridge device,
|
|
Packit |
5756e2 |
so such profiles also have a bridge section. Also, you probably want to set IP methods as "shared",
|
|
Packit |
5756e2 |
so that clients get automatic IP addressing. Note that the "shared" IPv4 method requires dnsmasq to be available.
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
$ nmcli connection add type bluetooth con-name "My Bluetooth Hotspot" autoconnect no ifname btnap0 bluetooth.type nap ipv4.method shared ipv6.method shared
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
See Also
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
nmcli(1),
|
|
Packit |
5756e2 |
NetworkManager(8),
|
|
Packit |
5756e2 |
NetworkManager.conf(5),
|
|
Packit |
5756e2 |
nm-settings(5),
|
|
Packit |
5756e2 |
nm-online(1),
|
|
Packit |
5756e2 |
nm-applet(1),
|
|
Packit |
5756e2 |
nm-connection-editor(1)
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
Generated by GTK-Doc V1.32
|
|
Packit |
5756e2 |
</body>
|
|
Packit |
5756e2 |
</html>
|