7

I have a new GNU/Linux Debian 9 server installation.

This is what I get from ethtool:

root@web-server:~# ethtool enp2s0
Settings for enp2s0:
        Supported ports: [ TP MII ]
        Supported link modes:   10baseT/Half 10baseT/Full
                                100baseT/Half 100baseT/Full
                                1000baseT/Half 1000baseT/Full
        Supported pause frame use: No
        Supports auto-negotiation: Yes
        Advertised link modes:  10baseT/Half 10baseT/Full
                                100baseT/Half 100baseT/Full
                                1000baseT/Half 1000baseT/Full
        Advertised pause frame use: Symmetric Receive-only
        Advertised auto-negotiation: Yes
        Link partner advertised link modes:  10baseT/Half 10baseT/Full
                                             100baseT/Half 100baseT/Full
                                             1000baseT/Full
        Link partner advertised pause frame use: Symmetric Receive-only
        Link partner advertised auto-negotiation: Yes
        Speed: 1000Mb/s
        Duplex: Full
        Port: MII
        PHYAD: 0
        Transceiver: internal
        Auto-negotiation: on
        Supports Wake-on: pumbg
        Wake-on: g
        Current message level: 0x00000033 (51)
                               drv probe ifdown ifup
        Link detected: yes

So, you see the Magic Packet is on (Wake-on: g).


I am waking this computer from power off state like this:

./wolcmd 00********** 192.168.0.104 255.255.255.0 7  # I've hidden the MAC address here

from Cygwin on Windows 10 using Depicus Wake On Lan Command Line.


What I do not understand is, why I need to specify the IP address and mask or port number?

Why is MAC address not enough? Could anyone elaborate...

  • Note that this question is only borderline on-topic. Wake-On-LAN is not really specific to Unix or Linux, and isn't implemented by operating system softwares. Debian 9 isn't relevant really, because Debian isn't running at the time on the target machine, it being switched off. The tool mentioned is a Win32 program, so aspects of that program itself are definitely off-topic. Fortunately, the question as asked isn't about the tool, although several people have strayed into talking about the tool and not the mechanism. – JdeBP Aug 2 '18 at 9:52
11

A WoL magic packet can be sent either to UDP port 0, 7, or 9 (depending on the hardware in use) or as a raw Ethernet packet of type 0x0842. wolcmd has elected to use the former method, defaulting to port 7.

Note that wolcmd does support UDP broadcast, meaning that you can specify 255.255.255.255 as the address and mask if your hardware and network support TCP/IP broadcasts. The magic packet will only be interpreted by the machine whose MAC address it contains; all others will ignore it.

  • Good answer. I also have the same question as the OP, what is the IP address doing there, as a layer 2 packet, should not the MAC be enough? – Rui F Ribeiro Aug 1 '18 at 15:30
  • 5
    According to Wikipedia the only requirement for the magic packet is that the Ethernet frame contains six FFs, followed by 16 repetitions of the target computer's MAC address. The IP address is probably intended for situations where the packet is forwarded by a router, but I don't see how that can reliably work, since (if the target computer is turned off) the address quickly vanishes from the ARP cache. The creator of wolcmd does not seem very competent. – Johan Myréen Aug 1 '18 at 15:33
  • 1
    It's very simple. There's no way to have a UDP/IP datagram without an IP header, and IP headers need two addresses. – JdeBP Aug 1 '18 at 16:03
  • 1
    @JohanMyréen You can do a directed broadcast into another network as long as the router has been configured to do so. – ErikF Aug 2 '18 at 1:46
  • @JdeBP Yes, but what destination address? The target computer doesn't exist on the network, because it is turned off. The IP address the target computer had when it was still turned on is most likely long gone from the sending computer's ARP cache. And why is there even an option to specify the subnet mask? – Johan Myréen Aug 2 '18 at 6:50
1

The syntax used is: wolcmd [mac address] [ip address] [subnet mask] [port number = 7]

The [ip address] and [subnet mask] are used in cases where you need to wake a computer over the internet. The [ip address] does not have to be a numbered IP, you can use a named address or DDNS address and your DNS will convert it to an IP.

I have not confirmed this yet but I would guess, if you are waking a computer on your local network, the [ip address] and [subnet mask] are not really needed. You can set them both to 255.255.255.255 and it would probably work.

The [port number] is optional and can be left off defaulting the port to 7.

Another possible application of the [ip address] is to tell your router to assign that ip address to that mac address once the computer is awake and asking for a DHCP address. This would depend on the router's intelligence and whether that ip address is not already assigned. (not sure if/how that would work over the internet).

0

Perhaps it is to be used across the internet. Specifying an IP address would send it to the correct router, where it could be sorted out from there. If the computer had a static IP address on the local network then the router could certainly figure it out (perhaps it would need more advanced configuration than a consumer router, but I can see the application.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.