Turn Off WiFi Network Listing

UbuM 20.04 on my wife's plastic case 2010 MacBook lists 20-some wifi networks available, and she apparently inadvertently clicked on a password-free one. When things weren't going normally, she asked me to have a look. Appalled to see she wasn't on our home network, I disconnected and pointed out the error & potentially serious security risks so she'll be more careful.

Question: How can I disable her access to all but our home network? Even better would be to not even display the others, since the list can get so long it requires scrolling to show ours.

Of course I've set her Mac to auto-connect to our network, but having the others not accessible (and preferably not displayed) would ease my mind considerably.

Before posting this query I of course googled quite a bit using different search strings, but couldn't find anything relevant to this particular topic. I also checked every setting I could find, and explored further in the system by searching with dconf Editor but again, no leads. For some reason, my tower desktop only shows our network but since settings seem identical to the MacBook maybe it's just a less sensitive receiver or the antenna blocked by a metal case.

I'm hoping someone here might have ideas on how to limit the list of available wifi networks to just the one(s) a user wants.

Not as such no. It is not an option in network manager.

However:
I guess this solution will cover your needs

Since that mentioned post, some things have changed a bit:

The file /etc/network/interfaces does not contain much nowadays.
You only need to add the wlan part. Do know that the devicename wlan0 does not exist anymore.

find your wirelessadaptor's name by issuing ip addr
let's say for convenience that it is 'wlp3s0'

So now you could add to the mentioned file:

auto wlp3s0
iface wlp3s0 inet dhcp
wpa-ssid <your_network>
wpa-psk <your_key_in_clear_text>

I don't know for sure if it will still work (after all this time), but this is more or less the way to go.

1 Like

Thanks, tkn. I'll have a go and report back. :slightly_smiling_face:

Clarification: I just noticed not having mentioned that our computers do connect automatically to our "hidden" network when we turn on WiFi. For an illusion of increased security, we turn WiFi off when not actively using it. The problem is the long list of other networks that then require scrolling to click Enable Networking (or WiFi, whichever needs less scrolling). My guess is she inadvertently clicked a nearby network name when trying to turn off WiFi, in part due to a sometimes "jumpy" mouse.

The AskUbuntu post didn't make a lot of sense to me. My wifi adapter name shows when I click on the network icon used to connect. I click Edit Connections... then the name of my "hidden" network, then the little gear in a box icon that displays an Edit the selected connection mouseover. As you predicted, in the WiFi tab is the line:
Device: wlp3s0
It also of course shows the same when I use the ip addr command in Terminal as you suggested.

I displayed the interfaces file you mentioned, and indeed it contains but one active line:

cat /etc/network/interfaces
# interfaces(5) file used by ifup(8) and ifdown(8)
# Include files from /etc/network/interfaces.d:
source-directory /etc/network/interfaces.d

I'd like to understand how and why adding the auto... lines might (or might not) work. I've manually maimed UbuM on our computers many times, and then invested a week getting back to useful functioning (often without the initially desired change). This has motivated gaining at least an impression of comprehension before changing things manually. :upside_down_face:

So before editing I googled a bit and came across a tantalizing Arch item here:

Ignore specific devices

Sometimes it may be desired that NetworkManager ignores specific devices and does not try to configure addresses and routes for them. You can quickly and easily ignore devices by MAC or interface-name by using the following in /etc/NetworkManager/conf.d/unmanaged.conf:

[keyfile] unmanaged-devices=mac:00:22:68:1c:59:b1;mac:00:1E:65:30:D1:C4;interface-name:eth0

After editing the file, run nmcli general reload as root. Afterwards you should be able to configure interfaces without NetworkManager altering what you have set.

Though it's probably irrelevant to UbuM 20.04, maybe there's something similar that would accept a universal variable? Like:

[keyfile] unmanaged-devices=mac::::::;interface-name:eth0

Presumably that wouldn't work, and even if so it would then require specifically turning ON the SSID we do want. Hopefully it wouldn't turn OFF the automatic ethernet connection we sometimes use. Anyway, turning off listing of specific devices seems near the goal of turning off all but one device.

