Debian Codegraph @

man/nmcli-examples.xml

raw
1 <?xml version='1.0'?>
2 <?xml-stylesheet type="text/xsl" href="http://docbook.sourceforge.net/release/xsl/current/xhtml/docbook.xsl"?>
3 <!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
4 "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
5 <!ENTITY % entities SYSTEM "common.ent" >
6 %entities;
7 ]>
8
9 <!--
10 SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later
11
12 nmcli-examples(7) manual page
13
14 Copyright 2005 - 2022 Red Hat, Inc.
15 -->
16
17 <refentry id="nmcli-examples">
18 <refentryinfo>
19 <title>nmcli-examples</title>
20 <author>NetworkManager developers</author>
21 </refentryinfo>
22
23 <refmeta>
24 <refentrytitle>nmcli-examples</refentrytitle>
25 <manvolnum>7</manvolnum>
26 <refmiscinfo class="source">NetworkManager</refmiscinfo>
27 <refmiscinfo class="manual">Examples</refmiscinfo>
28 <refmiscinfo class="version">&NM_VERSION;</refmiscinfo>
29 </refmeta>
30
31 <refnamediv>
32 <refname>nmcli-examples</refname>
33 <refpurpose>usage examples of nmcli</refpurpose>
34 </refnamediv>
35
36 <refsynopsisdiv>
37 <cmdsynopsis>
38 <command>nmcli</command>
39 <arg choice="opt" rep="repeat">OPTIONS</arg>
40 </cmdsynopsis>
41 </refsynopsisdiv>
42
43 <refsect1>
44 <title>Description</title>
45 <para>
46 <emphasis>nmcli</emphasis> is a command-line client for NetworkManager. It
47 allows controlling NetworkManager and reporting its status. For more information
48 please refer to <link linkend='nmcli'><citerefentry><refentrytitle>nmcli</refentrytitle><manvolnum>1</manvolnum></citerefentry></link>
49 manual page.
50 </para>
51 <para>
52 The purpose of this manual page is to provide you with various examples and
53 usage scenarios of <emphasis>nmcli</emphasis>.
54 </para>
55 </refsect1>
56
57 <refsect1>
58 <title>Examples</title>
59
60 <example><title>Listing available Wi-Fi APs</title>
61 <screen><prompt>$ </prompt><userinput>nmcli device wifi list</userinput>
62 * SSID MODE CHAN RATE SIGNAL BARS SECURITY
63 netdatacomm_local Infra 6 54 Mbit/s 37 ▂▄__ WEP
64 * F1 Infra 11 54 Mbit/s 98 ▂▄▆█ WPA1
65 LoremCorp Infra 1 54 Mbit/s 62 ▂▄▆_ WPA2 802.1X
66 Internet Infra 6 54 Mbit/s 29 ▂___ WPA1
67 HPB110a.F2672A Ad-Hoc 6 54 Mbit/s 22 ▂___ --
68 Jozinet Infra 1 54 Mbit/s 19 ▂___ WEP
69 VOIP Infra 1 54 Mbit/s 20 ▂___ WEP
70 MARTINA Infra 4 54 Mbit/s 32 ▂▄__ WPA2
71 N24PU1 Infra 7 11 Mbit/s 22 ▂___ --
72 alfa Infra 1 54 Mbit/s 67 ▂▄▆_ WPA2
73 bertnet Infra 5 54 Mbit/s 20 ▂___ WPA1 WPA2</screen>
74 <para>
75 This command shows how to list available Wi-Fi networks (APs). You can also use
76 <emphasis>--fields</emphasis> option for displaying different columns.
77 <emphasis role="bold">nmcli -f all dev wifi list</emphasis> will show all of them.
78 </para>
79 </example>
80
81 <example><title>Connect to a password-protected wifi network</title>
82 <screen><prompt>$ </prompt><userinput>nmcli device wifi connect "$SSID" password "$PASSWORD"</userinput></screen>
83 <screen><prompt>$ </prompt><userinput>nmcli --ask device wifi connect "$SSID"</userinput></screen>
84 </example>
85
86 <example><title>Showing general information and properties for a Wi-Fi interface</title>
87 <screen><prompt>$ </prompt><userinput>nmcli -p -f general,wifi-properties device show wlan0</userinput>
88 ===========================================================================
89 Device details (wlan0)
90 ===========================================================================
91 GENERAL.DEVICE: wlan0
92 GENERAL.TYPE: wifi
93 GENERAL.VENDOR: Intel Corporation
94 GENERAL.PRODUCT: PRO/Wireless 5100 AGN [Shiloh] Network Connection
95 GENERAL.DRIVER: iwlwifi
96 GENERAL.DRIVER-VERSION: 3.8.13-100.fc17.x86_64
97 GENERAL.FIRMWARE-VERSION: 8.83.5.1 build 33692
98 GENERAL.HWADDR: 00:1E:65:37:A1:D3
99 GENERAL.MTU: 1500
100 GENERAL.STATE: 100 (connected)
101 GENERAL.REASON: 0 (No reason given)
102 GENERAL.UDI: /sys/devices/pci0000:00/0000:00:1c.1/net/wlan0
103 GENERAL.IP-IFACE: wlan0
104 GENERAL.IS-SOFTWARE: no
105 GENERAL.NM-MANAGED: yes
106 GENERAL.AUTOCONNECT: yes
107 GENERAL.FIRMWARE-MISSING: no
108 GENERAL.CONNECTION: My Alfa WiFi
109 GENERAL.CON-UUID: 85194f4c-d496-4eec-bae0-d880b4cbcf26
110 GENERAL.CON-PATH: /org/freedesktop/NetworkManager/ActiveConnection/
111 10
112 ---------------------------------------------------------------------------
113 WIFI-PROPERTIES.WEP: yes
114 WIFI-PROPERTIES.WPA: yes
115 WIFI-PROPERTIES.WPA2: yes
116 WIFI-PROPERTIES.TKIP: yes
117 WIFI-PROPERTIES.CCMP: yes
118 WIFI-PROPERTIES.AP: no
119 WIFI-PROPERTIES.ADHOC: yes
120 ---------------------------------------------------------------------------</screen>
121 <para>
122 This command shows information about a Wi-Fi device.
123 </para>
124 </example>
125
126 <example><title>Listing NetworkManager polkit permissions</title>
127 <screen><prompt>$ </prompt><userinput>nmcli general permissions</userinput>
128 PERMISSION VALUE
129 org.freedesktop.NetworkManager.enable-disable-network yes
130 org.freedesktop.NetworkManager.enable-disable-wifi yes
131 org.freedesktop.NetworkManager.enable-disable-wwan yes
132 org.freedesktop.NetworkManager.enable-disable-wimax yes
133 org.freedesktop.NetworkManager.sleep-wake no
134 org.freedesktop.NetworkManager.network-control yes
135 org.freedesktop.NetworkManager.wifi.share.protected yes
136 org.freedesktop.NetworkManager.wifi.share.open yes
137 org.freedesktop.NetworkManager.settings.modify.system yes
138 org.freedesktop.NetworkManager.settings.modify.own yes
139 org.freedesktop.NetworkManager.settings.modify.hostname auth
140 org.freedesktop.NetworkManager.settings.modify.global-dns auth
141 org.freedesktop.NetworkManager.reload auth</screen>
142 <para>
143 This command shows configured polkit permissions for various NetworkManager
144 operations. These permissions or actions (using polkit language) are configured
145 by a system administrator and are not meant to be changed by users. The usual
146 place for the polkit configuration is /usr/share/polkit-1/actions/org.freedesktop.NetworkManager.policy.
147 <emphasis>pkaction</emphasis> command can display description for polkit actions.
148 <synopsis><command>
149 pkaction --action-id org.freedesktop.NetworkManager.network-control --verbose
150 </command></synopsis>
151 More information about polkit can be found at http://www.freedesktop.org/wiki/Software/polkit.
152 </para>
153 </example>
154
155 <example><title>Listing NetworkManager log level and domains</title>
156 <screen><prompt>$ </prompt><userinput>nmcli general logging</userinput>
157 LEVEL DOMAINS
158 INFO PLATFORM,RFKILL,ETHER,WIFI,BT,MB,DHCP4,DHCP6,PPP,WIFI_SCAN,IP4,IP6,A
159 UTOIP4,DNS,VPN,SHARING,SUPPLICANT,AGENTS,SETTINGS,SUSPEND,CORE,DEVICE,OLPC,
160 WIMAX,INFINIBAND,FIREWALL,ADSL,BOND,VLAN,BRIDGE,DBUS_PROPS,TEAM,CONCHECK,DC
161 B,DISPATCH</screen>
162 <para>
163 This command shows current NetworkManager logging status.
164 </para>
165 </example>
166 <example><title>Changing NetworkManager logging</title>
167 <screen><prompt>$ </prompt><userinput>nmcli g log level DEBUG domains CORE,ETHER,IP</userinput>
168 <prompt>$ </prompt><userinput>nmcli g log level INFO domains DEFAULT</userinput></screen>
169 <para>
170 The first command makes NetworkManager log in DEBUG level, and only for CORE, ETHER and
171 IP domains. The second command restores the default logging state. Please refer to the
172 <link linkend='NetworkManager.conf'><citerefentry><refentrytitle>NetworkManager.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry></link> manual page
173 for available logging levels and domains.
174 </para>
175 </example>
176
177 <example><title>Activating a VPN connection profile requiring interactive password input</title>
178 <screen><prompt>$ </prompt><userinput>nmcli --ask con up my-vpn-con</userinput></screen>
179 <para>
180 This command activates a VPN connection profile enabling nmcli to interact with the user
181 ('--ask'): this will allow nmcli to prompt for the VPN password on the command line when
182 the <emphasis>password-flags</emphasis> are set to '0x02' ('always ask', see
183 <link linkend='nm-settings-nmcli'><citerefentry><refentrytitle>nm-settings-nmcli</refentrytitle><manvolnum>5</manvolnum></citerefentry></link>
184 ).
185 This is particularly useful for OTP based VPNs, as the user needs to be prompted for the
186 password each time the connection is activated.
187 </para>
188 </example>
189
190 <example><title>Adding a bonding controller and two port connection profiles</title>
191 <screen><prompt>$ </prompt><userinput>nmcli con add type bond ifname mybond0 mode active-backup</userinput>
192 <prompt>$ </prompt><userinput>nmcli con add type ethernet ifname eth1 controller mybond0</userinput>
193 <prompt>$ </prompt><userinput>nmcli con add type ethernet ifname eth2 controller mybond0</userinput></screen>
194 <para>
195 This example demonstrates adding a bond controller connection and two ports. The
196 first command adds a controller bond connection, naming the bonding interface
197 <emphasis>mybond0</emphasis> and using <emphasis>active-backup</emphasis> mode.
198 The next two commands add port connections, both attached as port to <emphasis>mybond0</emphasis>.
199 The first port will be bound to <emphasis>eth1</emphasis> interface, the second to
200 <emphasis>eth2</emphasis>.
201 </para>
202 </example>
203
204 <example><title>Adding a team controller and two port connection profiles</title>
205 <screen><prompt>$ </prompt><userinput>nmcli con add type team con-name Team1 ifname Team1 config team1-controller-json.conf</userinput>
206 <prompt>$ </prompt><userinput>nmcli con add type ethernet con-name Team1-port1 ifname em1 controller Team1</userinput>
207 <prompt>$ </prompt><userinput>nmcli con add type ethernet con-name Team1-port2 ifname em2 controller Team1</userinput></screen>
208 <para>
209 This example demonstrates adding a team controller connection profile and two ports. It is
210 very similar to the bonding example. The first command adds a controller team profile, naming
211 the team interface and the profile <emphasis>Team1</emphasis>. The team configuration
212 for the controller is read from <emphasis>team1-controller-json.conf</emphasis> file. Later, you can
213 change the configuration with <emphasis>modify</emphasis> command
214 (<emphasis role="bold">nmcli con modify Team1 team.config team1-controller-another-json.conf</emphasis>).
215 The last two commands add port profiles, both attached as port to <emphasis>Team1</emphasis>.
216 The first port will be bound to the <emphasis>em1</emphasis> interface, the second to
217 <emphasis>em2</emphasis>. The ports don't specify <emphasis>config</emphasis> and thus
218 <emphasis>teamd</emphasis> will use its default configuration. You will activate the whole setup
219 by activating both ports:
220 <screen> <prompt>$ </prompt><userinput>nmcli con up Team1-port1</userinput>
221 <prompt>$ </prompt><userinput>nmcli con up Team1-port2</userinput></screen>
222 By default, the created profiles are marked for auto-activation. But if another
223 connection has been activated on the device, the new profile won't activate
224 automatically and you need to activate it manually.
225 </para>
226 </example>
227
228 <example><title>Adding a bridge and two port profiles</title>
229 <screen><prompt>$ </prompt><userinput>nmcli con add type bridge con-name TowerBridge ifname TowerBridge</userinput>
230 <prompt>$ </prompt><userinput>nmcli con add type ethernet con-name br-port-1 ifname ens3 controller TowerBridge</userinput>
231 <prompt>$ </prompt><userinput>nmcli con add type ethernet con-name br-port-2 ifname ens4 controller TowerBridge</userinput>
232 <prompt>$ </prompt><userinput>nmcli con modify TowerBridge bridge.stp no</userinput></screen>
233 <para>
234 This example demonstrates adding a bridge controller connection and two ports. The
235 first command adds a controller bridge connection, naming the bridge interface and
236 the profile as <emphasis>TowerBridge</emphasis>.
237 The next two commands add ports profiles, both will be attached as port to
238 <emphasis>TowerBridge</emphasis>.
239 The first port will be tied to <emphasis>ens3</emphasis> interface, the second to
240 <emphasis>ens4</emphasis>.
241 The last command will disable 802.1D STP for the TowerBridge profile.
242 </para>
243 </example>
244
245 <example><title>Adding an ethernet connection profile with manual IP configuration</title>
246 <screen><prompt>$ </prompt><userinput>nmcli con add con-name my-con-em1 ifname em1 type ethernet \
247 ip4 192.168.100.100/24 gw4 192.168.100.1 ip4 1.2.3.4 ip6 abbe::cafe</userinput>
248 <prompt>$ </prompt><userinput>nmcli con mod my-con-em1 ipv4.dns "8.8.8.8 8.8.4.4"</userinput>
249 <prompt>$ </prompt><userinput>nmcli con mod my-con-em1 +ipv4.dns 1.2.3.4</userinput>
250 <prompt>$ </prompt><userinput>nmcli con mod my-con-em1 ipv6.dns "2001:4860:4860::8888 2001:4860:4860::8844"</userinput>
251 <prompt>$ </prompt><userinput>nmcli -p con show my-con-em1</userinput></screen>
252 <para>
253 The first command adds an Ethernet connection profile named <emphasis>my-con-em1</emphasis>
254 that is bound to interface name <emphasis>em1</emphasis>. The profile is configured
255 with static IP addresses. Three addresses are added, two IPv4 addresses and one IPv6.
256 The first IP 192.168.100.100 has a prefix of 24 (netmask equivalent of 255.255.255.0).
257 Gateway entry will become the default route if this profile is activated on em1 interface
258 (and there is no connection with higher priority). The next two addresses do not
259 specify a prefix, so a default prefix will be used, i.e. 32 for IPv4 and 128 for IPv6.
260 The second, third and fourth commands modify DNS parameters of the new connection profile.
261 The last <emphasis>con show</emphasis> command displays the profile so that all
262 parameters can be reviewed.
263 </para>
264 </example>
265
266 <example><title>Convenient field values retrieval for scripting</title>
267 <screen><prompt>$ </prompt><userinput>nmcli -g ip4.address connection show my-con-eth0</userinput>
268 192.168.1.12/24</screen>
269 <screen><prompt>$ </prompt><userinput>nmcli -g ip4.address,ip4.dns connection show my-con-eth0</userinput>
270 192.168.1.12/24
271 192.168.1.1</screen>
272 <screen><prompt>$ </prompt><userinput>nmcli -g ip4 connection show my-con-eth0</userinput>
273 IP4:192.168.1.12/24:192.168.1.1::192.168.1.1::</screen>
274 <para>
275 This example shows retrieval of ip4 connection field values via the --get-values
276 option. Multiple comma separated fields can be provided: they will be printed one
277 per line. If a whole section is provided instead of a single field, the name of the
278 section will be printed followed by all the related field values on the same line.
279 See also --terse, --mode, --fields and --escape options in <link linkend='nmcli'><citerefentry><refentrytitle>nmcli</refentrytitle><manvolnum>1</manvolnum></citerefentry></link>
280 manual page for more customized output.
281 </para>
282 </example>
283
284 <example><title>Adding an Ethernet connection and configuring SR-IOV VFs</title>
285 <screen><prompt>$ </prompt><userinput>nmcli con add type ethernet con-name EthernetPF ifname em1</userinput>
286 <prompt>$ </prompt><userinput>nmcli con modify EthernetPF sriov.total-vfs 3 sriov.autoprobe-drivers false</userinput>
287 <prompt>$ </prompt><userinput>nmcli con modify EthernetPF sriov.vfs '0 mac=00:11:22:33:44:55 vlans=10, 1 trust=true spoof-check=false'</userinput>
288 <prompt>$ </prompt><userinput>nmcli con modify EthernetPF +sriov.vfs '2 max-tx-rate=20'</userinput></screen>
289 <para>
290 This example demonstrates adding an Ethernet connection for
291 physical function (PF) <emphasis>ens4</emphasis> and
292 configuring 3 SR-IOV virtual functions (VFs) on it. The first
293 VF is configured with MAC address 00:11:22:33:44:55 and VLAN
294 10, the second one has the <emphasis>trust</emphasis> and
295 <emphasis>spoof-check</emphasis> features respectively enabled
296 and disabled. VF number 2 has a maximum transmission rate of
297 20Mbps. The kernel is instructed to not automatically
298 instantiate a network interface for the VFs.
299 </para>
300 </example>
301
302 <example><title>Escaping colon characters in tabular mode</title>
303 <screen><prompt>$ </prompt><userinput>nmcli -t -f general -e yes -m tab dev show eth0</userinput>
304 GENERAL:eth0:ethernet:Intel Corporation:82567LM Gigabit Network Connection:
305 e1000e:2.1.4-k:1.8-3:00\:22\:68\:15\:29\:21:1500:100 (connected):0 (No reas
306 on given):/sys/devices/pci0000\:00/0000\:00\:19.0/net/eth0:eth0:yes:yes:no:
307 ethernet-13:89cbcbc6-dc85-456c-9c8b-bd828fee3917:/org/freedesktop/NetworkMa
308 nager/ActiveConnection/9</screen>
309 <para>
310 This example shows escaping colon characters in tabular mode. It may be
311 useful for script processing, because ':' is used as a field separator.
312 </para>
313 </example>
314
315 <example><title>nmcli usage in a NetworkManager dispatcher script to make Ethernet and Wi-Fi mutually exclusive</title>
316 <programlisting language="bourne">
317 #!/bin/bash
318 export LC_ALL=C
319
320 enable_disable_wifi ()
321 {
322 result=$(nmcli dev | grep "ethernet" | grep -w "connected")
323 if [ -n "$result" ]; then
324 nmcli radio wifi off
325 else
326 nmcli radio wifi on
327 fi
328 }
329
330 if [ "$2" = "up" ]; then
331 enable_disable_wifi
332 fi
333
334 if [ "$2" = "down" ]; then
335 enable_disable_wifi
336 fi
337 </programlisting>
338 <para>
339 This dispatcher script makes Wi-Fi mutually exclusive with wired
340 networking. When a wired interface is connected, Wi-Fi will be set
341 to airplane mode (rfkilled). When the wired interface is disconnected,
342 Wi-Fi will be turned back on.
343 Name this script e.g. 70-wifi-wired-exclusive.sh and put it into /etc/NetworkManager/dispatcher.d/
344 directory.
345 See <link linkend='NetworkManager'><citerefentry><refentrytitle>NetworkManager</refentrytitle><manvolnum>8</manvolnum></citerefentry></link>
346 manual page for more information about NetworkManager dispatcher scripts.
347 </para>
348 </example>
349
350 <para><emphasis role="bold">Example sessions of interactive connection editor</emphasis></para>
351
352 <example><title>Adding an ethernet connection profile in interactive editor (a)</title>
353 <screen><prompt>$ </prompt><userinput>nmcli connection edit type ethernet</userinput>
354
355 ===| nmcli interactive connection editor |===
356
357 Adding a new '802-3-ethernet' connection
358
359 Type 'help' or '?' for available commands.
360 Type 'describe [&lt;setting&gt;.&lt;prop&gt;]' for detailed property description.
361
362 You may edit the following settings: connection, 802-3-ethernet (ethernet),
363 802-1x, ipv4, ipv6, dcb
364 <prompt>nmcli&gt; </prompt><userinput>print</userinput>
365 ===========================================================================
366 Connection details
367 ===========================================================================
368 connection.id: ethernet-4
369 connection.uuid: de89cdeb-a3e1-4d53-8fa0-c22546c775f4
370 connection.interface-name: --
371 connection.type: 802-3-ethernet
372 connection.autoconnect: yes
373 connection.autoconnect-priority: 0
374 connection.timestamp: 0
375 connection.read-only: no
376 connection.permissions:
377 connection.zone: --
378 connection.controller: --
379 connection.port-type: --
380 connection.secondaries:
381 connection.gateway-ping-timeout: 0
382 ---------------------------------------------------------------------------
383 802-3-ethernet.port: --
384 802-3-ethernet.speed: 0
385 802-3-ethernet.duplex: --
386 802-3-ethernet.auto-negotiate: yes
387 802-3-ethernet.mac-address: --
388 802-3-ethernet.cloned-mac-address: --
389 802-3-ethernet.mac-address-blacklist:
390 802-3-ethernet.mtu: auto
391 802-3-ethernet.s390-subchannels:
392 802-3-ethernet.s390-nettype: --
393 802-3-ethernet.s390-options:
394 ---------------------------------------------------------------------------
395 ipv4.method: auto
396 ipv4.dns:
397 ipv4.dns-search:
398 ipv4.addresses:
399 ipv4.gateway: --
400 ipv4.routes:
401 ipv4.route-metric: -1
402 ipv4.ignore-auto-routes: no
403 ipv4.ignore-auto-dns: no
404 ipv4.dhcp-client-id: --
405 ipv4.dhcp-send-hostname: yes
406 ipv4.dhcp-hostname: --
407 ipv4.never-default: no
408 ipv4.may-fail: yes
409 ---------------------------------------------------------------------------
410 ipv6.method: auto
411 ipv6.dns:
412 ipv6.dns-search:
413 ipv6.addresses:
414 ipv6.gateway: --
415 ipv6.routes:
416 ipv6.route-metric: -1
417 ipv6.ignore-auto-routes: no
418 ipv6.ignore-auto-dns: no
419 ipv6.never-default: no
420 ipv6.may-fail: yes
421 ipv6.ip6-privacy: -1 (unknown)
422 ipv6.dhcp-hostname: --
423 ---------------------------------------------------------------------------
424 <prompt>nmcli&gt; </prompt><userinput>goto ethernet</userinput>
425 You may edit the following properties: port, speed, duplex, auto-negotiate,
426 mac-address, cloned-mac-address, mac-address-blacklist, mtu, s390-subchann
427 els, s390-nettype, s390-options
428 nmcli 802-3-ethernet> set mtu 1492
429 nmcli 802-3-ethernet> b
430 <prompt>nmcli&gt; </prompt><userinput>goto ipv4.addresses</userinput>
431 nmcli ipv4.addresses> desc
432
433 === [addresses] ===
434 [NM property description]
435 Array of IP addresses.
436
437 [nmcli specific description]
438 Enter a list of IPv4 addresses formatted as:
439 ip[/prefix], ip[/prefix],...
440 Missing prefix is regarded as prefix of 32.
441
442 Example: 192.168.1.5/24, 10.0.0.11/24
443
444 nmcli ipv4.addresses> set 192.168.1.100/24
445 Do you also want to set 'ipv4.method' to 'manual'? [yes]: yes
446 nmcli ipv4.addresses>
447 nmcli ipv4.addresses> print
448 addresses: 192.168.1.100/24
449 nmcli ipv4.addresses> back
450 nmcli ipv4> b
451 <prompt>nmcli&gt; </prompt><userinput>set ipv4.gateway 192.168.1.1</userinput>
452 <prompt>nmcli&gt; </prompt><userinput>verify</userinput>
453 Verify connection: OK
454 <prompt>nmcli&gt; </prompt><userinput>print</userinput>
455 ===========================================================================
456 Connection details
457 ===========================================================================
458 connection.id: ethernet-4
459 connection.uuid: de89cdeb-a3e1-4d53-8fa0-c22546c775f4
460 connection.interface-name: --
461 connection.type: 802-3-ethernet
462 connection.autoconnect: yes
463 connection.autoconnect-priority: 0
464 connection.timestamp: 0
465 connection.read-only: no
466 connection.permissions:
467 connection.zone: --
468 connection.controller: --
469 connection.port-type: --
470 connection.secondaries:
471 connection.gateway-ping-timeout: 0
472 ---------------------------------------------------------------------------
473 802-3-ethernet.port: --
474 802-3-ethernet.speed: 0
475 802-3-ethernet.duplex: --
476 802-3-ethernet.auto-negotiate: yes
477 802-3-ethernet.mac-address: --
478 802-3-ethernet.cloned-mac-address: --
479 802-3-ethernet.mac-address-blacklist:
480 802-3-ethernet.mtu: 1492
481 802-3-ethernet.s390-subchannels:
482 802-3-ethernet.s390-nettype: --
483 802-3-ethernet.s390-options:
484 ---------------------------------------------------------------------------
485 ipv4.method: manual
486 ipv4.dns:
487 ipv4.dns-search:
488 ipv4.addresses: 192.168.1.100/24
489 ipv4.gateway: 192.168.1.1
490 ipv4.routes:
491 ipv4.route-metric: -1
492 ipv4.ignore-auto-routes: no
493 ipv4.ignore-auto-dns: no
494 ipv4.dhcp-client-id: --
495 ipv4.dhcp-send-hostname: yes
496 ipv4.dhcp-hostname: --
497 ipv4.never-default: no
498 ipv4.may-fail: yes
499 ---------------------------------------------------------------------------
500 ipv6.method: auto
501 ipv6.dns:
502 ipv6.dns-search:
503 ipv6.addresses:
504 ipv6.routes:
505 ipv6.route-metric: -1
506 ipv6.ignore-auto-routes: no
507 ipv6.ignore-auto-dns: no
508 ipv6.never-default: no
509 ipv6.may-fail: yes
510 ipv6.ip6-privacy: -1 (unknown)
511 ipv6.dhcp-hostname: --
512 ---------------------------------------------------------------------------
513 <prompt>nmcli&gt; </prompt><userinput>set ipv4.dns 8.8.8.8 8.8.4.4</userinput>
514 <prompt>nmcli&gt; </prompt><userinput>print</userinput>
515 ===========================================================================
516 Connection details
517 ===========================================================================
518 connection.id: ethernet-4
519 connection.uuid: de89cdeb-a3e1-4d53-8fa0-c22546c775f4
520 connection.interface-name: --
521 connection.type: 802-3-ethernet
522 connection.autoconnect: yes
523 connection.autoconnect-priority: 0
524 connection.timestamp: 0
525 connection.read-only: no
526 connection.permissions:
527 connection.zone: --
528 connection.controller: --
529 connection.port-type: --
530 connection.secondaries:
531 connection.gateway-ping-timeout: 0
532 ---------------------------------------------------------------------------
533 802-3-ethernet.port: --
534 802-3-ethernet.speed: 0
535 802-3-ethernet.duplex: --
536 802-3-ethernet.auto-negotiate: yes
537 802-3-ethernet.mac-address: --
538 802-3-ethernet.cloned-mac-address: --
539 802-3-ethernet.mac-address-blacklist:
540 802-3-ethernet.mtu: 1492
541 802-3-ethernet.s390-subchannels:
542 802-3-ethernet.s390-nettype: --
543 802-3-ethernet.s390-options:
544 ---------------------------------------------------------------------------
545 ipv4.method: manual
546 ipv4.dns: 8.8.8.8,8.8.4.4
547 ipv4.dns-search:
548 ipv4.addresses: 192.168.1.100/24
549 ipv4.gateway: 192.168.1.1
550 ipv4.routes:
551 ipv4.route-metric: -1
552 ipv4.ignore-auto-routes: no
553 ipv4.ignore-auto-dns: no
554 ipv4.dhcp-client-id: --
555 ipv4.dhcp-send-hostname: yes
556 ipv4.dhcp-hostname: --
557 ipv4.never-default: no
558 ipv4.may-fail: yes
559 ---------------------------------------------------------------------------
560 ipv6.method: auto
561 ipv6.dns:
562 ipv6.dns-search:
563 ipv6.addresses:
564 ipv6.gateway: --
565 ipv6.routes:
566 ipv6.route-metric: -1
567 ipv6.ignore-auto-routes: no
568 ipv6.ignore-auto-dns: no
569 ipv6.never-default: no
570 ipv6.may-fail: yes
571 ipv6.ip6-privacy: -1 (unknown)
572 ipv6.dhcp-hostname: --
573 ---------------------------------------------------------------------------
574 <prompt>nmcli&gt; </prompt><userinput>verify</userinput>
575 Verify connection: OK
576 <prompt>nmcli&gt; </prompt><userinput>save</userinput>
577 Connection 'ethernet-4' (de89cdeb-a3e1-4d53-8fa0-c22546c775f4) successfully
578 saved.
579 <prompt>nmcli&gt; </prompt><userinput>quit</userinput></screen>
580 <para>
581 Example session in the nmcli interactive connection editor.
582 The scenario creates an Ethernet connection profile with static addressing (IPs and DNS).
583 </para>
584 </example>
585
586 <example><title>Bluetooth connection profiles</title>
587 <para>NetworkManger supports both connecting to NAP and DUN devices as a client. It also
588 supports sharing the network via a NAP server.
589 </para>
590 <para>For NAP client connections, NetworkManager automatically creates a suitable in-memory profile
591 for paired devices if none is available. You may use that generated profile directly, but you may also modify
592 and persist it, which will prevent to automatically re-create it. You may also create a profile from scratch.
593 For example, the following uses DHCP and IPv6 autoconf for address configuration:
594 </para>
595 <screen><prompt>$ </prompt><userinput>nmcli connection add type bluetooth con-name "Profile for My Bluetooth Device (NAP)" autoconnect no bluetooth.type panu bluetooth.bdaddr "$BDADDR"</userinput></screen>
596 <para>For DUN connections, the user needs to configure modem settings and hence no profile
597 gets created automatically. The modem settings depend on your device and you either need
598 a "gsm" or a "csma" section. For example,
599 </para>
600 <screen><prompt>$ </prompt><userinput>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</userinput></screen>
601 <para>Finally, you can create a bluetooth hotspot. BlueZ implements those as a bridge device,
602 so such profiles also have a bridge section. Also, you probably want to set IP methods as "shared",
603 so that clients get automatic IP addressing. Note that the "shared" IPv4 method requires dnsmasq to be available.
604 </para>
605 <screen><prompt>$ </prompt><userinput>nmcli connection add type bluetooth con-name "My Bluetooth Hotspot" autoconnect no ifname btnap0 bluetooth.type nap ipv4.method shared ipv6.method shared</userinput></screen>
606 </example>
607
608 <example><title>Offline use</title>
609 <screen><prompt>$ </prompt><userinput>nmcli --offline con add type ethernet '
610 conn.id eth0 \
611 conn.interface-name eth0 \
612 >/sysroot/etc/NetworkManager/system-connections/eth0.nmconnection</userinput></screen>
613 <para>
614 Creates a connection file in keyfile format without using the NetworkManager service.
615 This allows for use of familiar <command>nmcli</command> syntax in situations
616 where the service is not running, such as during system installation of image
617 provisioning and ensures the resulting file is correctly formatted.
618 </para>
619 <screen><prompt>$ </prompt><userinput>nmcli --offline con modify type ethernet '
620 conn.id eth0-ipv6 \
621 ipv4.method disabled \
622 &lt;/sysroot/etc/NetworkManager/system-connections/eth0.nmconnection \
623 >/sysroot/etc/NetworkManager/system-connections/eth0-ipv6.nmconnection</userinput></screen>
624 <para>
625 Read and write a connection file without using the NetworkManager service, modifying
626 some properties along the way.
627 </para>
628 <para>
629 This allows templating of the connection profiles using familiar
630 <command>nmcli</command> syntax in situations where the service is not running.
631 </para>
632 </example>
633
634 <example><title>Device Checkpoint and Restore</title>
635
636 <screen><prompt>$ </prompt><userinput>nmcli dev checkpoint eth0 -- nmcli dev dis eth0</userinput>
637 Device 'eth0' successfully disconnected.
638 Type "Yes" to commit the changes: No
639 Checkpoint was removed.</screen>
640 <para>
641 In this example the device eth0 was disconnected with the eth0 checkpoint
642 taken. The user didn't confirm that the change is good, so the eth0 was
643 brought back to the state it was when the checkpoint was taken.
644 </para>
645 <para>
646 If the command being run unintentionaly brings down the remote connection
647 (such as a
648 <citerefentry><refentrytitle>ssh</refentrytitle><manvolnum>1</manvolnum></citerefentry>
649 session) to the very machine it's being run on, the user wouldn't be able to
650 confirm the success and the connectivity would end up being restored
651 after a timeout.
652 </para>
653 <para>
654 If, on the other hand, the command results in a success, the user could just
655 confirm, causing the checkpoint to be abandoned without a rollback:
656 </para>
657 <screen><prompt>$ </prompt><userinput>nmcli dev checkpoint -- ip link del br0</userinput>
658 Type "Yes" to commit the changes: <userinput>Yes</userinput></screen>
659 </example>
660
661 </refsect1>
662
663 <refsect1>
664 <title>See Also</title>
665 <para>
666 <link linkend='nmcli'><citerefentry><refentrytitle>nmcli</refentrytitle><manvolnum>1</manvolnum></citerefentry></link>,
667 <link linkend='NetworkManager'><citerefentry><refentrytitle>NetworkManager</refentrytitle><manvolnum>8</manvolnum></citerefentry></link>,
668 <link linkend='NetworkManager.conf'><citerefentry><refentrytitle>NetworkManager.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry></link>,
669 <link linkend='nm-settings-nmcli'><citerefentry><refentrytitle>nm-settings-nmcli</refentrytitle><manvolnum>5</manvolnum></citerefentry></link>,
670 <link linkend='nm-online'><citerefentry><refentrytitle>nm-online</refentrytitle><manvolnum>1</manvolnum></citerefentry></link>,
671 <citerefentry><refentrytitle>nm-applet</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
672 <citerefentry><refentrytitle>nm-connection-editor</refentrytitle><manvolnum>1</manvolnum></citerefentry>
673 </para>
674 </refsect1>
675 </refentry>