Scheduled Maintenance: Over the course of a few days we will be addressing issues with the search backend. General search, newposts, yourposts, and other search driven queries may fail during the update. Details and discussion here: viewtopic.php?t=159736

 

 

 

Network does not show without "nmcli dev wifi" first

Linux Kernel, Network, and Services configuration.
Post Reply
Message
Author
User avatar
cthulhu
Posts: 310
Joined: 2009-09-07 12:34

Network does not show without "nmcli dev wifi" first

#1 Post by cthulhu »

I just got a travel router (GL.iNET 750S), a very nifty little thing.

When I start it, it starts emitting the WiFi. In order to get the router to connect to internet (e.g. hotel's wifi), I need to connect to the router and enter details in 192.168.8.1. However, the wirless network of the router doesn't show up when I list available networks to connect to.

I found out I must first do below, and _then_ I see the network in my network manager menu.

Code: Select all

nmcli dev wifi
Any idea why this is, or how to do it such that it sees the network immediately? I'm guessing it's not listing the wifi since it's a network that doesn't have internet (yet)?

Aki
Global Moderator
Global Moderator
Posts: 3353
Joined: 2014-07-20 18:12
Location: Europe
Has thanked: 92 times
Been thanked: 442 times

Re: Network does not show without "nmcli dev wifi" first

#2 Post by Aki »

cthulhu wrote: 2024-07-06 06:22 I just got a travel router (GL.iNET 750S), a very nifty little thing.
[..]
I found out I must first do below, and _then_ I see the network in my network manager menu.

Code: Select all

nmcli dev wifi
Any idea why this is, or how to do it such that it sees the network immediately? I'm guessing it's not listing the wifi since it's a network that doesn't have internet (yet)?
According to the manual page [1], the command nmcli device wifi:
[..]
wifi [list [--rescan | auto | no | yes] [ifname ifname] [bssid BSSID]]
List available Wi-Fi access points. The ifname and bssid options can be used to list APs for a particular
interface or with a specific BSSID, respectively.

By default, nmcli ensures that the access point list is no older than 30 seconds and triggers a network scan
if necessary
. The --rescan can be used to either force or disable the scan regardless of how fresh the access
point list is.
[..]
As you can see, the command triggers a network scan.

That's why the wireless network name generated by the router is recognised by Debian's network manager as soon as you run the command.

--
[1] NMCLI(1) - General Commands Manual
⢀⣴⠾⠻⢶⣦⠀
⣾⠁⢠⠒⠀⣿⡁ Debian - The universal operating system
⢿⡄⠘⠷⠚⠋⠀ https://www.debian.org
⠈⠳⣄⠀

User avatar
cthulhu
Posts: 310
Joined: 2009-09-07 12:34

Re: Network does not show without "nmcli dev wifi" first

#3 Post by cthulhu »

Thanks. Interestingly, the list of wifi nets to connect to listed with the ncurses GUI:

Code: Select all

 nmtui-connect
does not seem to do a full scan, then.

Aki
Global Moderator
Global Moderator
Posts: 3353
Joined: 2014-07-20 18:12
Location: Europe
Has thanked: 92 times
Been thanked: 442 times

Re: Network does not show without "nmcli dev wifi" first

#4 Post by Aki »

cthulhu wrote: 2024-07-09 14:58 Thanks. Interestingly, the list of wifi nets to connect to listed with the ncurses GUI:

Code: Select all

 nmtui-connect
does not seem to do a full scan, then.
Yes, I suppose.

However, the network manager daemon should periodically rescan the available wifi network connections.

Therefore, maybe you are not waiting long enough for the next rescan before running the nmtui-connect command.
⢀⣴⠾⠻⢶⣦⠀
⣾⠁⢠⠒⠀⣿⡁ Debian - The universal operating system
⢿⡄⠘⠷⠚⠋⠀ https://www.debian.org
⠈⠳⣄⠀

Aki
Global Moderator
Global Moderator
Posts: 3353
Joined: 2014-07-20 18:12
Location: Europe
Has thanked: 92 times
Been thanked: 442 times

Re: Network does not show without "nmcli dev wifi" first

#5 Post by Aki »

Hello,

As a confirmation, I tried to verify if starting nmtui-connect would trigger a WiFi network rescan in the NetworkManager running daemon (before the character-based user interface with the list of available connections is displayed).

To do this, I used gdb (GNU Debugger) to activate a breakpoint in the NetworkManager function (called nm_device_recheck_available_connections) that is executed when a rescan is done.

In a terminal:
  1. downloaded the NetworkManager source code and debugging symbols
  2. started the gdb (GNU debugger) and attached it to the running NetworkManager daemon
  3. instructed the debugger where to find the NetworkManager source code (-d option)
  4. set a breakpoint on the function and added a date/time marker command
  5. let the NetworkManager run until the breakpoint is hit
These are the commands:

Code: Select all

# trace the NetworkManager for connections rescan
#
$ apt source network-manager
$ su -l -c "apt install network-manager-dbgsym"
$ cd network-manager-1.42.4
$ su -l -c "gdb --pid $(pgrep NetworkManager) -d $PWD"
(gdb) break nm_device_recheck_available_connections
(gdb) continue
In another terminal, while the NetworkManager was running with gdb attached, I ran the nmtui-connect command: it did not cause the breakpoint to be hit.

Then I tried the nmcli device wifi command: the breakpoint at nm_device_recheck_available_connections was hit:

Code: Select all

Thread 1 "NetworkManager" hit Breakpoint 1, nm_device_recheck_available_connections (self=self@entry=0x55f76dedc810) at src/core/devices/nm-device.c:15103
15103   {
(gdb) 
In the end, if you wish, you can work around it using as alias that mixes the two commands; i.e.

Code: Select all

alias nm_tui="nmcli device wifi; nmtui-connect"
Then, you can simply use the aliased command:

Code: Select all

nm_tui
Of course, the rescan will take some time to complete, so nmtui-connect will start a little later.

The alias can be added at the end of the ~/.bashrc file of the user's home directory.

Hope this helps. Please let me know.
⢀⣴⠾⠻⢶⣦⠀
⣾⠁⢠⠒⠀⣿⡁ Debian - The universal operating system
⢿⡄⠘⠷⠚⠋⠀ https://www.debian.org
⠈⠳⣄⠀

Post Reply