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