WOL unable to send magic packet network unreachable

Hi all

My long shot is to preserve energy. So I got a shiny new server with low energy consumption. Installed an configured it, so it now provides what we need to get from it to run our family and business. Tuned it to consume as little energy as possible when up. If no one is logged in, my target is to get the server to detect that and put itself into Suspend To Ram (STR) or hibernation (STD), depending on daytime and week day. The idea is to have the server woken up whenever a client is booted or woken up. This part should simply work as I am out ferquently for longer time, even days. But it is exactly here wher it struggles:

I can put the serve to Suspend To Ram (STR) and wake it up by “/usr/bin/wol 00:11:22:33:44:55”. That part works like a charm. The server provides dhcp service among others. It is running OpenSuSE 13.2 with latest updates. So serverside no issue at all, client no problem too, as long as it keeps it’s IP.

Different story, if I put the client to STR, STD or shut it down. When reactivated, network-manager (NM) tries to activate the network but can’t as obviously the server is still in STR state. when I try to send the same “/usr/bin/wol 00:11:22:33:44:55”, I now get

/usr/bin/wol: Kann kein magic packet für »00:11:22:33:44:55« zu 255.255.255.255:40000 senden: Das Netzwerk ist nicht erreichbar

Meaning wol can’t send magic packet as network is unreachable. That does not lack logic, as NM has obviously not gotten an IP as the server is still to be woken up. That’s probably where the cat bites its tail.

So I thought, I manually bring up the network after stopping NM and then issue the wol cmd, thinking I still can do this in a script in /etc/pm/sleepd if it works. I tried:

ifconfig enp0s25 192.168.23.253 up
Hi all

My long shot is to preserve energy. so I got a shiny ne  server with low energy consumption. Installed an configured it, so it  now provides what we need to get from it to run our family and business.  Tuned it to consume as little energy as possible when up. If no one is  logged in, my target is to get the server to detect that and put itself  into Suspend To Ram (STR) or hibernation (STD), depending on daytime and  week day. The idea is to have the server woken up whenever a client is  booted or woken up.  This part should simply work as I am out ferquently for longer time, even days. But it is exactly here wher it struggles:

I can put the serve to Suspend To Ram (STR) and wake it up by  "/usr/bin/wol 00:11:22:33:44:55". That part works like a charm. The  server provides dhcp service among others. It is running OpenSuSE 13.2  with latest updates. So serverside no issue at all, client no problem  too, as long as it keeps it's IP.

Different story, if I put the client to STR, STD or shut it down. When  reactivated, network-manager (NM) tries to activate the network but  can't as obviously the server is still in STR state. when I try to send  the same "/usr/bin/wol 00:11:22:33:44:55", I now get 

/usr/bin/wol: Kann kein magic packet für »00:11:22:33:44:55« zu 255.255.255.255:40000 senden: Das Netzwerk ist nicht erreichbar


Meaning wol can't send magic packet as network is unreachable. That does not lack logic, as NM has obviously not gotten an IP as the server is still to be woken up. That's probably where the cat bites its tail.

So I thought, I manually bring up the network after stopping NM and then issue the wol cmd, thinking I still can do this in a script in /etc/pm/sleepd if it works. I tried:

ifconfig enp0s25 192.168.23.254 up
ifconfig enp0s25
enp0s25 Link encap:Ethernet Hardware Adresse 00:11:22:33:44:55
inet Adresse:192.168.23.254 Bcast:192.168.23.255 Maske:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:1164230 errors:0 dropped:2 overruns:0 frame:0
TX packets:1067551 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 Sendewarteschlangenlänge:1000
RX bytes:1089895477 (1039.4 Mb) TX bytes:315845215 (301.2 Mb)
Interrupt:20 Speicher:fc200000-fc220000

ping 192.168.23.109
PING 192.168.23.109 (192.168.23.109) 56(84) bytes of data.
64 bytes from 192.168.23.109: icmp_seq=1 ttl=64 time=0.513 ms
64 bytes from 192.168.23.109: icmp_seq=2 ttl=64 time=0.378 ms

/usr/bin/wol 00:11:22:33:44:55
/usr/bin/wol: Kann kein magic packet für »00:11:22:33:44:55« zu 255.255.255.255:40000 senden: Das Netzwerk ist nicht erreichbar



So despite the fact, that I can ping a machine on the same net, wol can't send the magic packet to the server. Why?

If I cannot solve this, my  long target to preserve energy by automagically put the server into STR  and wake it up when a Client is booted or woken up is unachievable. I  have been googling around for this quite some time. I just can't believe  not a sole having a similar idea and hopefully solved this.

I tried also to switch network mangment from NM to wicked, but that is inaccptable as with wcked there is no airplanmode availble.

