0

How can I automatically switch "off and on" the usage of a certain WLAN network BY TIME ?
(assuming the computer runs at that time)

Or alternatively how to switch off the Android-Hotspot by time ?

Background:
I arrive at 8:20 at work.
My laptop's internet connection runs via the mobile-phone-hotspot.
The mobile phone has a data-plan (2GB/month).
I sometimes forget to switch off the phone's hotspot.
I sometimes download large files (e.g. 350 MB).
Then I have no more data to surf, except if I purchase a dataplan-upgrade. Then in the evening I go home, and potentially the same happens...

1
  • Seems like an XY problem. Rather than controlling your hotspot (which is better done using Android), have you considered using networking hooks or dbus monitors to disconnect from hotspot and connect to home/work networks whenever they are available? – user535733 Oct 17 '17 at 15:52
1

The simplest answer might be a cron script or a Systemd Timer.

Alternatively, you might consider using a tool like ifmetric to give the mobile hotspot a lower priority, so that the system will automatically prefer to use another interface whenever one is available.

Edit: Apparently nmcli also has an autoconnect-priority setting, but it's not currently exposed through the GUI. That should also work for wireless networks which use the same interface. I would recommend using that solution instead, assuming you're on at least 16.04.

Quick summary of that answer:

To list all networks and their priorities:

nmcli -f NAME,UUID,AUTOCONNECT,AUTOCONNECT-PRIORITY c

To set a network's priority:

nmcli connection modify <NAME> connection.autoconnect-priority <priority>
2
  • It's the same interface, no wired connection. Just a different WLAN ESSID. – WitchCraft Oct 17 '17 at 15:52
  • Nice find, will find out how that works. nmcli connection <up|down> id <connection name> and then couple that with nmcli -f NAME connection show --active – WitchCraft Oct 17 '17 at 16:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.