Might there be a way of turning off scanning for devices? That is, when I turn on WiFi my receiver scans for networks in range and lists them. So if it didn't scan it wouldn't find and would thus not list. Maybe then it would simply wait for my specific network, and if it's active automatically connect? Or maybe there's a way to scan only
for my network? Maybe there's some potential for another strategy in that Arch page's Configuring MAC address randomization section?

I'd prefer to just eliminate the list of nearby networks on all our computers, but if not, could perhaps set her WiFi to turn Off when the MacBook lid is closed since it doesn't turn On automatically. When turning Networking or WiFi On no scrolling is required and it auto-connects to our network. A close/open of the lid would be quick, easy, and immune to inadvertent clicks on unknown networks. Then she could turn it On when needed again.

I probably shouldn't rummage around in Arch stuff, but am wondering about this in nmcli show:

profile
only shows static profile configuration.

If that's what it seems, since only our network is a saved connection maybe the others wouldn't be listed?

1 Like

EDIT: forget this post, go immediately to my next post

Oh yes, I totally understand your hesitation to undertake something like this, this is a pretty invasive change.

I'd like to understand how and why adding the auto... lines might (or might not) work.

'auto' activates the corresponding networkcard when the system boots.
Use this command in the terminal: man 5 interfaces
It will explain everything. Better and more concise than I can. :slight_smile:

Upto this part I cannot guarantee if everything will work because:

  1. we need a good way to keep networkmanager away from the card you want to manage manually.
    (but you have found a pretty elegant way to do so)
  2. There have been changes to the 'init' system (now 'systemd') that involves some networkparts but I haven't yet dived into that in detail to exactly check what is kept of the old stuff and what is new. I guess the old methods still work (otherwise a most server operators would already have lynched the inventor of 'systemd')

The Arch item you quoted in the previous post is about how to exclude a networkcard from the control of networkmanager. That is what I mentioned in point 1 :slight_smile:
It should also work in Ubuntu-MATE because, considering networking, it uses the same underlying pieces of software as Arch.

Though it's probably irrelevant to UbuM 20.04, maybe there's something similar that would accept a universal variable? Like:

[keyfile] unmanaged-devices=mac::::::;interface-name:eth0

No, it's not irrelevant, you did a very good discovery.
In your case, to exclude your wifi from networkmanager control, this would be:

[keyfile]
unmanaged-devices=interface-name:wlp3s0

After editing the file, run nmcli general reload as root. Afterwards you should be able to configure interfaces without NetworkManager altering what you have set.

even if so it would then require specifically turning ON the SSID we do want.

And that is what you fill in in /etc/network/interfaces.d/10_our_home_network :

iface wlp3s0 inet dhcp
wpa-ssid <your_network>
wpa-psk <your_key_in_clear_text>

We don't use auto because you said you want to deliberately start with network OFF
to switch it on:
ifup wlp3s0
to switch it off again:
ifdown wlp3s0

To revert to the old situation:

  1. delete /etc/network/interfaces.d/10_our_home_network
  2. delete /etc/NetworkManager/conf.d/unmanaged.conf
    reboot

Anyway, turning off listing of specific devices seems near the goal of turning off all but one device.

Yes, but don't confuse devices (your networkcards) with wireless networks in your neighborhood.

Might there be a way of turning off scanning for devices?

No, networkmanager is not able to do that

Or maybe there's a way to scan only for my network?

No, networkmanager is not able to do that

Maybe there's some potential for another strategy in that Arch page's Configuring MAC address randomization section?

No, MAC-spoofing is only useful if you travel from network to network to minimalize tracking and fingerprinting. Since you only use that laptop at home, it won't do anything for you.

I'd prefer to just eliminate the list of nearby networks on all our computers,

I understand totally what you want, but I also know that networkmanager is absolutely not able to do that. None of the other GUI-network-managers that I know of can do that.
That means that you have to build your own network-manager, which is what we are doing here.

but if not, could perhaps set her WiFi to turn Off when the MacBook lid is closed since it doesn't turn On automatically.

Normally, on every operating system on every laptop: If the laptop lid is closed, WiFi is switched off.
When opening laptop, it depends on the settings if it will connect automatically again.
(this is something that NetworkManager CAN do, and it does it well)

BUT: When you are building this homebrew thing, you have to test if it switches off when closing the laptop lid and perhaps it might be needed to add an ifdown in the 'sleep'-script.