Can anyone jump in and help please?

Greez

chris

On 2014-12-20 12:36, seuchato wrote:
>
> Hi all
>
> My long shot is to preserve energy. so I got a shiny ne server with low
> energy consumption. Installed an configured it, so it now provides what
> we need to get from it to run our family and business. Tuned it to
> consume as little energy as possible when up. If no one is logged in, my
> target is to get the server to detect that and put itself into Suspend
> To Ram (STR) or hibernation (STD), depending on daytime and week day.
> The idea is to have the server woken up whenever a client is booted or
> woken up.

Cool… :slight_smile:

> Different story, if I put the client to STR, STD or shut it down. When
> reactivated, network-manager (NM) tries to activate the network but
> can’t as obviously the server is still in STR state. when I try to send
> the same “/usr/bin/wol 00:11:22:33:44:55”, I now get
>
> Code:
> --------------------
> /usr/bin/wol: Kann kein magic packet für »00:11:22:33:44:55« zu 255.255.255.255:40000 senden: Das Netzwerk ist nicht erreichbar
> --------------------
>
> Meaning wol can’t send magic packet as network is unreachable. That does
> not lack logic, as NM has obviously not gotten an IP as the server is
> still to be woken up. That’s probably where the cat bites its tail.

Ah.

Just a comment. When the system language is not English, you should do,
in order to post here, like this:


minas-tirith:~ # LANG=C zypper lr --details
....

That way we can all read it, regardless of local languages of sender and
reader. It is not a permanent change, it only applies to one command.

> So I thought, I manually bring up the network after stopping NM and then issue the wol cmd, thinking I still can do this in a script in /etc/pm/sleepd if it works. I tried:
>
> Code:
> --------------------
> ifconfig enp0s25 192.168.23.253 up
> ifconfig enp0s25 192.168.23.254 up
> ifconfig enp0s25
> enp0s25 Link encap:Ethernet Hardware Adresse 00:11:22:33:44:55
> inet Adresse:192.168.23.254 Bcast:192.168.23.255 Maske:255.255.255.0
> UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
> RX packets:1164230 errors:0 dropped:2 overruns:0 frame:0
> TX packets:1067551 errors:0 dropped:0 overruns:0 carrier:0
> collisions:0 Sendewarteschlangenlänge:1000
> RX bytes:1089895477 (1039.4 Mb) TX bytes:315845215 (301.2 Mb)
> Interrupt:20 Speicher:fc200000-fc220000
>
> ping 192.168.23.109
> PING 192.168.23.109 (192.168.23.109) 56(84) bytes of data.
> 64 bytes from 192.168.23.109: icmp_seq=1 ttl=64 time=0.513 ms
> 64 bytes from 192.168.23.109: icmp_seq=2 ttl=64 time=0.378 ms
>
> /usr/bin/wol 00:11:22:33:44:55
> /usr/bin/wol: Kann kein magic packet für »00:11:22:33:44:55« zu 255.255.255.255:40000 senden: Das Netzwerk ist nicht erreichbar
>
> --------------------
>
>
> So despite the fact, that I can ping a machine on the same net, wol can’t send the magic packet to the server. Why?

But my problem here is that I can not read the error message :wink:

> Can anyone jump in and help please?

I think, at least on previous releases, that you could assign several
addresses to a single interfaces. Maybe one on dhcp, one fixed. Maybe
with different names, and you can bring up the “other” manually.

There is also another type of automatic network address family besides dhcp.

There is an IPv6 address that depends on the local MAC, so you might
have that UP even if IPv4-dhcp is down.

Some wild ideas.

Another one: increase the dhcp server lease time given to your clients
to weeks.


Cheers / Saludos,

Carlos E. R.
(from 13.1 x86_64 “Bottle” at Telcontar)

Carlos

Thanks for the flowers :shame:. And: I am always available for wild wild ideas. But before I continue, let’s cross the language barrier.


minas-tirith:~ # LANG=C zypper lr --details
....

That lists the repos. Cant’t see why you would like to seee these, not that I bother quoting them here for you, here you go:

