Announcement

Collapse
No announcement yet.

Computer automatically wakes up from sleep after enabling wake on lan

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Computer automatically wakes up from sleep after enabling wake on lan

    I am trying to set up Wake on Lan on my machine... I followed instructions from https://help.ubuntu.com/community/WakeOnLan and https://necromuralist.github.io/post...g-wake-on-lan/ for this. I first made relevant changes to my BIOS. I am using an MSI B550 Unify motherboard with the latest version of BIOS. In my BIOS I have set the "Wake Up Event" to "BIOS" (other option is "OS") and enabled "Resume by PCI devices" (my ethernet is built-in).

    After enabling wake on lan using ethtool on my machine, I checked if it is receiving magic packets using tcpdump as described here: https://necromuralist.github.io/post...g-wake-on-lan/
    Code:
    $ sudo tcpdump -i enp42s0 '(udp and port 7) or (udp and port 9)'
    tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
    listening on enp42s0, link-type EN10MB (Ethernet), capture size 262144 bytes
    15:19:24.316234 IP recon.58451 > 255.255.255.255.discard: UDP, length 102
    At this point, I put my machine to sleep using the KDE power menu. It goes to sleep for a few seconds and automatically restarts on its own without any input. I don't even have to touch the mouse or keyboard... it just wakes up on its own. The motherboard has a WiFi adapter as well. I have disabled Wireless in KDE but not from BIOS. I doubt that is what's causing it though as the ethtool tells me that interface (wlo1) is disabled. Any ideas where the signal to wake the computer is coming from?

    #2
    So, I followed instructions from here https://wiki.archlinux.org/title/Wake-on-LAN and used nmcli to get the correct settings in. I am now able to wake my machine remotely from sleep by trying to ssh to it. Long story short, I had to run the following two commands:
    Code:
    ## this command to wake on lan using magic packet
    nmcli connection modify "Wired connection 1" 802-3-ethernet.wake-on-lan magic
    ## or this command to wake on ssh:
    nmcli connection modify "Wired connection 1" 802-3-ethernet.wake-on-lan unicast
    nmcli connection modify "Wired connection 1" 802-3-ethernet.auto-negotiate yes
    But my computer still wakes up on its own from sleep without having to do anything. After some searching, I found multiple posts referring to something like this: https://forums.linuxmint.com/viewtopic.php?p=1995055
    My machine has a bunch of devices that are in the enabled state:
    Code:
    $ cat /proc/acpi/wakeup
    Device  S-state   Status   Sysfs node
    GP12      S4    *enabled   pci:0000:00:07.1
    GP13      S4    *enabled   pci:0000:00:08.1
    XHC0      S4    *enabled   pci:0000:2d:00.3
    GP30      S4    *disabled
    GP31      S4    *disabled
    GPP0      S4    *enabled   pci:0000:00:01.1
    GPP8      S4    *enabled   pci:0000:00:03.1
    GPP1      S4    *enabled   pci:0000:00:01.2
    PTXH      S4    *enabled   pci:0000:05:00.0
    PT20      S4    *disabled
    PT24      S4    *disabled
    PT26      S4    *disabled
    PT27      S4    *disabled
    PT28      S4    *enabled   pci:0000:06:08.0
    PT29      S4    *enabled   pci:0000:06:09.0
    And these device codes mean the following:
    Code:
    $ cat /proc/acpi/wakeup | grep -P '\d.:\d+\.\d+' | sed 's/[ ]*S4.*pci:0000:/\t/' | while read -r a b; do echo -ne "$a\t"; lspci | grep "$b" ; done                                   
    GP12    00:07.1 PCI bridge: Advanced Micro Devices, Inc. [AMD] Starship/Matisse Internal PCIe GPP Bridge 0 to bus[E:B]
    GP13    00:08.1 PCI bridge: Advanced Micro Devices, Inc. [AMD] Starship/Matisse Internal PCIe GPP Bridge 0 to bus[E:B]
    XHC0    2d:00.3 USB controller: Advanced Micro Devices, Inc. [AMD] Matisse USB 3.0 Host Controller
    GPP0    00:01.1 PCI bridge: Advanced Micro Devices, Inc. [AMD] Starship/Matisse GPP Bridge
    GPP8    00:03.1 PCI bridge: Advanced Micro Devices, Inc. [AMD] Starship/Matisse GPP Bridge
    GPP1    00:01.2 PCI bridge: Advanced Micro Devices, Inc. [AMD] Starship/Matisse GPP Bridge
    PTXH    05:00.0 USB controller: Advanced Micro Devices, Inc. [AMD] Device 43ee
    PT28    06:08.0 PCI bridge: Advanced Micro Devices, Inc. [AMD] Device 43ea
    PT29    06:09.0 PCI bridge: Advanced Micro Devices, Inc. [AMD] Device 43ea
    I started to disable them one after another finally getting to a state where I had disabled every single one of them. Still, the machine just wakes up from sleep on its own. So I am still not sure what is going on...

    Comment


      #3
      Forgive my curiosity, but does it wake with the ethernet cable disconnected?
      Regards, John Little

      Comment


        #4
        Originally posted by jlittle View Post
        Forgive my curiosity, but does it wake with the ethernet cable disconnected?
        I did not try that. I started on this path with the goal to put the computer to sleep when I am not using it but still be able to access via ssh should I need. If I pull the ethernet cable I won't be able to use wake-on-lan which will defeat the purpose. Nevertheless I am going to give it a try...

        EDIT: Yes, pulling the ethernet cable keeps the computer asleep (at least for the brief period I was monitoring). Unfortunately, that's not a solution that works for me. I will need to keep it connected.
        Last edited by kayvee; Apr 19, 2022, 04:35 PM.

        Comment


          #5
          jlittle suggestion to pull the ethernet cable got me thinking...
          I had wake-on-lan set up such that the computer wakes up when I ssh to it. If I tweak the setting just so that the machine wakes up only on receiving a magic packet, the computer no longer automatically wakes up from sleep without any external trigger. So... progress!

          Now I need to figure out how to (1) make the unicast setting that allows wake-on-ssh work with sleep state, or (2) send magic packets from an external network. I prefer the first one over second because then I won't have to worry about having a wakeonlan application installed on my client.

          Comment


            #6
            Thanks for posting the question AND the solution, Kayvee!
            You'll never know how many people you will help with that post but it will be many more than just yourself!
            "A nation that is afraid to let its people judge the truth and falsehood in an open market is a nation that is afraid of its people.”
            – John F. Kennedy, February 26, 1962.

            Comment


              #7
              I suspect you'll have to learn a bit of Wireshark. You've run tcpdump with the system asleep, but that won't in principle see the activity that woke the computer. Ideally, you'd run a dump using another computer on the same subnet (I'm unsure if that's the right term) and look closely in the second before the computer wakes. I suspect your router is doing something. If you don't have another computer to look at stuff, a tcpdump with the computer idling might reveal the culprit.

              tcpdump output bamboozled me when I looked at it for something, years ago now. Wireshark organizes stuff to let you see what's going on, IIRC.
              Regards, John Little

              Comment


                #8
                Thank you GreyGeek ... I hope it is helpful to others (or even future me :-D)
                jlittle -- I am not sure that I will able to do much even if I figure out what it is that is currently causing activity on my LAN at all times. Say, I find out it is the router or the home printer or another device at home. Unfortunately, shutting them down is not an option. I am sure the curiosity to find out what it is will get me eventually :-D I will update the thread with my findings.

                After searching for a bit I could not come up with a way to keep the unicast setting. So I changed it to magic packet and now I have to rely on sending a magic packet to wake the computer up. It's easy enough to do it from within the network but to be able to do it over the internet I had to add appropriate settings in my WiFi router to route UDP ports 7 and 9 to my desktop. I have dynamic IP but have a DDNS set up so now I can send magic packets to wake up my computer as follows:
                Code:
                wakeonlan -i mysite.example.com a0:7b:c0:3d:9e:0f
                Apparently there are cellphone apps that can do this too. So my plan is to just use the cellphone app to wake the machine up when needed.--

                Comment


                  #9
                  That's great, thank you for sharing the solution.
                  Regards, John Little

                  Comment

                  Working...
                  X