12

I am a new Ubuntu user and have so far really enjoyed it. However, I spent around 3 hours yesterday trying to get my wifi to resume after my laptop wakes from sleep mode (it works if i reboot). I have scoured message boards and all the links on google are purple 3 or 4 pages in for every search result on this matter. Therefore, I don't think this question will be a repeat.

I have

  • A Dell Inspiron 15
  • AMD A6-6310
  • Ubuntu A6-6310
  • My wireless card is labeled as (device) wlp3s0 (driver) ath9k

and I have tried the following:

I have put these into a config folder in /config.d

SUSPEND_MODULES="$SUSPEND_MODULES ath9k"

SUSPEND_MODULES="ath9k"

I have created executable files in /sleep.d such as:

 #!/bin/sh
#Tell Network Manager that resume was successful
case "$1" in
        thaw)
       /usr/bin/nmcli nm sleep false
      ;;
 esac

#!/bin/sh

case "${1}" in
 resume|thaw)
 nmcli r wifi off && nmcli r wifi on ;;
esac

and many other variants thereof.

Also, this restarts the NetworkManager but does not connect wifi again:

sudo service network-manager restart

There are a couple other things I have tried that I can't exactly remember with commands like nmcli d wifi on, or something. They didnt work.

Now, I may be wrong, but I think the problem might lie in this:

sudo nmcli nm sleep false

Now, my terminal does NOT recognize "nm" and says:

sudo nmcli nm sleep false

and when I pull up the menu for nmcli, nm is nowhere in the object list. I feel like this might be the key to the problem. So, is there anything that I haven't done that I should do and is there any way to "fix" the "nm" problem? Thanks in advance!

  • Maybe not the same problem (I'm with intel driver) but I'm facing similar if not the same issues and ended assigning a shortcut (FN+F9 in my case) to execute the command pkexec systemctl restart network-manager.service to tell systemd to restart network-manager from the GUI in the least intrusive way i found. – dgonzalez Dec 25 '16 at 02:23
  • for what's worth: version of my nmcli is 1.2.2 – Timothy Truckle Dec 25 '16 at 20:44
  • Please see this question and edit the post to include the information – Jeremy31 Dec 26 '16 at 10:58
  • @TimothyTruckle you may just ask your own question as Ryan Callihan hasn't been logged in since Nov 7 – Jeremy31 Dec 26 '16 at 11:00
  • @Jeremy31 "Please see this question" His is not the same question since we (the TO an me) have the probem only after the system resumes from suspend. – Timothy Truckle Dec 26 '16 at 13:54
  • @TimothyTruckle it might be an issue with dnsmasq, try sudo sed -i 's/dns=dnsmasq/#dns=dnsmasq/' /etc/NetworkManager/NetworkManager.conf Then reboot – Jeremy31 Dec 26 '16 at 14:10
  • @TimothyTruckle The version of nmcli included with 16.04 no longer supports the nm object, nor the sleep command. Personally I would turn off power management on the wireless interface to avoid the initial disconnection or perhaps attempt bring down all Network manager interfaces on suspend and bring them all up on resume. – Elder Geek Dec 29 '16 at 17:58
  • @ElderGeek unfortunately this did not solve the problem either, the WiFi is still disconnected after suspend... :o( – Timothy Truckle Dec 29 '16 at 19:28
  • @TimothyTruckle I apologize for my confusion, but could you clarify as to what did not solve the problem? Are you refering to turning off power management or bringing down the interfaces on suspend and back up on resume? Perhaps your approach and the results of your testing could provide me some clues that would allow us to further assist you. Thank you for helping us help you! – Elder Geek Dec 29 '16 at 21:08
  • @ElderGeek I followed the steps in the answer you linked to http://askubuntu.com/questions/836271/ralink-pci-wifi-adaptor-intermittently-drops-connection and that did not solve the problem on my laptop. If you're suggesting somthing ese please add an answer with detailed explanation. – Timothy Truckle Dec 29 '16 at 21:14
  • @TimothyTruckle I'll see what I can come up with. Can you provide us with the output of uname -a – Elder Geek Dec 29 '16 at 21:25
  • @ElderGeek "Can you provide us with the output of uname -a" : Linux tt-LIFEBOOK-E8420 4.4.0-57-generic #78-Ubuntu SMP Fri Dec 9 23:50:32 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux – Timothy Truckle Dec 29 '16 at 21:27

3 Answers3

2

EDIT: Driver misbehavior on returning from suspend is a problem I've run across several times with several network interfaces across several operating systems. The only thing I've found to be effective across all of these is to turn power management off for the WiFi card. After reviewing the adjustments I made to a system to resolve a similar problem I offer the following resolution.

First we will make a backup of existing default power management settings with:

sudo cp /etc/NetworkManager/conf.d/default-wifi-powersave-on.conf /etc/NetworkManager/conf.d/default-wifi-powersave-on.conf.bak

Next we will edit the content to turn power management for WiFi off entirely. with gksu gedit /etc/NetworkManager/conf.d/default-wifi-powersave-on.conf which contains the default value wifi.powersave = 3 which enables power saving on the WiFi device. Changing the content of this file to:

[connection]
wifi.powersave = 0

Completing the above and also renaming my interface to wlan0 resolved my issues under 16.04

Once that is done you'll need to reboot or issue the command sudo systemctl restart NetworkManager to restart Network Manager

Note: My card does not have an Atheros chip and is identified as follows:

*-network description: Wireless interface product: RT2561/RT61 802.11g PCI vendor: Ralink corp. physical id: 1 bus info: pci@0000:04:01.0 logical name: wlan0 version: 00 serial: 00:1a:ef:03:00:aa width: 32 bits clock: 33MHz capabilities: pm bus_master cap_list ethernet physical wireless

Alternatives that may work for others with a similar problem are:

Put the bash script below in your /etc/pm/sleep.d folder with a name like 99_wifiup.

NOTE: The 99_ is needed where the 99 is the highest number in the folder to ensure it runs last.

You'll need to insure that the script has execute permissions and you'll need superuser (sudo) permissions to write the file there. Once in place every time you come out of suspend it will run.

#!/bin/bash

case "$1" in
suspend | hibernate)
# executed on suspend
;;
resume | thaw)
# executed on resume
/usr/sbin/rfkill block all
/usr/sbin/rfkill unblock all
/sbin/iwlist wlan0 scan
;;
*)
;;
esac 

