Navigation

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

    Cron for WOL

    General pfSense Questions
    7
    24
    2369
    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.
    • K
      Khampol last edited by

      Hello,

      I find an old topic here but comand do not work. Please could someone update the right command?

      https://forum.pfsense.org/index.php?topic=30966.0

      :-\

      1 Reply Last reply Reply Quote 0
      • Gertjan
        Gertjan last edited by

        What do you mean ?

        [2.3.4-RELEASE][admin@pfsense.brit-hotel-fumel.net]/root: wol
        wol: Too few arguments.
        Try `wol --help' for more information.
        [2.3.4-RELEASE][admin@pfsense.brit-hotel-fumel.net]/root: wol --help
        Usage: wol [OPTION] ... MAC-ADDRESS ...
        Wake On LAN client - wakes up magic packet compliant machines.
        
            --help          display this help and exit
        -V, --version       output version information and exit
        -v, --verbose       verbose output
        -w, --wait=NUM      wait NUM millisecs after sending
        -h, --host=HOST     broadcast to this IP address or hostname
        -i, --ipaddr=HOST   same as --host
        -p, --port=NUM      broadcast to this UDP port
        -f, --file=FILE     read addresses from file FILE ("-" reads from stdin)
            --passwd[=PASS] send SecureON password PASS (if no PASS is given, you
                            will be prompted for the password)
        
        Each MAC-ADDRESS is written as x:x:x:x:x:x, where x is a hexadecimal number
        between 0 and ff which represents one byte of the address, which is in
        network byte order (big endian).
        
        PASS is written as x-x-x-x-x-x, where x is a hexadecimal number between 0
        and ff which represents one byte of the password.
        
        Report bugs to <krennwallner@aon.at></krennwallner@aon.at>
        

        The command works ….
        The cron package exists also now.
        I just woke up our coffee machine.....

        No "help me" PM's please. Use the forum.

        1 Reply Last reply Reply Quote 0
        • K
          Khampol last edited by

          I have this.. (see pict). Normally it should wake my NAS everyday at 10.01.
          It never wake it… :(

          PS : My NAS wakes up if I do WOL manually.


          1 Reply Last reply Reply Quote 0
          • Gertjan
            Gertjan last edited by

            Putting the command in a cron is the final step.

            You tested the command from the console (SSH !) interface ?
            You did set up the NAS so it wakes up on when it receives the WOL packet ?
            Try also to wake it up from a windows PC using : https://sourceforge.net/projects/aquilawol/
            And even : try to wake up a Windows PC (settings have to be made in Windows and may be even the BIOS).
            When you can WOL "by hand" only then you automise (by cron).
            Check if the cron line is executed (see logs).

            No "help me" PM's please. Use the forum.

            1 Reply Last reply Reply Quote 0
            • K
              Khampol last edited by

              Yes I know what mean WOL ! LOL!  ;D ;D ;D
              Years I do manually (by hand..).

              In Pfsense there is ALSO a function for WOL and "by hand" it works perfectly with my NAS.

              Thats why I am confused…


              1 Reply Last reply Reply Quote 0
              • I
                Issom last edited by

                Any update on this old topic? I am in the same boat as OP.
                I can manually start my unraid server and test Dell laptop from the WOL menu under Services but when I try to schedule the cron job or run the command manually I do not get the WOL protocol.
                I am monitoring the network traffic from Wireshark and I can see a protocol "WOL" when I run the wake up from the Services menu. When I try to run this command from cron or manually under Diagnostics> command prompt I only see TCP protocols broadcast.
                I am trying to wake both Unraid and Dell laptop.

                here is the commands I have been trying

                /usr/local/bin/wol (Mac address) This will broadcast to entire IP scheme
                /usr/local/bin/wol -v -i 172.x.x.x (Mac address) This only targets the exact IP of the machine

                Any help would be great
                Thanks
                Issom

                Kalle13 1 Reply Last reply Reply Quote 0
                • Gertjan
                  Gertjan last edited by

                  Dono ....
                  I just power down a PC next to me, and the I typed in

                  /usr/local/bin/wol -v -i 192.168.1.7 b8:ac:6f:47:2d:b2
                  

                  The PC woke up immediately.

                  Btw : I use the console access. That the one for 'real' commands.

                  No "help me" PM's please. Use the forum.

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

                    It's usually because the user Cron runs with is not admin/root and somethings are subtly different. Default paths, permissions etc. You are using the complete path so that rules that out. Do you see any errors logged at that time?

                    Steve

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

                      @Issom Hi,
                      I know what you and OP mean. I have the same issue. It works manually but not via cron.
                      I want to wake up my server at 7 am but it won' t work. So after I realized it was not working I punshed the command in the command line and I got one error. It says that the host was not reachable. But direct after that I used the WOL service of the pfsense and it worked perfectly. (I am using pfSense 2.4.4. p3)
                      So was is the weird behaviour?

                      Best regards

                      "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
                      • Kalle13
                        Kalle13 last edited by

                        I've discovered a solution for this problem. Here you can find it. It' s a german post. Translated it says:
                        You have to activate the "static ARP" option at the "DHCP Static Mappings for this Interface" of the DHCP Server. Now you can wake your Host up with (direct from shell or via cron):
                        /usr/local/bin/wol -i IP MAC

                        Best regards

                        "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
                        • stephenw10
                          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

                          Kalle13 1 Reply Last reply Reply Quote 0
                          • Kalle13
                            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.
                              
                              
                              Gertjan 1 Reply Last reply Reply Quote 1
                              • Gertjan
                                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.

                                1 Reply Last reply Reply Quote 1
                                • Bob.Dig
                                  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

                                  Primitive Threat on Layer 8

                                  Remember: Upvote with the 👍 button for any user/post you find to be helpful, informative, or deserving of recognition!

                                  Gertjan 1 Reply Last reply Reply Quote 0
                                  • Gertjan
                                    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.

                                    Bob.Dig 1 Reply Last reply Reply Quote 1
                                    • Bob.Dig
                                      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

                                      Primitive Threat on Layer 8

                                      Remember: Upvote with the 👍 button for any user/post you find to be helpful, informative, or deserving of recognition!

                                      Gertjan 1 Reply Last reply Reply Quote 0
                                      • Gertjan
                                        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.

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

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

                                          Bob.Dig 1 Reply Last reply Reply Quote 0
                                          • Bob.Dig
                                            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.

                                            Primitive Threat on Layer 8

                                            Remember: Upvote with the 👍 button for any user/post you find to be helpful, informative, or deserving of recognition!

                                            Gertjan 1 Reply Last reply Reply Quote 0
                                            • Gertjan
                                              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.

                                              Bob.Dig 1 Reply Last reply Reply Quote 2
                                              • Bob.Dig
                                                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. 🙂

                                                Primitive Threat on Layer 8

                                                Remember: Upvote with the 👍 button for any user/post you find to be helpful, informative, or deserving of recognition!

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

                                                  @bob-dig I edited - see above.

                                                  No "help me" PM's please. Use the forum.

                                                  Bob.Dig 1 Reply Last reply Reply Quote 1
                                                  • Bob.Dig
                                                    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 !!

                                                    Primitive Threat on Layer 8

                                                    Remember: Upvote with the 👍 button for any user/post you find to be helpful, informative, or deserving of recognition!

                                                    1 Reply Last reply Reply Quote 0
                                                    • First post
                                                      Last post