cancel
Showing results for 
Search instead for 
Did you mean: 

Wake on LAN on Hub One

Miguel7
Newbie
Posts: 1
Registered: 26-04-2016

Wake on LAN on Hub One

I have read 3 threads on this but none really have a specific answer. I have configured Wake On Lan on my PC and it does work in Sleep or Hibernate mode. However it only works for around 15-30 minutes. I suspect this is because after a while the ARP table is refreshed on the router and my PC, is taken off so the ping packet has no destination to go to.

Has anyone got Wake on LAN working on this router? Is it even possible? Plusnet, it would be nice if you could let us know because it would appear there is a minimal amount of configuration we can do on this router.

Thanks

2 REPLIES
Community Veteran
Posts: 4,746
Thanks: 1,045
Fixes: 27
Registered: 16-10-2014

Re: Wake on LAN on Hub One

It’s of no comfort or even any use to you but I had a need to control some PCs via WoL and your suspicion about the ARP cache is correct. I ended up writing a C++ class that scanned the ARP table and if it couldn’t find the entry, it added it, after doing this I could then send the WoL packet and the PC would wake from its slumber.

const int WOLSender::setARP(const char * pAddr, const char * pMAC) {
    int ok(0), arpSocket(socket(AF_INET, SOCK_DGRAM, IPPROTO_IP)) ;
    if (arpSocket < 0) {
        syslog(LOG_CRIT, "%s", "Unable to get Socket DataGram for APR set!") ;
    }
    else {
        struct in_addr ipaddr ;
        if (inet_aton(pAddr, &ipaddr) == 0) {
            syslog(LOG_INFO, "Invalid IP Address %s", pAddr) ;
        }
        else {
            struct arpreq arp ;
            std::memset(&arp, 0, sizeof(arpreq)) ;
            arp.arp_ha.sa_family = ARPHRD_ETHER ;
            std::memcpy(&arp.arp_ha.sa_data, pMAC, std::strlen(pMAC)) ;
            arp.arp_flags = ATF_PERM | ATF_COM ;
            struct sockaddr_in * sin = (struct sockaddr_in *) &arp.arp_pa ;
            sin->sin_addr = ipaddr ;
            sin->sin_family = AF_INET ;
            strncpy(arp.arp_dev, ETH_IF, std::strlen(ETH_IF)) ;
            if (ioctl(arpSocket, SIOCSARP, (caddr_t) &arp) < 0) {
                syslog(LOG_INFO, "arp ioctl set request failed : %d", errno) ;
            }
            else {
                syslog(LOG_INFO, "Added %s's MAC %s to ARP Cache!", pAddr, pMAC) ;
                ok = 1 ;
            }
        }
    }
    close(arpSocket) ;
    return ok ;
}

 

mssystems
Rising Star
Posts: 269
Thanks: 33
Fixes: 1
Registered: 10-08-2007

Re: Wake on LAN on Hub One

WoL is an L2 protocol, that is to say WoL operates with MAC addresses at the DLC layer below IP.  I have come across the odd router doing proprietary nonsense with a static arp entry; allowing the magic packet to be triggered on the LAN segment by sending a special command to the routers WAN interface.  Been A while since I noticed the  feature on any router.