• sales

    +86-0755-88291180

Use NetworkManager to configure network settings

1 Introduction to NetworkManager

The NetworkManager is a utility to check network status and manage network connectivity. It can be used to manage both wireless and wired network.
The NetworkManager has a commandline utility nmcli, a commandline based GUI nmtui, and an X-Windows based GUI nm-connection-editor.

2 Images with NetworkManager

All the image files of Linux variants(Debian and Ubuntu) developed by FriendlyElec have this utility. This utility works with the following FriendlyElec boards:

2.1 Board Model

S5P4418 Based Boards:
NanoPi2 / NanoPC-T2 / NanoPi-S2 / Smart4418 / NanoPi2-Fire / NanoPi-M2 / NanoPi-M2A
S5P6818 Based Boards:
NanoPC-T3 / NanoPC-T3T / NanoPi-M3
Allwinner SoC Based Boards:
NanoPi-M1 /NanoPi-NEO /NanoPi-NEO-Air / NanoPi-M1-Plus / NanoPi-NEO2 / NanoPi-M1-Plus2 / NanoPi-NEO-Plus2 / NanoPi-NEO-Core / NanoPi-Duo

2.2 Applicable OS

Debian 8.x jessie (for S5P4418 and S5P6818 only)
Ubuntu core xenial 16.04.x (for all FriendlyElec's nano boards)
These OS images include those based on armhf and aarch64.

3 Setup WiFi Connection with NetworkManager

3.1 Commandline Utility (nmcli)

Command to Check WiFi:

  • Check Device List
$ sudo nmcli dev

Note: if a device's status is unmanaged it means this device is not accessed by the NetworkManager and you need to clear the settings under /etc/network/interfaces and reboot.

  • Start WiFi
$ sudo nmcli r wifi on
  • Scan Surrounding WiFi Hotspots
$ sudo nmcli dev wifi
  • Connect to WiFi Hotspot
$ sudo nmcli dev wifi connect "SSID" password "PASSWORD"

The "SSID" and "Password" need to be replaced with your actual WiFi's SSID and password.
If a connection is successfully established your board will be automatically connected to your specified WiFi on system reboot.

  • Disconnect WiFi
$ sudo nmcli dev disconnect wlan0
  • If there are mutiple active WiFi devices you can specify your expected WiFi device by using the ifname option in the following command. For example if you want to operate wlan1 you can do it this way:
sudo nmcli device wifi connect "ssid" password "password" ifname wlan1

3.2 Commandline Based GUI(nmtui)

nmtui is a curses based GUI. You can start it by running the following command:

$ sudo nmtui

For more details refer to "man nmtui".

3.3 Operations with Windows Utility

Under Debian there are two options to start a Windows utility:

Option 1: you can click on the network icon on the bottom right of the task bar. After you click on it a NetworkManger menu will pop up and all the available networks will be listed. If there is an active wireless network you will see something similar to the following screenshot:


You can click on a WiFI AP and connect your board to it.

Option 2: you can go to Preferences -> Network Connections and enter the following window:


4 Setup Static IP

4.1 1: Setup Static IP Manually

You can setup a static IP manually without using the NetworkManager:

sudo vi /etc/NetworkManager/NetworkManager.conf

Edit NetworkManger.conf and set the value of "managed" under "ifupdown" to false:

[ifupdown]
managed=false

Add network setting to /etc/network/interfaces:

$ sudo vi /etc/network/interfaces

Here is is sample of /etc/network/interfaces:

# The loopback network interface
auto lo
iface lo inet loopback
 
# network interface not managed by Network Manager
allow-hotplug eth0
iface eth0 inet static
address 192.168.2.199
netmask 255.255.255.0
gateway 192.168.2.1
dns-nameservers 192.168.2.1

4.2 2: Setup Static IP with NetworkManager

Here is an example demonstrating how to setup a static IP with NetworkManager in a wired network
Check netowrk connection:

pi@Smart4418SDK:~$ sudo nmcli connection show
NAME                UUID                                  TYPE            DEVICE 
Wired connection 1  cffa785e-0425-3777-b670-092c79328a1f  802-3-ethernet  eth0

The above messages show that there is a wired connection named "Wired connection 1". You can set a static IP for "Wired connection 1" by running the following commands:

sudo nmcli connection modify 'Wired connection 1' connection.autoconnect yes ipv4.method manual ipv4.address 192.168.2.199/24 ipv4.gateway 192.168.2.1 ipv4.dns 192.168.2.1
sudo reboot

If this is successful the connection will be assigned a static IP with IP address to be 192.168.2.199 and both gateway and DNS to be 192.168.2.1

5 Uninstall NetworkManager

If you still prefer to use a traditional utility such as wpa_supplicant you can uninstall your NetworkManager by running the following commands

Create a script named rmnm.sh:

$vi rmnm.sh

Here is a sample:

#!/bin/bash
 
apt-get --yes --force-yes remove --auto-remove --purge network-manager
apt autoremove -y
 
cat >/etc/network/interfaces <<INTERFACEEOL
source-directory /etc/network/interfaces.d
 
auto lo
iface lo inet loopback
 
allow-hotplug wlan0
iface wlan0 inet dhcp
        wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
INTERFACEEOL
 
cat >/etc/network/interfaces.d/eth0 <<ETH0EOLB
auto eth0
    iface eth0 inet dhcp
    hwaddress 76:92:d4:85:f3:0f
ETH0EOLB

Run this script:

$chmod 755 rmnm.sh
$ sudo ./rmnm.sh

Reboot your board.

6 Disable WLan if Wired/Cable Network is available

Please refre to: https://superuser.com/questions/233448/disable-wlan-if-wired-cable-network-is-available

7 Resources

For more details refer to: NetworkManager

8 Update Log

8.1 June-18-2017

  • Released English Version
TAG: RP2040 1.5inch LCD Raspberry Pi 5 Modbus-Series-BootLoader-Description User Guide Computer Secondary Screen Serial UART Bus Servo CF35-12 TTL 35KG.CM Magnetic-Encoder High precision and Large torque Industrial Modbus RTU RS485 8-ch 30A High Current Relay Module (E) With Digital Input WiFi Wireless ESP32 DDSM Motor Driver HAT For Direct Drive Servo Hub Motors For Raspberry Pi DeepSeek AI Voice Chat ESP32 C6 Development Board 2.06-inch AMOLED Display 410×502 2.06inch TouchScreen Programmable Watch EC200U C4-P01 Development Board QuecPython LTE Cat-1 Bluetooth GNSS Positioning Raspberry Pi 5 PCIE to MiniPCIe For wireless network WIFI Card USB Bluetooth 3.5 inch LCD Computer CPU GPU RAM Monitor PC USB Secondary Display Screen MPS2280 POE Raspberry Pi 5 PCIe to M.2 NVMe SSD Adapter Board HAT Pi5 2280/2242/2230 Pi5 Fan SpotPear Raspberry Pi Pico 2 RP2350B 4.3inch Capacitive TouchScreen 4.3 inch LCD Display Development Board 800×480 Raspberry Pi Pico 2 RP2350-Tiny/Tiny-Kit Super Mini Board RP2350A Gyroscope PC USB Monitor Screen Raspberry Pi 1.3inch ESP32 S3 5 inch LCD Development Board 800x480 TouchScreen Display TVBOX LVGL HMI Sensor CAN RS485