---
obj: application
---

# NetworkManager
[NetworkManager](https://networkmanager.dev/) is a program for providing detection and configuration for systems to automatically connect to networks. NetworkManager's functionality can be useful for both wireless and wired networks. For wireless networks, NetworkManager prefers known wireless networks and has the ability to switch to the most reliable network. NetworkManager-aware applications can switch from online and offline mode. NetworkManager also prefers wired connections over wireless ones, has support for modem connections and certain types of VPN. NetworkManager was originally developed by Red Hat and now is hosted by the GNOME project.

After installation, you should start/enable  `NetworkManager.service`. Once the NetworkManager daemon is started, it will automatically connect to any available "system connections" that have already been configured. Any "user connections" or unconfigured connections will need _nmcli_ or an applet to configure and connect.

## Usage
NetworkManager comes with nmcli and nmtui.

### nmcli examples
List nearby Wi-Fi networks:
`nmcli device wifi list`

Connect to a Wi-Fi network:
`nmcli device wifi connect SSIDorBSSID password password`

Connect to a hidden Wi-Fi network:
`nmcli device wifi connect SSID_or_BSSID password password hidden yes`

Connect to a Wi-Fi on the `wlan1` interface:
`nmcli device wifi connect SSID_or_BSSID password password ifname wlan1 profile_name`

Disconnect an interface:
`nmcli device disconnect ifname eth0`

Get a list of connections with their names, UUIDs, types and backing devices:
`nmcli connection show`

Activate a connection (i.e. connect to a network with an existing profile):
`nmcli connection up name_or_uuid`

Delete a connection:
`nmcli connection delete name_or_uuid`

See a list of network devices and their state:
`nmcli device`

Turn off Wi-Fi:
`nmcli radio wifi off`

### Edit a connection
For a comprehensive list of settings, see [nm-settings(5)](https://man.archlinux.org/man/nm-settings.5).

Firstly you need to get list of connections:
`nmcli connection`
```
NAME                UUID                                  TYPE      DEVICE
Wired connection 2  e7054040-a421-3bef-965d-bb7d60b7cecf  ethernet  enp5s0
Wired connection 1  997f2782-f0fc-301d-bfba-15421a2735d8  ethernet  enp0s25
MY-HOME-WIFI-5G     92a0f7b3-2eba-49ab-a899-24d83978f308  wifi
```

Here you can use the first column as connection-id used later. In this example we pick `Wired connection 2` as a connection-id.

You have three methods to configure a connection `Wired connection 2` after it has been created:

nmcli interactive editor
`nmcli connection edit 'Wired connection 2'`.  
Usage is well documented from the editor.

nmcli command line interface
`nmcli connection modify 'Wired connection 2' setting.property value`. See [nmcli(1)](https://man.archlinux.org/man/nmcli.1) for usage. For example you can change its IPv4 route metric to 200 using `nmcli connection modify 'Wired connection 2' ipv4.route-metric 200` command.

To remove a setting pass an empty field ("") to it like this:
`nmcli connection modify 'Wired connection 2' setting.property ""`

Connection file
In `/etc/NetworkManager/system-connections/`, modify the corresponding `Wired connection 2.nmconnection` file .  
Do not forget to reload the configuration file with `nmcli connection reload`.

## Configuration
NetworkManager will require some additional steps to be able run properly. Make sure you have configured `/etc/hosts`.

NetworkManager has a global configuration file at `/etc/NetworkManager/NetworkManager.conf`. Additional configuration files can be placed in `/etc/NetworkManager/conf.d/`. Usually no configuration needs to be done to the global defaults.

After editing a configuration file, the changes can be applied by running:
`nmcli general reload`

### DNS
> **Note:** If `/etc/resolv.conf` is a symlink to `/run/systemd/resolve/stub-resolv.conf`, `/run/systemd/resolve/resolv.conf`,`/lib/systemd/resolv.conf` or `/usr/lib/systemd/resolv.conf`, NetworkManager will choose [systemd](../../linux/systemd/Systemd.md)-resolved automatically. To use dnsmasq, you must first remove that symlink, then restart NetworkManager.

### VPN
[WireGuard](Wireguard.md) is natively supported. To import a [WireGuard](Wireguard.md) Config File as a connection:
`nmcli connection import type wireguard file <conf_file>`