#  | Alias                                  | Name                                                 | Enabled | Refresh | Priority | Type   | URI                                                                          | Service
---+----------------------------------------+------------------------------------------------------+---------+---------+----------+--------+------------------------------------------------------------------------------+--------
 1 | 13.2-non-oss                           | openSUSE-13.2 Non-OSS                                | Yes     | Yes     |   99     | yast2  | http://download.opensuse.org/distribution/13.2/repo/non-oss/                 |        
 2 | 13.2-oss                               | openSUSE-13.2 OSS                                    | Yes     | Yes     |   99     | yast2  | http://download.opensuse.org/distribution/13.2/repo/oss/                     |        
 3 | 13.2-update                            | openSUSE-13.2 Updates                                | Yes     | Yes     |   99     | rpm-md | http://download.opensuse.org/update/13.2/                                    |        
 4 | Education                              | Education                                            | Yes     | Yes     |   99     | rpm-md | http://download.opensuse.org/repositories/Education/openSUSE_Factory/        |        
 5 | Science                                | Science                                              | Yes     | Yes     |   99     | rpm-md | http://download.opensuse.org/repositories/science/openSUSE_Factory/          |        
 6 | Spiele                                 | Spiele                                               | Yes     | Yes     |   99     | rpm-md | http://download.opensuse.org/repositories/games/openSUSE_Factory/            |        
 7 | anki                                   | anki                                                 | Yes     | Yes     |   99     | rpm-md | http://download.opensuse.org/repositories/home:/HunOL/openSUSE_13.2          |        
 8 | cupspdf                                | cupspdf                                              | Yes     | Yes     |   99     | rpm-md | http://download.opensuse.org/repositories/Printing/openSUSE_13.2             |        
 9 | download.opensuse.org-Education_1      | openSUSE BuildService - Bildungswesen                | Yes     | Yes     |   99     | rpm-md | http://download.opensuse.org/repositories/Education/openSUSE_13.2/           |        
10 | download.opensuse.org-Extra_1          | openSUSE BuildService - KDE:Extra                    | Yes     | Yes     |   99     | rpm-md | http://download.opensuse.org/repositories/KDE:/Extra/openSUSE_13.2/          |        
11 | download.opensuse.org-Stable           | openSUSE BuildService - LibreOffice                  | Yes     | Yes     |   99     | rpm-md | http://download.opensuse.org/repositories/LibreOffice:/Stable/openSUSE_13.2/ |        
12 | download.opensuse.org-Virtualization_1 | openSUSE BuildService - Virtualisierung (VirtualBox) | Yes     | Yes     |   99     | rpm-md | http://download.opensuse.org/repositories/Virtualization/openSUSE_13.2/      |        
13 | download.opensuse.org-Wine             | openSUSE BuildService - Wine CVS Builds              | Yes     | Yes     |   99     | rpm-md | http://download.opensuse.org/repositories/Emulators:/Wine/openSUSE_13.2/     |        
14 | download.opensuse.org-games_1          | openSUSE BuildService - Spiele                       | Yes     | Yes     |   99     | rpm-md | http://download.opensuse.org/repositories/games/openSUSE_13.2/               |        
15 | download.opensuse.org-mozilla          | openSUSE BuildService - Mozilla                      | Yes     | Yes     |   99     | rpm-md | http://download.opensuse.org/repositories/mozilla/openSUSE_13.2/             |        
16 | download.opensuse.org-packages         | openSUSE BuildService - Java:packages                | Yes     | Yes     |   99     | rpm-md | http://download.opensuse.org/repositories/Java:/packages/openSUSE_13.2/      |        
17 | download.opensuse.org-php_13.2         | openSUSE-13.2 BuildService - PHP 13.2                | Yes     | Yes     |   99     | rpm-md | http://download.opensuse.org/repositories/server:/php/openSUSE_13.2/         |        
18 | eclipse                                | eclipse                                              | Yes     | Yes     |   99     | rpm-md | http://download.opensuse.org/repositories/home:/marec2000/openSUSE_13.2/     |        
19 | ftp.gwdg.de-suse                       | Packman Repository                                   | Yes     | Yes     |   99     | rpm-md | http://ftp.gwdg.de/pub/linux/packman/suse/openSUSE_13.2/                     |        
20 | multimedia_apps                        | multimedia apps                                      | Yes     | Yes     |   99     | rpm-md | http://download.opensuse.org/repositories/multimedia:/apps/openSUSE_Factory/ |        
21 | multimedia_libs                        | multimedia libs                                      | Yes     | Yes     |   99     | rpm-md | http://download.opensuse.org/repositories/multimedia:/libs/openSUSE_Factory/ |        
22 | opensuse-guide.org-repo                | libdvdcss repository                                 | Yes     | Yes     |   99     | rpm-md | http://opensuse-guide.org/repo/13.2/                                         |        
23 | repo-update-non-oss                    | openSUSE-13.2-Update-Non-Oss                         | Yes     | Yes     |   99     | rpm-md | http://download.opensuse.org/update/13.2-non-oss/                            |        
24 | vidia                                  | nvidia                                               | Yes     | Yes     |   99     | rpm-md | ftp://download.nvidia.com/opensuse/13.2/                                     | 

I guess you are aiming at some automagical messge translation? Google translate failed miserably, So I reedit the orignal post and add handis translations. Hope that’s OK.

Greez

chris

