Netgate Discussion Forum
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Search
    • Register
    • Login

    Cron for WOL

    Scheduled Pinned Locked Moved General pfSense Questions
    24 Posts 7 Posters 5.6k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • stephenw10S
      stephenw10 Netgate Administrator
      last edited by

      Hmm, that should not be required. The machine doing the waking should not need to know anything but the MAC address.
      Does it just not send the packet if you use the MAC only?

      Steve

      Kalle13K 1 Reply Last reply Reply Quote 0
      • Kalle13K
        Kalle13 @stephenw10
        last edited by

        @stephenw10
        Sorry, I don't know. I didn' t used the wol command without the IP option.

        "Jeder kocht mit Wasser, man kann das Binsenweisheit nenn`. Der unterschied zu dir ist, dass wir zwei kochen könn`"

        • Kinderzimmer Productions
        1 Reply Last reply Reply Quote 0
        • P
          pbshaan
          last edited by

          I bumped into the same problem. Sharing my findings for future visitors (tested with VLANs present - not sure if it matters).

          Interface required:

          Specifying the interface is optional, but without it the command doesn't work.

          • wol xx:xx:xx:xx:xx:xx - executes, but no magic packet to device.
          • wol -i 192.168.1.255 xx:xx:xx:xx:xx:xx - works.

          Entries required in /etc/crontab:

          • Manually add job definition to /etc/crontab - works, job triggers.
          • crontab -e (as root user) - reports success, but job doesn't trigger. I also tried restarting cron after adding entries as another post suggested, but no luck.

          So, edit /etc/crontab file directly and add your entry there. For the interface address, either machine IP or broadcast IP may be specified.

          e.g.. /etc/crontab

          ...
          
          # Wake up server at 6:30
          30      6       *       *       *       root    wol -i 192.168.1.255 c0:3f:d5:66:XX:XX
          
          ...
          
          #
          # If possible do not add items to this file manually.
          
          
          GertjanG 1 Reply Last reply Reply Quote 1
          • GertjanG
            Gertjan @pbshaan
            last edited by

            @pbshaan said in Cron for WOL:

            So, edit /etc/crontab file directly

            😵

            pfSense most simple package might be useful here.
            Introducing the wol package :

            bb18c5ad-908a-4447-8c3a-4621fcc7cc46-image.png

            Now, your own crons will even be saved in the global pfSense config, making it a real set it and forget it thing.

            Also, according to the "official manual" :

            0d60bcc0-82f6-4e13-b8ba-ec4b10700f4a-image.png

            If FreeBSD was installed on desktop type device with a single NIC, then this option is an option as there is only one NIC.
            Our pfSense tends to have at least 2 NICs. So the option is qualified as "important".
            I guess it's even a security issue if wol starts to send its notifications on all my xx interfaces.

            No "help me" PM's please. Use the forum, the community will thank you.
            Edit : and where are the logs ??

            1 Reply Last reply Reply Quote 1
            • Bob.DigB
              Bob.Dig LAYER 8
              last edited by Bob.Dig

              Also had no luck getting wol with cron to work, the command is not even working in the GUI command prompt...

              /usr/local/bin/wol -v -i 192.168.1.21 dx:50:99:92:11:e7
              /usr/local/bin/wol dx:50:99:92:11:e7

              Capture2.png

              But working flawlessly via the pfSense >Services>Wake-on-LAN

              GertjanG 1 Reply Last reply Reply Quote 0
              • GertjanG
                Gertjan @Bob.Dig
                last edited by Gertjan

                @bob-dig

                I ping 192.168.1.2 : it's powered down.
                I "wol" it.
                It ping again and it replies ....

                [2.5.2-RELEASE][admin@pfsense.local.net]/root: wol
                wol: Too few arguments.
                Try `wol --help' for more information.
                [2.5.2-RELEASE][admin@pfsense.local.net]/root: ping 192.168.1.2
                PING 192.168.1.2 (192.168.1.2): 56 data bytes
                ^C
                --- 192.168.1.2 ping statistics ---
                3 packets transmitted, 0 packets received, 100.0% packet loss
                [2.5.2-RELEASE][admin@pfsense.brit-hotel-fumel.net]/root:  wol -v -i 192.168.1.2 00:4e:01:ac:ca:9c
                Waking up 00:4e:01:ac:ca:9c with 192.168.1.2:40000...
                [2.5.2-RELEASE][admin@pfsense.local.net]/root: ping 192.168.1.2
                PING 192.168.1.2 (192.168.1.2): 56 data bytes
                64 bytes from 192.168.1.2: icmp_seq=2 ttl=128 time=0.255 ms
                64 bytes from 192.168.1.2: icmp_seq=3 ttl=128 time=0.325 ms
                64 bytes from 192.168.1.2: icmp_seq=4 ttl=128 time=0.333 ms
                64 bytes from 192.168.1.2: icmp_seq=5 ttl=128 time=0.291 ms
                ^C
                --- 192.168.1.2 ping statistics ---
                6 packets transmitted, 4 packets received, 33.3% packet loss
                round-trip min/avg/max/stddev = 0.255/0.301/0.333/0.031 ms
                

                In the past, when wol was still a magic (pun intended) thing, there was a tool that you could run on the device to be waken up : it showes you that it's NIC did receive the magic wake up packets.
                These packets are used to wake up the device, if it is able to do so, and if it was allowed to do (by driver and or BIOS settings).

                No "help me" PM's please. Use the forum, the community will thank you.
                Edit : and where are the logs ??

                Bob.DigB 1 Reply Last reply Reply Quote 1
                • Bob.DigB
                  Bob.Dig LAYER 8 @Gertjan
                  last edited by Bob.Dig

                  @gertjan One difference might be that my NIC doesn't have an IP address, its only purpose it to wake up the PC.

                  And again, it is working flawlessly via the GUI Services>Wake-on-LAN

                  GertjanG 1 Reply Last reply Reply Quote 0
                  • GertjanG
                    Gertjan @Bob.Dig
                    last edited by Gertjan

                    @bob-dig said in Cron for WOL:

                    And again, it is working flawlessly via the GUI Services>Wake-on-LAN

                    GUI Services>Wake-on-LAN ?
                    Aha, you mean https://pfsense.yourlocal.tld/services_wol.php.

                    You had a look how "services_wol.php" does it's wol thing ?
                    ( it used the wol command like you ;) )

                    See here https://github.com/pfsense/pfsense/blob/master/src/usr/local/www/services_wol.php - line 51.

                    'wol' needs an IP ( ?) so it can determine the interface to be used..
                    The interface has an IP, right ?

                    When I used a fake IP, like 192.168.1.200 instead of 192.168.2, my "00:4e:01:ac:ca:9c" device didn't wake up.

                    No "help me" PM's please. Use the forum, the community will thank you.
                    Edit : and where are the logs ??

                    1 Reply Last reply Reply Quote 1
                    • stephenw10S
                      stephenw10 Netgate Administrator
                      last edited by

                      What happens if you use the pfSense interface IP there? In the same segment as the target?

                      Bob.DigB 1 Reply Last reply Reply Quote 0
                      • Bob.DigB
                        Bob.Dig LAYER 8 @stephenw10
                        last edited by Bob.Dig

                        @stephenw10 Doesn't work either and yes.

                        If I try with putty I get this.

                        [2.5.2-RELEASE][admin@pfSense.home.arpa]/root: /usr/local/bin/wol -v -i 192.168.1.1 d0:50:99:92:11:e7
                        Waking up d0:50:99:92:11:e7 with 192.168.1.1:40000...
                        [2.5.2-RELEASE][admin@pfSense.home.arpa]/root: /usr/local/bin/wol -v d0:50:99:92:11:e7
                        /usr/local/bin/wol: Cannot send magic packet for 'd0:50:99:92:11:e7' to 255.255.255.255:40000: Permission denied
                        [2.5.2-RELEASE][admin@pfSense.home.arpa]/root: /usr/local/bin/wol d0:50:99:92:11:e7
                        /usr/local/bin/wol: Cannot send magic packet for 'd0:50:99:92:11:e7' to 255.255.255.255:40000: Permission denied
                        [2.5.2-RELEASE][admin@pfSense.home.arpa]/root:
                        
                        

                        But again, none of this worked.

                        GertjanG 1 Reply Last reply Reply Quote 0
                        • GertjanG
                          Gertjan @Bob.Dig
                          last edited by Gertjan

                          @bob-dig

                          If your "device without IP" ( serious ?? see below ) is some windows device, try this :

                          https://www.depicus.com/wake-on-lan/wake-on-lan-monitor

                          b5d92fac-bb97-4596-928d-944c68793f6e-image.png

                          I had to indicate a port number like "40000" on both side so the command line works :

                          wol -i 192.168.1.2 00:4e:01:ac:ca:9c -p 4000
                          Waking up 00:4e:01:ac:ca:9c...
                          

                          The tool on the device, my PC, that it received the special pachet (5 times the device MAC as the data payload)

                          See also the FreeBSD mn page for wol https://www.freebsd.org/cgi/man.cgi?query=wol&manpath=ports&sektion=1

                          edit : a device in lower power mode doesn't have - use an IP(v4 or v6).
                          It just listens to the incoming data stream, and knows how to detect if it's won MAC is present 5 times in a row. No processor power is needed.

                          wol needs a IP or host just to so it can find out on what interface to use if it is "multi homed", like our pfSense. The actual IP shouldn't matter ......
                          But .....
                          I think © that our switches play an important role here. Switches are not hubs, so traffic isn't broadcasted any more.
                          When I use the broadcast IP of my LAN, like :

                          wol -i 192.168.1.255 -p 4000 00:4e:01:ac:ca:9c
                          

                          it worked, the Wake On Lan monitor on my PC showed the incoming magic packet.

                          No "help me" PM's please. Use the forum, the community will thank you.
                          Edit : and where are the logs ??

                          Bob.DigB 1 Reply Last reply Reply Quote 2
                          • Bob.DigB
                            Bob.Dig LAYER 8 @Gertjan
                            last edited by Bob.Dig

                            @gertjan I want to use wol (not pattern match?) for this. I ended up using wol.exe on another Windows host together with windows tasksheduler to achieve what pfSense couldn't do for me. 🙂

                            GertjanG 1 Reply Last reply Reply Quote 0
                            • GertjanG
                              Gertjan @Bob.Dig
                              last edited by

                              @bob-dig I edited - see above.

                              No "help me" PM's please. Use the forum, the community will thank you.
                              Edit : and where are the logs ??

                              Bob.DigB 1 Reply Last reply Reply Quote 1
                              • Bob.DigB
                                Bob.Dig LAYER 8 @Gertjan
                                last edited by Bob.Dig

                                @gertjan So this time I tried in putty:

                                /usr/local/bin/wol -v -i 192.168.1.255 d0:50:99:92:11:e7
                                
                                

                                And it did work. Then I tried cron, also does work!

                                So the key is to use .255 at the end.

                                I still wonder why the web-GUI-thingy works with the MAC only, but on the other hand, when I first added the host to the Wake-on-LAN Devices list, it had an IP-address, so it might have saved it there.

                                Thank you @Gertjan !!

                                1 Reply Last reply Reply Quote 0
                                • First post
                                  Last post
                                Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.