You probably have some reading to do to check for yourself about what I wrote, but know this:
the command man will give you a complete manual of every command you want to know about.
the command apropos will give you all commands that have a connection with the keyword you give it.

1 Like

I probably shouldn't rummage around in Arch stuff, but am wondering about this in nmcli show:

profile
only shows static profile configuration.

If that's what it seems, since only our network is a saved connection maybe the others wouldn't be listed?

WOW, that would be the best solution indeed :grinning:
use nmcli con up profilename to control the card.
You can even put that in a keyboard shortcut :grin:

If you can make that work then you don't need anything else.
Really nothing that I wrote before is needed anymore with this solution.
This is so COOL :grin:

EDIT: I just tested it and it works really really easy.
I did nmcli con down "Wired connection 1" and my computer went offline
I did nmcli con up "Wired connection 1" and my computer connected again
Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/2)

The commands also work directly from inside a keyboardshortcut
For the rest you don't have to change anything on your computer :grin:

1 Like

Respectfully (and appreciatively), I'm finding it quite helpful. My painfully slow process of delving into what (imo) should be a simple NetworkManager option, every tidbit wafting into my limited understanding of this is a bit like cash falling from the sky. :smiley:
I'd come here hoping for a simple solution, but it now seems likely it will be another weeks long foray into the guts of UbuM. Hopefully I can find the courage (or foolhardiness) to get something working.

Ah, so that will be helpful when (having already read your next reply), I try to implement the laptop lid closure turning off WiFi. Maybe also ensuring it doesn't auto-start when the lid's opened again.

So from this first reply of yours I'm getting that we'll be basically turning of some/all of NM and building a manual way to turn on/off networking and auto-connect to our network when it's on. Then presumably try to build a simple GUI way to do this and also swap this manual GUI with NM when we're on the road?

Perhaps a few lines here and there, eh? :crazy_face:

1 Like

Maybe if I read this after coffee in the morning it will make sense. I've not yet checked to see if nmcli is in the UbuM 20.04 system or will need to be installed, nor whether it would conflict with NM (tho presumably not, since my dim understanding so far is that it's specifically intended to extend NM capabilities). A keyboard shortcut would be fine for me, but I may need to find some way of putting an icon in the Panel for my wife (whose genius lies in completely different areas).

WOW. This is exceptionally cool! So even if I can't put something in the Panel, maybe there's a way to put a keyboard shortcut reminder icon somewhere on her screen. I guess it may be easy for a script to shut off her WiFi when the lid's closed, so all we'd need is a shortcut to turn it on and autoconnect.

Hope I can sleep tonight without pondering this into exhaustion. :slightly_smiling_face:

I'm going to try editing the Subject of this thread to change "Limit" to "Turn Off" since that seems to be where this is headed.

Hey, thanks SO much for your help, suggestions, and patience!

Hi again :slight_smile:

OK, forget everything we discussed so far.
I repeat: forget everything we discussed so far. :slight_smile:

I have a step by step instruction how you can add two buttons to the panel:

  1. one to connect to your home network.
  2. one to disconnect from your home network.

All without even opening the networkmanager list window.

If that is at the moment sufficient for you to do what you want to do, read on.

Right-click on the panel and click 'add to panel'
step01

Select 'custom application launcher' twice

Fill in the fields like this and replace "xxx" for the name of your homenetwork
(in practice, the name of the profile is identical to your SSID or network name etc. )

(I just chose some random icons, choose whatever you prefer)

It will result in these two buttons (Yay! Tooltips!) :
step3c

in action it looks like this:
connect:
step04

disconnect:
step05

b.t.w. note how the WiFi icon still dutyfully indicates the networkstatus

I 've not yet checked to see if nmcli is in the UbuM 20.04 system

I also run UbuM 20.04 and It is installed by default. :slight_smile:

, nor whether it would conflict with NM

Your intuition is right, It does not conflict. :slight_smile:

since my dim understanding so far is that it's specifically intended to extend NM capabilities)

Q.E.D. It does that indeed :slight_smile:

I guess it may be easy for a script to shut off her WiFi when the lid's closed

If your laptop is configured to go to suspend when the lid is closed, it will surely disconnect from network. :slight_smile:
Suspend