Ths is a repost, with message translations in purple color. Hope it is acceptable for the time being, as I feel, the whole story should be together.

Wouldn’t I then need to tell wol through what interface it should send the magic packet?

I tried the following, thinking wildly:
What, if instead of my iprange 192.168.23.xx use something else, out of the blue? So I tried:

ifconfig enp0s25 192.168.10.1 up
/usr/bin/wol 00:11:22:33:44:55
/usr/bin/wol: Kann kein magic packet für »00:11:22:33:44:55« zu 255.255.255.255:40000 senden: Das Netzwerk ist nicht erreichbar
/usr/bin/wol: Cannot send magic packet for »00:11:22:33:44:55« to 255.255.255.255:40000 : Network ist unreacable
ws1005:/etc/pm/sleep.d # /usr/bin/wol 00:11:22:33:44:55 -h 192.168.10.255
Wecke 00:11:22:33:44:55 auf...
Waking 00:11:22:33:44:55 up...

Tadaaa, time to pop a beer! The server wakes up. I will test this a couple of times, before I mark it as solved. Hopefully it will continue to work when put into the /etc/pm/sleep.d script.

Thanks Carlos for suggesting getting wild, I knew it would help

Greez

chris

On 2014-12-20 16:16, seuchato wrote:

> That lists the repos. Cant’t see why you would like to seee these, not
> that I bother quoting them here for you, here you go:

Argh. No, I don’t want them. :-}

It is just a copypasted example of how to change the language. You have
to run your command, wol something preceded with lang=c thing.

ie:


LANG=C /usr/bin/wol .... whatever options.


cer@Telcontar:~> LANG=C wol 00:11:22:33:44:55
Waking up 00:11:22:33:44:55...
cer@Telcontar:~> LANG=es_ES wol 00:11:22:33:44:55
Encendiendo 00:11:22:33:44:55...
cer@Telcontar:~>

in general:


LANG=C whatever_command_you_need_to_show_us


Cheers / Saludos,

Carlos E. R.
(from 13.1 x86_64 “Bottle” at Telcontar)

On 2014-12-20 16:36, seuchato wrote:

>> I think, at least on previous releases, that you could assign several
>> addresses to a single interfaces. Maybe one on dhcp, one fixed. Maybe
>> with different names, and you can bring up the “other” manually.
>>
>
> Wouldn’t I then need to tell wol through what interface it should send
> the magic packet?

Mmm. Yes, probably. I don’t know. maybe it sends on all available
interfaces. I tried with your MAC, and it happily sent it without complain.

Don’t worry, it will not reach your machine, routers block it :wink:

> Tadaaa, time to pop a beer! The server wakes up. I will test this a
> couple of times, before I mark it as solved. Hopefully it will continue
> to work when put into the /etc/pm/sleep.d script.
>
> Thanks Carlos for suggesting getting wild, I knew it would help

Welcome :slight_smile:


Cheers / Saludos,

Carlos E. R.
(from 13.1 x86_64 “Bottle” at Telcontar)

Carlos

That makes click in my brain, reference saved for future use, Thanks a ton for ponting me to this

greez

chris

Progress report:

I can confirm:

ifconfig enp0s25 192.168.10.1 up 
/usr/bin/wol 00:11:22:33:44:55 -h 192.168.10.255 
Wecke 00:11:22:33:44:55 auf... 
Waking 00:11:22:33:44:55 up...

works, not only on the machine usually used for testing but also on other machines.

But I am still far from the scon beer.

The issue now is to get the magic packet sent while opening the lid. Ponts to look after are here:

  • /etc/pm/sleepd

  • /usr/lib/systemd/system-sleep

1st attempt, /etc/pm/sleepd:

cat 00serverwakeupcall
#!/bin/bash
case $1 in
hibernate)
#echo “Hey guy, we are going to suspend to disk!”
;;
suspend)
#echo “Oh, this time we are doing a suspend to RAM. Cool!”
;;
thaw)
#echo “Oh, suspend to disk is over, we are resuming…”
# wake up the server…
echo “wol brutus 00”
ifconfig enp0s25 192.168.10.1 up
ifconfig enp0s25
/usr/bin/wol 00:11:22:33:44:55 -h 192.168.10.255
ifconfig enp0s25 down
;;
resume)
# echo “Hey, the suspend to RAM seems to be over…”
# wake up the server…
echo “wol brutus 00”
ifconfig enp0s25 192.168.10.1 up
ifconfig enp0s25
/usr/bin/wol 00:11:22:33:44:55 -h 192.168.10.255
ifconfig enp0s25 down
;;
*) echo “Somebody is calling me totally wrong.”
;;
esac

This works - sort of. In /var/log/pm-suspend.log I seee this:

