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