6

Let's say that network-manager is connected to specific Wi-Fi network. When I click "Disconnect" via GUI from it then it never connects back.

But when I close the laptop lid, then open it back (so that system suspends and resumes) then network-manager automatically connects to the Wi-Fi network it finds.

How do I trigger network-manager from console to automatically connect to the Wi-Fi network it finds without doing system suspend and resume?

7
nmcli device set IFNAME autoconnect yes

is the command you're searching for. It enables autoconnect for the device with the interface name IFNAME, see e. g. nmcli device to get this name. If the device is currently not connected but finds a network it can connect to when you execute this command, it will instantly connect.

3
  • Is there a way to read the current state of this setting for a device? – AndreKR Jul 23 '19 at 22:58
  • @AndreKR Not that I found quickly – that’s a very good new question! – dessert Aug 4 '19 at 21:20
  • 2
    I found out that in my case this setting seems to have no effect at all. I had to set connection.autoconnect in the connection properties to control whether my GSM connection is up or down on boot. – AndreKR Aug 4 '19 at 23:01
2

device as suggested only works if the connection is existing/up.

If you want the setting to be permanent, you need to modify the connection config instead of the device config:

nmcli connection modify IFNAME connection.autoconnect yes|no

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.