Running hook /etc/pm/sleep.d/00serverwakeupcall resume suspend:
wol brutus 00
enp0s25 Link encap:Ethernet Hardware Adresse 00:11:22:33:44:55
inet Adresse:192.168.10.1 Bcast:192.168.10.255 Maske:255.255.255.0
UP BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:1221972 errors:0 dropped:2 overruns:0 frame:0
TX packets:1123954 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 Sendewarteschlangenlänge:1000
RX bytes:1119195619 (1067.3 Mb) TX bytes:327265067 (312.1 Mb)
Interrupt:20 Speicher:fc200000-fc220000

Wecke 00:11:22:33:44:55 auf…
Waking 00:11:22:33:44:55 up…
/etc/pm/sleep.d/00serverwakeupcall resume suspend: success.

so, the “00serverwakeupcall” script gets called and run, but no effect, the server does not wake up. Why?
Somehow, the twork s not available, but then I really would have expected a clear error message. /var/log/messages i quiet though.

2nd approach through /usr/lib/systemd/system-sleep:

cat serverwakeupcall 
#!/bin/sh
echo $1 $2
case $1/$2 in
  pre/*)
    echo "Going to $2..."
    ;;
  post/*)
    echo "Waking up from $2..."
        #echo "Oh, suspend to disk is over, we are resuming..."
        # wake up the server...
        echo "wol brutus 00"
        ifconfig enp0s25 192.168.10.1 up
        # ifconfig enp0s25
        /usr/bin/wol 00:11:22:33:44:55 -h 192.168.10.255
        ifconfig enp0s25 down
        ifconfig enp0s25 up
    ;;
esac


No joy, apat from ‘echo “wol brutus 00”’ bing logged in /var/log/messages.

At that point, I am going to pla chess with my sons and let this aone over the night. Maybe my cushion or one of you good souls out there knows how to solve that - last - obstacle to get it done.

greez and good nite

chris

On 2014-12-20 21:06, seuchato wrote:

> Carlos
>
> That makes click in my brain, reference saved for future use, Thanks a
> ton for ponting me to this

Welcome! :slight_smile:

I have updated my list of recipes so that the next time I post it it is
clearer (you are the second person that gets the same confusion). O:-)


Cheers / Saludos,

Carlos E. R.
(from 13.1 x86_64 “Bottle” at Telcontar)

On 2014-12-20 21:36, seuchato wrote:

> The issue now is to get the magic packet sent while opening the lid.
> Ponts to look after are here:
>
> - /etc/pm/sleepd

I guess you mean “/etc/pm/sleep.d/”.

> 1st attempt, /etc/pm/sleepd:

> so, the “00serverwakeupcall” script gets called and run, but no effect,
> the server does not wake up. Why?

One trick is to replace the code with:


do_the_job_later_script &

And that script contains something like this:



sleep 3
do my wol thing.
sleep 10
ping the server.
No? Loop back.  (3 times, say)
yes? exit.


I’m sure you can concoct that script :slight_smile:

The reason to do it in a separate script is to run it in background and
don’t hold up booting/thawing. However, if thawing completes before the
server is up, perhaps that poses a problem for you :-?

maybe the solution for that is to mount the shares a bit later. I
understand that systemd is good at that, starting services when things
are ready. There are some user space provisions, but I know little about
that.

> Somehow, the twork s not available, but then I really would have
> expected a clear error message. /var/log/messages i quiet though.

No, try to run “wol” against a non-existing MAC. It does not error out.
Apparently it just sends the packet and exits, not expecting a response.

Humm… do we have a “ping” tool for MACs without IPs? it would perhaps
serve better on your script.


Cheers / Saludos,

Carlos E. R.
(from 13.1 x86_64 “Bottle” at Telcontar)

It could take some time before network is up after resume. If you are usign NM you probably should look at dispatcher scripts. Unfortunately it does not look like NM passes information whether it returned from suspend, so you can only run it every time interface is up.

        ifconfig enp0s25 192.168.10.1 up
        # ifconfig enp0s25
        /usr/bin/wol 00:11:22:33:44:55 -h 192.168.10.255

It races with NM which may tear down interface when it sees “unplanned” interface activation.

Morning

correct, and after thinking, I came to the conclusion, that I would love to have the wakeupcall for my server either done “/etc/pm/sleep.d/” or “/usr/lib/systemd/system-sleep”. I guess, it could be done also when the login screen appears (we have all machines configured, that after opening the lid again, users must provide their passwords).

No problem at all. I was thinking, that there might be a timing problem ivolved somehow, which might get resolved by your suggestion. Maybe the nic driver is not ready at the time my script is running wol. I will give this a try and report back.

Mounting shares did not pose a problem so far. It is sending the wakeupcall to the server automagically that needs to get done in the background, without any user interaction at all. Therefore I would also love to keep this away from user space. If in user space, wouldn’t I need to place such a wakeupcall, where they probably could delete such a script?

You’re right, wol just shoots a broad load without listening. So all I can get from logs is if wol did shoot or not.

Off to put that script for background process as you sufĝgested above

Thanks so far and greetings, till later…

chris

Yes, using a NM dispatcher script is probably the way to go here.

Borrowing from

https://wiki.archlinux.org/index.php/NetworkManager#Use_dispatcher_to_connect_to_a_VPN_after_a_network_connection_is_established

I wonder if something like the following might work

#!/bin/sh
interface=$1 status=$2
case $status in
  up)
    if "$interface" = "enp0s25"]; then
        ifconfig enp0s25 192.168.10.1 up
        /usr/bin/wol 00:11:22:33:44:55 -h 192.168.10.255
    fi
    ;;
 esac

arvidjaar

Saw your post after my reply to Carlos. I think you ar probably right. as Carlus suggested, I have extracted the wol section and put it into another script that I called servewakeup (please no hard hits, that thing is just there to test the whole thing, when it works, I will trim it, so for it to become cracky and shiny)

in “/etc/pm/sleep.d” i got these two scripts: “00serverwakeupcall” and “serverwakeup”

cat 00serverwakeupcall
#!/bin/bash
case $1 in
    hibernate)
        #echo "Hey guy, we are going to suspend to disk!"
    ;;
    suspend)
        #echo "Oh, this time we are doing a suspend to RAM. Cool!"
    ;;
    thaw)
        #echo "Oh, suspend to disk is over, we are resuming..."
        # wake up the server...
        /etc/pm/sleep.d/serverwakeup &
    ;;
    resume)
        # echo "Hey, the suspend to RAM seems to be over..."
        # wake up the server...
        /etc/pm/sleep.d/serverwakeup &
    ;;
    *)  echo "Somebody is calling me totally wrong."
    ;;
esac
cat serverwakeup
#!/bin/bash

echo "script called with params $1 $2"
# make sure script gets called on resume only
if  "$1" = "suspend" ];
then
  exit
fi
# name of nic
nic=enp0s25

# free subnet
freesub=192.168.10

# the subnet we are actually using
mysub=192.168.23

# the server's mac and ip
servermac=00:22:4D:B1:E7:D0
serverip=$mysub.4

# time intervals
waitforserver=10
waitforsystem=5

# a quick check, if we have the server still running
echo "ping -c 1 $serverip"

LANG=en ping -c 1 $serverip
rv=$?
echo "ping -c 1 $serverip returned $rv"


if  "$rv" = "0" ];
then
  # yep, server's up, so nothing to do
  echo "yep, server's up, so nothing to do"
  exit 0
else
  # server not up, needs to be woken up
  echo "server not up, needs to be woken up"

  maxloops=5
  loop=0
  while  $loop -lt $maxloops ]
  do
    # stay a couple of seconds idle, in order for stuff to get ready
    sleep $waitforsystem

    # wake up the server...
    echo "wol brutus 00, loop nr. $loop of $maxloops"
    LANG=en ifconfig $nic $freesub.1 up
    LANG=en ifconfig $nic
    # ifconfig $nic
    LANG=en /usr/bin/wol $servermac -h $freesub.255
    LANG=en ifconfig $nic down

    sleep $waitforserver
    LANG=en ifconfig $nic up $mysub.254
    LANG=en ping -c 1 $serverip
    rv=$?
    LANG=en ifconfig $nic down

    if  $rv -eq 0 ];
    then
        echo "Success, server at $serverip is awake now!"
        LANG=en ifconfig $nic down
        LANG=en ifconfig $nic up
        exit 0 
    else 
        eho "server still asleep"
        echo "ping -c 1 $serverip returned $rv"
    fi
    loop=$(( $loop + 1 ))
  done    
fi

exit 0

and here the relevant part of

 cat pm-suspend.log
.....
fbcon fb0 state 1
fbcon fb0 state 0
switching back to vt7... succeeded
Son Dez 21 10:55:25 CET 2014: Awake.
Son Dez 21 10:55:25 CET 2014: Running hooks for resume
Running hook /etc/pm/sleep.d/serverwakeup resume suspend:
script called with params resume suspend
ping -c 1 192.168.23.4
connect: Network is unreachable
ping -c 1 192.168.23.4 returned 2
server not up, needs to be woken up
wol brutus 00, loop nr. 0 of 5
enp0s25   Link encap:Ethernet  HWaddr 00:1F:16:30:C3:BB  
          inet addr:192.168.10.1  Bcast:192.168.10.255  Mask:255.255.255.0
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:1259891 errors:0 dropped:2 overruns:0 frame:0
          TX packets:1158833 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:1143532545 (1090.5 Mb)  TX bytes:332262407 (316.8 Mb)
          Interrupt:20 Memory:fc200000-fc220000 

Waking up 00:22:4D:B1:E7:D0...
PING 192.168.23.4 (192.168.23.4) 56(84) bytes of data.
From 192.168.23.254 icmp_seq=1 Destination Host Unreachable

--- 192.168.23.4 ping statistics ---
1 packets transmitted, 0 received, +1 errors, 100% packet loss, time 0ms

server still asleep
ping -c 1 192.168.23.4 returned 1
wol brutus 00, loop nr. 1 of 5
enp0s25   Link encap:Ethernet  HWaddr 00:1F:16:30:C3:BB  
          inet addr:192.168.10.1  Bcast:192.168.10.255  Mask:255.255.255.0
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:1259891 errors:0 dropped:2 overruns:0 frame:0
          TX packets:1158833 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:1143532545 (1090.5 Mb)  TX bytes:332262407 (316.8 Mb)
          Interrupt:20 Memory:fc200000-fc220000 

Waking up 00:22:4D:B1:E7:D0...
PING 192.168.23.4 (192.168.23.4) 56(84) bytes of data.
From 192.168.23.254 icmp_seq=1 Destination Host Unreachable

--- 192.168.23.4 ping statistics ---
1 packets transmitted, 0 received, +1 errors, 100% packet loss, time 0ms

server still asleep
ping -c 1 192.168.23.4 returned 1
wol brutus 00, loop nr. 2 of 5
enp0s25   Link encap:Ethernet  HWaddr 00:1F:16:30:C3:BB  
          inet addr:192.168.10.1  Bcast:192.168.10.255  Mask:255.255.255.0
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:1259891 errors:0 dropped:2 overruns:0 frame:0
          TX packets:1158833 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:1143532545 (1090.5 Mb)  TX bytes:332262407 (316.8 Mb)
          Interrupt:20 Memory:fc200000-fc220000 

Waking up 00:22:4D:B1:E7:D0...
PING 192.168.23.4 (192.168.23.4) 56(84) bytes of data.
From 192.168.23.254 icmp_seq=1 Destination Host Unreachable

--- 192.168.23.4 ping statistics ---
1 packets transmitted, 0 received, +1 errors, 100% packet loss, time 0ms

server still asleep
ping -c 1 192.168.23.4 returned 1
wol brutus 00, loop nr. 3 of 5
enp0s25   Link encap:Ethernet  HWaddr 00:1F:16:30:C3:BB  
          inet addr:192.168.10.1  Bcast:192.168.10.255  Mask:255.255.255.0
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:1259892 errors:0 dropped:2 overruns:0 frame:0
          TX packets:1158833 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:1143532609 (1090.5 Mb)  TX bytes:332262407 (316.8 Mb)
          Interrupt:20 Memory:fc200000-fc220000 

Waking up 00:22:4D:B1:E7:D0...
PING 192.168.23.4 (192.168.23.4) 56(84) bytes of data.
From 192.168.23.254 icmp_seq=1 Destination Host Unreachable

--- 192.168.23.4 ping statistics ---
1 packets transmitted, 0 received, +1 errors, 100% packet loss, time 0ms

server still asleep
ping -c 1 192.168.23.4 returned 1
wol brutus 00, loop nr. 4 of 5
enp0s25   Link encap:Ethernet  HWaddr 00:1F:16:30:C3:BB  
          inet addr:192.168.10.1  Bcast:192.168.10.255  Mask:255.255.255.0
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:1259893 errors:0 dropped:2 overruns:0 frame:0
          TX packets:1158833 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:1143532673 (1090.5 Mb)  TX bytes:332262407 (316.8 Mb)
          Interrupt:20 Memory:fc200000-fc220000 

Waking up 00:22:4D:B1:E7:D0...
PING 192.168.23.4 (192.168.23.4) 56(84) bytes of data.
From 192.168.23.254 icmp_seq=1 Destination Host Unreachable

--- 192.168.23.4 ping statistics ---
1 packets transmitted, 0 received, +1 errors, 100% packet loss, time 0ms

server still asleep
ping -c 1 192.168.23.4 returned 1

/etc/pm/sleep.d/serverwakeup resume suspend: success.
....


When initially having the wol call in “00serverwakeupcall”, the outputs were quite at the end of the “pm-suspend.log”. Now, with the relevant calls in “serverwakeup” and running in th background, they come immediately after resuming. That might be one of the reason why that stuff still fails. But I fear, it is not the nly one.

greezs

chris

Deano

tried this out, I am getting:

Dispatching action 'up' for enp0s25
Dez 21 12:15:58 ws1005.domain nm-dispatcher[15096]: /etc/NetworkManager/dispatcher.d/autoserver: line 5: [enp0s25: command not found

line 5 is [i]if “$interface” = “enp0s25”]; then thought it might be because of “#!/bin/sh”, but" #!/bin/bash" gives the same error. I can’t see anything wrong here, am I blind?

At this point, I am out of options. I really cannot believe that noone had a similar idea and got it up working. It would be so elegant: Users close the lids of their laptops or shut down their PCs, server checks if there are any active connections, if not, it goes into suspend and sits there without consuming much (in case of STD almost no) energy. Users boot or resume their PCs, server gets the magic packet, resumes and within short time everything is up working again.

All 3 approaches fail when the question is to send the magic packet from suspended state.

Any more ideas?

I am desprate to get this working.

greez chris

…and besides: many thanks for the help so far

On 2014-12-21 09:36, seuchato wrote:

> No problem at all. I was thinking, that there might be a timing problem
> ivolved somehow, which might get resolved by your suggestion. Maybe the
> nic driver is not ready at the time my script is running wol. I will
> give this a try and report back.

You know that you have some control about timing with the names of the
scripts in /etc/pm/sleep.d/. Say 05sleep vs 95sleep.

> robin_listas;2684257 Wrote:
>> maybe the solution for that is to mount the shares a bit later.
>> I
>> understand that systemd is good at that, starting services when things
>> are ready. There are some user space provisions, but I know little about
>> that.
>
> Mounting shares did not pose a problem so far. It is sending the
> wakeupcall to the server automagically that needs to get done in the
> background, without any user interaction at all. Therefore I would also
> love to keep this away from user space. If in user space, wouldn’t I
> need to place such a wakeupcall, where they probably could delete such a
> script?

No, I was thinking for the need to have the server up that early. :-?

> You’re right, wol just shoots a broad load without listening. So all I
> can get from logs is if wol did shoot or not.
>
> Off to put that script for background process as you sufĝgested above
>
>
> Thanks so far and greetings, till later…

Welcome. It is an interesting project :slight_smile:


Cheers / Saludos,

Carlos E. R.
(from 13.1 x86_64 “Bottle” at Telcontar)

On 2014-12-21 09:56, deano ferrari wrote:
>
> arvidjaar;2684317 Wrote:
>> It could take some time before network is up after resume. If you are
>> usign NM you probably should look at dispatcher scripts. Unfortunately
>> it does not look like NM passes information whether it returned from
>> suspend, so you can only run it every time interface is up.
> Yes, using a NM dispatcher script is probably the way to go here.

Not really.

I understand that the network can not be automatically restored till the
server is up and responds (because it has the dhcpd). And to awake the
server he needs to send it a wol packet.

So NM can’t complete.

And if it doesn’t complete, it is impossible to send the wol packet,
because there is no network device available for the wol program.

So what he does is create an interface using a fixed IP on another range
(not with NM), send the packet, destroy the interface.


Cheers / Saludos,

Carlos E. R.
(from 13.1 x86_64 “Bottle” at Telcontar)

On 2014-12-21 11:06, seuchato wrote:

> in “/etc/pm/sleep.d” i got these two scripts: “00serverwakeupcall” and
> “serverwakeup”

I think that “serverwakeup” has to be on another directory, because it
may run twice.

Also, I had problems with scripts named “00*”, minimum is “05*” (00 did
not run, IIRC). You also have to experiment on what works better, 05 or 95.


>   LANG=en ping -c 1 $serverip
>   rv=$?

:-))

I think you can just set “LANG=en_EN” globally in the variables section
of your script.


eho "server still asleep"

missing ‘c’ :wink:

> and here the relevant part of
>
>
> Code:
> --------------------
> cat pm-suspend.log
> …
> fbcon fb0 state 1
> fbcon fb0 state 0
> switching back to vt7… succeeded
> Son Dez 21 10:55:25 CET 2014: Awake.
> Son Dez 21 10:55:25 CET 2014: Running hooks for resume
> Running hook /etc/pm/sleep.d/serverwakeup resume suspend:

You see, it is called directly, outside of 00serverwakeupcall (which
calls it without parameters)

> Waking up 00:22:4D:B1:E7:D0…
> PING 192.168.23.4 (192.168.23.4) 56(84) bytes of data.
> From 192.168.23.254 icmp_seq=1 Destination Host Unreachable

What about routing? It may not be setup.

> --------------------

Just some ideas… :slight_smile:


Cheers / Saludos,

Carlos E. R.
(from 13.1 x86_64 “Bottle” at Telcontar)

Do you mean you are trying to send WOL packet back to the same system? I.e. host A sends WOL to host A?