October 12, 2023

NetworkManager UI and access point, hotspot

Updated 2023-10-12 !

In a former post I shared some thoughts about how to start using NetworkManager (NM), on a Raspberry, and here I will continue with additional examples that can help with network setup.
  • NMTUI is NetworkManager text UI which can handle the most common tasks in a easy way.
  • An access point or hotspot will be configured.
  • "sudo nmcli connection edit xxxx" is a command that guides you throw a change of parameters.

NMTUI
Start
Together with NM, the text UI is installed and is started with 

pi@NmTest:~ $ sudo nmtui


and the interface, like the picture above, is shown.

Configure WiFi client
It can help you with some tasks, for example to connect to a WiFi as a client via the "Activate a connection".

Just pic the WiFi you want to connect to, using the arrow and tab keys, and then "Enter" for the selected one. If it's a secured WiFi logon with the eventual password. The connection will then be stored if confirmed with "OK".

If you want to check/change use the "Edit .... " in the menu.

To check the connections use

pi@NmTest:$ sudo nmcli connection

NAME                UUID                                  TYPE      DEVICE 

Wired connection 1  efb1b467-14cd-3a0b-ad75-56c9cb7b3d63  ethernet  eth0   

Guapa               e21ee622-fbdc-40f1-a6e7-08e3e24f773d  wifi      wlan0  


Configure WiFi client for a remote network
If you are moving the RPi to another place, and know the credentials, you can add the settings without a scan.

One way is to use the command 

pi@NmTest:~ $ sudo nmcli connection add type wifi ssid newwifi ......

or maybe a simpler way via the text UI

pi@NmTest:~ $ sudo nmtui

and then "Edit a connection => Add” Select the type and continue with the other parameters.

Access point
Having an access to Internet you can share this via an access point (AP), also called Hotspot. There is a quick way to set up this via the command 

pi@NmTest:$ sudo nmcli device wifi hotspot con-name Wifi_AP_wlan0 ifname wlan0 ssid RPi_AP password 12345678

Device 'wlan0' successfully activated with '37237db5-515e-400c-b744-f1b1b8a0a719'.

Hint: "nmcli dev wifi show-password" shows the Wi-Fi name and password.


To break it down 

ifname what Wi-Fi device is used.

con-name name of the created hotspot connection profile.(Optional)

ssid SSID of the hotspot.

band Wi-Fi band to use.(Optional)

channel Wi-Fi channel to use. (Optional)

password password to use for the created hotspot.


Since the AP is using the same device, "wlan0" as the "Guapa" client it will disconnect it and apply the configuration.

pi@NmTest:$ sudo nmcli connection

NAME                UUID                                  TYPE      DEVICE 

Wifi_AP_wlan0       37237db5-515e-400c-b744-f1b1b8a0a719  wifi      wlan0  

Wired connection 1  efb1b467-14cd-3a0b-ad75-56c9cb7b3d63  ethernet  eth0   

Guapa               e21ee622-fbdc-40f1-a6e7-08e3e24f773d  wifi      --     


Now you can test the setup connecting to the WiFi "RPi_AP" and log on.

Edit connection
Some parameters can be changed via nmtui but not all so here we use the mentioned edit function. As an example we will change the "autoconnect" parameter for Guapa with 

pi@NmTest:~ $ sudo nmcli connection edit Guapa


===| nmcli interactive connection editor |===


Editing existing '802-11-wireless' connection: 'Guapa'


Type 'help' or '?' for available commands.

Type 'print' to show all the connection properties.

Type 'describe [<setting>.<prop>]' for detailed property description.


You may edit the following settings: connection, 802-11-wireless (wifi), 802-11-wireless-security (wifi-sec), 802-1x, ethtool, match, ipv4, ipv6, hostname, tc, proxy

nmcli> goto connection

You may edit the following properties: id, uuid, stable-id, type, interface-name, autoconnect, autoconnect-priority, autoconnect-retries, multi-connect, auth-retries, timestamp, read-only, permissions, zone, master, slave-type, autoconnect-slaves, secondaries, gateway-ping-timeout, metered, lldp, mdns, llmnr, mud-url, wait-device-timeout

nmcli connection> print

['connection' setting values]

connection.id:                          Guapa

connection.uuid:                        ab37eb9c-8fc4-43f0-baf4-17ebd96f3de4

connection.stable-id:                   --

connection.type:                        802-11-wireless

connection.interface-name:              wlan0

connection.autoconnect:                 no

connection.autoconnect-priority:        0

connection.autoconnect-retries:         -1 (default)

connection.multi-connect:               0 (default)

connection.auth-retries:                -1

connection.timestamp:                   1670507099

connection.read-only:                   no

connection.permissions:                 --

connection.zone:                        --

connection.master:                      --

connection.slave-type:                  --

connection.autoconnect-slaves:          -1 (default)

connection.secondaries:                 --

connection.gateway-ping-timeout:        0

connection.metered:                     unknown

connection.lldp:                        default

connection.mdns:                        -1 (default)

connection.llmnr:                       -1 (default)

connection.wait-device-timeout:         -1

nmcli connection> set autoconnect yes

nmcli connection> verify

Verify setting 'connection': OK

nmcli connection> save persistent

Connection 'Guapa' (ab37eb9c-8fc4-43f0-baf4-17ebd96f3de4) successfully updated.

nmcli connection> quit

pi@NmTest:~ $ 


Remarks
Routing
I had problem with the routing from the AP to the wired connection, Internet connected, but solved it with flushing the routing table with 

pi@NmTest:~ $ sudo ip route flush table main


and then restart NM with 

pi@NmTest:~ $ sudo systemctl restart NetworkManager 


check with 

pi@NmTest:~ $ sudo ip route


Can not connect
Sometimes I got problem connecting to the created AP using the above hotspot command and the only solution was to change it to security None. ??

No comments:

Post a Comment

Feel free to leave a comment ! ... but due to a lot of spam comments I have to moderate them. Will reply ASAP !