If that doesn't work it should be worth exploring modifying the script to issue the commands nmcli networking off on suspend and nmcli networking on on thaw.

If none of these solutions work for you and you notice other anomalies you may have a faulty WiFi adapter or perhaps this bug has been resurrected.

Sources:

Modified /etc/NetworkManager/conf.d/default-wifi-powersave-on.conf and /etc/udev/rules.d/70-persistent-net.rules on one of my systems.

Mickeypop post #9 https://ubuntuforums.org/showthread.php?t=2321399

man nmcli

https://gist.github.com/jcberthon/ea8cfe278998968ba7c5a95344bc8b55

Elder Geek
  • 36,023
  • 25
  • 98
  • 183
1

I've found wifi power management often to be a bane of the linux experience. In my case, it was across various Intel and Broadcom adapters. Perhaps disabling it will resolve your issue. Here is how I do it (edit for your interface wlp3s0):

Create: /etc/network/if-up.d/wifi-powerman-off
Enable: chmod +x /etc/network/if-up.d/wifi-powerman-off

wifi-powerman-off:

#!/bin/sh
IWCONFIG=/sbin/iwconfig
WLAN_IFACE=<<interface name>>
if [ ! -x $IWCONFIG ]; then
    exit 1
fi
if [ "$IFACE" = $WLAN_IFACE ]; then
    $IWCONFIG $IFACE power off
fi

Here is the original Q & A reference:
How can I prevent iwconfig power management from being turned on?

Mark
  • 1,502
-1

few commands to try (in addition to the above), if you find one of them to work (when running manually) - add it to one of the scripts you mentioned in the question to be run during wakeup.

restart network & wifi related services:

sudo service wpa_supplicant restart

sudo service network-manager restart

restart the network card:

sudo ifconfig wlan0 down && sudo ifconfig wlan0 up

force wifi card mode:

sudo iwconfig wlan0 essid any

(on older ubuntu versions the state is called auto, not any)

reload the network card kernel drivers (the list might need to be updated for your drivers, the list was taken from a script I use on another model):

sudo rmmod ath9k ath9k_common ath9k_hw ath mac80211 rndis_wlan cfg80211 rndis_host cdc_ether usbnet && sleep 1 && sudo modprobe -a usbnet cdc_ether rndis_host cfg80211 rndis_wlan mac80211 ath ath9k_hw ath9k_common ath9k