Skip to content

Instantly share code, notes, and snippets.

@jcberthon
Last active April 22, 2024 14:33
Show Gist options
  • Save jcberthon/ea8cfe278998968ba7c5a95344bc8b55 to your computer and use it in GitHub Desktop.
Save jcberthon/ea8cfe278998968ba7c5a95344bc8b55 to your computer and use it in GitHub Desktop.
NetworkManager Wi-Fi powersaving configuration

NetworkManager WiFi Power Saving

NetworkManager supports WiFi powersaving but the function is rather undocumented.

From the source code: wifi.powersave can have the following value:

  • NM_SETTING_WIRELESS_POWERSAVE_DEFAULT (0): use the default value
  • NM_SETTING_WIRELESS_POWERSAVE_IGNORE (1): don't touch existing setting
  • NM_SETTING_WIRELESS_POWERSAVE_DISABLE (2): disable powersave
  • NM_SETTING_WIRELESS_POWERSAVE_ENABLE (3): enable powersave

Then I propose 2 files, only one of them needs to be put under /etc/NetworkManager/conf.d/.
One is forcing to disable powersaving, while the other one enable it.

Once you have put the file in the right folder, simply restart NetworkManager:

sudo systemctl restart NetworkManager
# File to be place under /etc/NetworkManager/conf.d
[connection]
# Values are 0 (use default), 1 (ignore/don't touch), 2 (disable) or 3 (enable).
wifi.powersave = 2
# File to be place under /etc/NetworkManager/conf.d
[connection]
# Values are 0 (use default), 1 (ignore/don't touch), 2 (disable) or 3 (enable).
wifi.powersave = 3
@paravz
Copy link

paravz commented May 30, 2020

Thnaks for this, used for my connection and latency in ssh sessions seems to be imroved:
CONN="my wifi conn"; nmcli con mod "$CONN" 802-11-wireless.powersave 2

@wazoox
Copy link

wazoox commented Aug 12, 2020

Notice that enabling powersave reduces bandwidth dramatically from 200Mbps to 50Mbps...

@soltanix
Copy link

I wonder if anyone has experimented on the effects of enable/disabling this feature in terms of power consumption. Is it negligible? If not, then is there a script that leverages a hook for low power states in laptops so that I can use it to enable this configuration when the battery is low?

@Godrigos
Copy link

After a kernel upgrade (from 5.11 to 5.13) on my Ubuntu 20.04 I experienced annoying wireless latency spikes, disabling this power saving solved the issue. Just reporting in case anyone suffer from the same problem.

@jeremyb31
Copy link

jeremyb31 commented Apr 14, 2022

A way to do this in terminal is sudo sed -i 's/wifi.powersave = 3/wifi.powersave = 2/' /etc/NetworkManager/conf.d/default-wifi-powersave-on.conf && systemctl restart network-manager.service

@FUIT1985
Copy link

FUIT1985 commented May 8, 2022

There is a discussion on the linustechtips.com forum about power saving and the rfc2863 protocol. Unfortunately the user did not follow my instructions, but he mixed them with other instructions taken from the internet, not solving the problem. If anyone wants to intervene and also correct what I have suggested to the user, he is welcome.
https://linustechtips.com/topic/1428381-kubuntu-keep-log-me-off-my-wifi/?do=findComment&comment=15386100

@RCantw3ll
Copy link

Does anyone else run into an issue where changing the setting to 2 (in order to disable power saving) completely disables the gnome network manager? In fact, any setting that I change here seems to disable it. Any help would be appreciated as this issue has been plaguing me for a long time and resetting the network manager every 10 minutes is getting exhausting.

@ctrlcctrlv
Copy link

Don't think you did it right @RCantw3ll. If the file has a syntactical error than NM will not start. Look at its log.

@alanngo
Copy link

alanngo commented Feb 14, 2023

Saved me a headache in having to reinstall ubuntu Thanks!

@e219
Copy link

e219 commented Feb 19, 2023

My wifi connection is often interrupted when using battery power, while using AC power, the connection is stable. It is solved after I modify the wifi.powersave to 2. Thank you very much!

@thomas2net
Copy link

Spelling correction in comment: "File to be placed under", with a d after place
Thanks!

In any case, interesting and long-lasting bug...
https://bugs.launchpad.net/ubuntu/+source/network-manager/+bug/1960817

@jeremyb31
Copy link

@JonasGroeger
Copy link

Check with

iwconfig <interface> | grep "Power Management"

@aceqbaceq
Copy link

this is amazing.

# cat /etc/NetworkManager/conf.d/default-wifi-powersave-on.conf 
[connection]
wifi.powersave = 3

literally kills ssh performance.
and
wifi.powersave = 2
creates a miracle!

@owainkenwayucl
Copy link

owainkenwayucl commented Feb 3, 2024

If you aren't using NetworkManager (default in the minimal RaspberyOS 11 install at least) you can temporarily (until reboot) turn off power management with:

iwconfig wlan0 power off

There are many conceivable ways of making this persist, e.g. putting it in rc.local.

@jeremyb31
Copy link

If you aren't using NetworkManager (default in the minimal RaspberyOS 11 install at least) you can temporarily (until reboot) turn off power management with:

iwconfig wlan0 power off

There are many conceivable ways of making this persist, e.g. putting it in rc.local.

It may just be Ubuntu and its derivatives that set the wifi.powersave=3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment