Configuring networks using NetworkManager
- WHAT?
The article covers the basics of NetworkManager and the usage of the CLI tool to configure the network.
- WHY?
You are using NetworkManager, and you want to configure your network.
- EFFORT
It takes approx. 15 minutes to go through this article.
- GOAL
You will have a better understanding of how NetworkManager works and how network connections can be configured.
1 About NetworkManager #
NetworkManager is a program that manages the primary network connection and other
connection interfaces. NetworkManager has been designed to be fully automatic by
default. NetworkManager is handled by systemd
and is shipped with all necessary
service unit files.
NetworkManager stores all network configurations as a connection, which is a
collection of data that describes how to create or connect to a network.
These connections are stored as files in the
/etc/NetworkManager/system-connections/
directory.
A connection is active when a particular device uses the connection. The device may have more than one connection configured, but only one can be active at a given time. The other connections can be used to fast switch from one connection to another. For example, if the active connection is not available, NetworkManager tries to connect the device to another configured connection.
To manage connections, use the nmcli
command, described
in the Section 4, “The nmcli
command reference”.
2 The NetworkManager.conf
configuration file #
The main configuration file for the NetworkManager is
/etc/NetworkManager/NetworkManager.conf
. This file can
be used to configure the behavior of NetworkManager.
The file consists of sections of key-value pairs. Each key-value pair must
belong to a section. A section starts with a name enclosed in
[]. Lines beginning with a # are
considered comments. The minimal configuration needs to include the
[main]
section with the plugins
value:
[main] plugins=keyfile
The keyfile
plug-in supports all the connection types and
capabilities of NetworkManager.
The default configuration file contains the connectivity
section that specifies the URI to check the network connection.
On SUSE Linux Micro, you can also use other sections. For details, refer to networkmanager.conf(5) or Gnome's developer guide.
3 Starting and stopping NetworkManager #
As NetworkManager is a systemd
service, you can use common systemd
commands to
start, stop, or restart NetworkManager.
To start NetworkManager:
#
systemctl start network
To restart NetworkManager:
#
systemctl restart network
To stop NetworkManager:
#
systemctl stop network
4 The nmcli
command reference #
The nmcli
command has the following generic syntax:
#
nmcli OPTIONS SUBCOMMAND SUBCOMMAND_ARGUMENTS
where OPTIONS are described in
Section 4.1, “The nmcli
command options” and
SUBCOMMAND can be any of the following:
connection
enables you to configure your network connection. For details, refer to Section 4.2, “The
connection
subcommand”.device
used for network device management. For details, refer to Section 4.3, “The
device
subcommand”.general
shows status and permissions. For details refer to Section 4.4, “The
general
subcommand”.monitor
monitors activity of NetworkManager and watches for changes in the state of connectivity and devices. This subcommand does not take any arguments.
networking
queries the networking status. For details, refer to Section 4.5, “The
networking
subcommand”.
4.1 The nmcli
command options #
Besides the subcommands and their arguments, the
nmcli
command can take the following options:
-a|--ask
The command stops its run to ask for any missing arguments, for example, for a password to connect to a network.
-c|--color {yes|no|auto}
controls the color output:
yes
to enable the colors,no
to disable them, andauto
creates color output only when the standard output is directed to a terminal.-m|--mode {tabular|multiline}
switches between
tabular
(each line describes a single entry, columns define particular properties of the entry) andmultiline
(each entry comprises more lines, each property is on its own line).tabular
is the default value.-h|--help
prints help.
-w|--wait seconds
sets a time-out period for which to wait for NetworkManager to finish operations. Using this option is recommended for commands that might take longer to complete, for example, connection activation.
4.2 The connection
subcommand #
The connection
command enables you to manage
connections or view any information about particular connections. The
nmcli connection
provides the following commands to
manage your network connections:
show
to list connections:
>
nmcli connection show
You can also use this command to show details about a specified connection:
>
nmcli connection show CONNECTION_ID
where CONNECTION_ID is any of the identifiers: a connection name, UUID or a path
up
to activate the provided connection. Use the command to reload a connection. Also run this command after you perform any change to the connection.
>
sudo
nmcli connection up [--active] [CONNECTION_ID]
When
--active
is specified, only the active profiles are displayed. The default is to display both active connections and static configuration.down
to deactivate a connection.
>
sudo
nmcli connection down CONNECTION_ID
where: CONNECTION_ID is any of the identifiers: a connection name, UUID or a path
If you deactivate the connection, it will not reconnect later even if it has the
autoconnect
flag.modify
to change or delete a property of a connection.
>
sudo
nmcli connection modify CONNECTION_ID SETTING.PROPERTY PROPERTY_VALUE
where:
CONNECTION_ID is any of the identifiers: a connection name, UUID, or a path
SETTING.PROPERTY is the name of the property, for example,
ipv4.addresses
PROPERTY_VALUE is the desired value of SETTING.PROPERTY
The following example deactivates the
autoconnect
option on theethernet1
connection:>
sudo
nmcli connection modify ethernet1 connection.autoconnect no
add
to add a connection with the provided details. The command syntax is similar to the
modify
command:>
sudo
nmcli connection add CONNECTION_ID save YES|NO SETTING.PROPERTY PROPERTY_VALUE
You should at least specify a
connection.type
or usetype
. The following example adds an Ethernet connection tied to theeth0
interface with DHCP and disables the connection'sautoconnect
flag:>
sudo
nmcli connection add type ethernet autoconnect no ifname eth0
edit
to edit an existing connection using an interactive editor.
>
sudo
nmcli connection edit CONNECTION_ID
clone
to clone an existing connection. The minimal syntax follows:
>
sudo
nmcli connection clone CONNECTION_ID NEW_NAME
where CONNECTION_ID is the connection to be cloned.
delete
to delete an existing connection:
>
sudo
nmcli connection delete CONNECTION_ID
monitor
to monitor the provided connection. Each time the connection changes, NetworkManager prints a line.
>
sudo
nmcli connection monitor CONNECTION_ID
reload
to reload all connection files from the disk. As NetworkManager does not monitor changes performed to the connection files, you need to use this command whenever you make changes to the files. This command does not take any further subcommands.
load
to load/reload a particular connection file, run:
>
sudo
nmcli connection load CONNECTION_FILE
For details about the above-mentioned commands, refer to the
nmcli
documentation.
4.3 The device
subcommand #
The device
subcommand enables you to show and manage
network interfaces. The nmcli device
command
recognizes the following commands:
status
to print the status of all devices.
>
nmcli device status
show
shows detailed information about a device. If no device is specified, all devices are displayed.
>
mcli device show [DEVICE_NAME]
connect
to connect a device. NetworkManager tries to find a suitable connection to activate. If there is no compatible connection, a new profile is created.
>
sudo
nmcli device connect DEVICE_NAME
modify
performs temporary changes to the configuration that is active on the particular device. The changes are not stored in the connection profile.
>
sudo
nmcli device modify DEVICE_NAME [+|-] SETTING.PROPERTY VALUE
For possible SETTING.PROPERTY values, refer to nm-settings-nmcli(5).
The example below starts the IPv4 shared connection sharing on the device
con1
.>
sudo
nmcli dev modify con1 ipv4.method shared
disconnect
disconnects a device and prevents the device from automatically activating further connections without manual intervention.
>
sudo
nmcli device disconnect DEVICE_NAME
delete
to delete the interface from the system. You can use the command to delete only software devices like bonds and bridges. You cannot delete hardware devices with this command.
>
sudo
nmcli device delete DEVICE_NAME
wifi
lists all available access points.
>
nmcli device wifi
wifi connect
connects to a Wi-Fi network specified by its SSID or BSSID. The command takes the following options:
password
- password for secured networksifname
- interface used for activationname
- you can give the connection a name
>
sudo
nmcli device wifi connect SSID [password PASSWORD_VALUE] [ifname INTERFACE_NAME]
To connect to a Wi-Fi GUESTWiFi with a password
pass$word2#@@
, run:>
sudo
nmcli device wifi connect GUESTWiFi password pass$word2#@@
4.4 The general
subcommand #
You can use this command to view NetworkManager status and permissions, and
change the host name and logging level. The nmcli
general
recognizes the following commands:
status
displays the overall status of NetworkManager. Whenever you do not specify a command to the
nmcli general
command, status is used by default.>
nmcli general status
hostname
if you do not provide a new host name as an argument, the current host name is displayed. If you specify a new host name, the value is used to set a new host name.
>
sudo
nmcli general hostname [HOSTNAME]
For example, to set
MyHostname
, run:>
sudo
nmcli general hostname MyHostname
permissions
shows your permission for NetworkManager operations like enabling or disabling networking, modifying connections, etc.
>
nmcli general permissions
logging
shows and changes NetworkManager logging levels and domains. Without any arguments, the command displays current logging levels and domains.
>
sudo
nmcli general logging [level LEVEL domains DOMAIN]
LEVEL is any of the values:
OFF
,ERR
,WARN
,INFO
,DEBUG
, orTRACE
.DOMAIN is a list of values that can be as follows:
PLATFORM, RFKILL, ETHER, WIFI, BT, MB, DHCP4, DHCP6, PPP, WIFI_SCAN, IP4, IP6, AUTOIP4, DNS, VPN, SHARING, SUPPLICANT, AGENTS, SETTINGS, SUSPEND, CORE, DEVICE, OLPC, WIMAX, INFINIBAND, FIREWALL, ADSL, BOND, VLAN, BRIDGE, DBUS_PROPS, TEAM, CONCHECK, DCB, DISPATCH, AUDIT, SYSTEMD, VPN_PLUGIN, PROXY
.
4.5 The networking
subcommand #
The subcommand enables you to query the status of the network. Also, by
using this command, you can enable or disable networking. The
nmcli networking
command takes the following
commands:
on/off
enables or disables networking. The
off
command deactivates all interfaces managed by NetworkManager.>
sudo
nmcli networking on
- connectivity
displays the network connectivity state. If
check
is used, NetworkManager performs a new check of the state. Otherwise, the last detected state is displayed.>
nmcli networking connectivity
Possible states are the following:
none - the host is not connected to any network.
portal - the host is behind a captive portal and cannot reach the full Internet.
limited - the host is connected to a network, but it has no access to the Internet.
full - the host is connected to a network and has full access to the Internet.
unknown - NetworkManager could not determine the network state.
5 Legal Notice #
Copyright© 2006–2025 SUSE LLC and contributors. All rights reserved.
Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or (at your option) version 1.3; with the Invariant Section being this copyright notice and license. A copy of the license version 1.2 is included in the section entitled “GNU Free Documentation License”.
For SUSE trademarks, see https://www.suse.com/company/legal/. All other third-party trademarks are the property of their respective owners. Trademark symbols (®, ™ etc.) denote trademarks of SUSE and its affiliates. Asterisks (*) denote third-party trademarks.
All information found in this book has been compiled with utmost attention to detail. However, this does not guarantee complete accuracy. Neither SUSE LLC, its affiliates, the authors, nor the translators shall be held liable for possible errors or the consequences thereof.