2 Likes

WOW! :grinning:
This looks so Perfect and so EASY!
I'm going to try it on my identical laptop, and if she's still using hers after that I'll distract her and grab it. :wink:
Then ponder why I missed notification of this excellent solution you've so kindly shared. I need to log in here more often!

I tried creating the launcher as described, and it worked great. It took me a minute to figure out how to select an icon. The board on a spring (or whatever that default icon is) didn't seem intuitive for my wife. I discovered that simply clicking on the icon displays a default directory of icons.

The problem came when I then tested how she'd use the cool new panel icon. On these MacBooks the Panel is pretty crowded, so she'll use the Indicator Applet to turn WiFi off. I toggled the Indicator Applet's "Enable WiFi" Networking option to turn it off. The new icon stopped working and I got this error message:

Error: Connection activation failed: No suitable device found for this connection (device enp2s0 not available because profile is not compatible with device (mismatching interface name)).

So after some struggle I got this working in the Terminal:

notify-send "Joining myWiFi." ; nmcli networking on ; nmcli radio wifi on ; sleep 3 # ; nmcli con up "myWiFi"

It even worked when I pasted it into the custom launcher's Command box. I could use the Indicator Applet to turn off Networking and WiFi, then click the new custom icon and it popped the notification & connected to myWiFi.

Then it didn't work anymore.

So next I made a script named .joinMyWiFi.sh, put it in my Home directory, turned on Execute permissions, and used the Browse option in the Panel's Custom Application Launcher to select it. Now it works in every scenario I've tested. I guessed that something went funky about chaining the commands in one line, so the file contains this on separate lines:

notify-send "Joining myWiFi..."
nmcli networking on
nmcli radio wifi on
nmcli con up "myWiFi"

At this point it seems possible it might actually work tomorrow when I test it some more. :crossed_fingers:

1 Like

So after some struggle I got this working in the Terminal:

notify-send "Joining myWiFi." ; nmcli networking on ; nmcli radio wifi on ; sleep 3 # ; nmcli con up "myWiFi"

It even worked when I pasted
I guessed that something went funky about chaining the commands in one line

An unintended character made it's way into the commandline:
The '#' in the line of commands turns everything to the right of it into a comment, so effectively it disables the last command.

I guess it must have been a real headscratcher because it is easily overlooked. :slight_smile:

1 Like

Ah. TKN this could explain much. :roll_eyes:

As you've probably guessed, this has been a head scratcher since my last post. :upside_down_face:

I googled shell scripting and also scripts specific to toggling WiFi, and found this script that sadly didn't work at all (perhaps because the nmcli syntax may have changed such that the nm suffix doesn't work, and note also that for some reason the -t does have to come before the -f). I tediously diagnosed that script by pasting it line by line into the Terminal to see what effect changing the nonfunctional lines would have.

All the Panel button Command line now contains (I used right-click on the Panel button -> Properties to edit it) is

/home/me/.toggleWifi.sh

Here's my new .toggleWifi.sh WiFi toggling script called by a single Panel button that I now have working flawlessly (almost):

status=$(nmcli -t -f NETWORKING general status)
if [ $status = "enabled" ] ; then
notify-send "Toggling All Networking OFF"
nmcli radio wifi off
nmcli networking off
else
nmcli networking on
nmcli radio wifi on
notify-send "Toggling MyWiFi On"
nmcli con up "MyWiFi"
fi
exit 0

It was making me nuts until removing a

nmcli con down "MyWiFi"

line I had just above the Else. The only niggle now is, if I manually Disconnect from MyWiFi before toggling it Off, the script doesn't automatically reconnect to MyWiFi after turning networking and radio back on. It's "good enough" but if you have some idea why it doesn't over-ride the manual Disconnect I'd love to fix that.

ps-I forgot to mention in prior posts my simple way of making this script in my Home directory Executable. I just used Nemo (presumably Caja has the same feature), to highlight the file and then right-click, click Permissions, and click the Execute box on Owner, Group and Others. I also unclicked the Write box for Group & Others but there's little chance my wife would inadvertently edit the file. :slightly_smiling_face:

Speaking of whom, being tired of using the Indicator Applet she's very excited for me to install this on her laptop! :stuck_out_tongue:

1 Like