Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

So i've seen the WOL scripts and they seem like they could work well when i'm trying to connect from a computer that is outside my router.

Script i'm using: http://www.dd-wrt.com/wiki/index.php/Useful_Scripts#Web_Server_Wake-up

Now the problem that i see is that when ever i'm home the WOL script will be useless because the initiating computer and the server are on the same subnet so the router will not log the request.

Is there a way to have the router log the requests that are sent between two computers inside its network? I'm not very knowledgeable when it comes to network structure but i don't know if this is possible. Do i need to somehow proxy all my traffic through my router?

For explanation here is what i'm trying to do:

I have my home server that serves up SMB, AFP, HTTP(s), and a few other web applications. I would like the server to be sleeping when its not being accessed period. So if something outside the network requests HTTP access i want the server to wake up. If a computer on the local subnet requests a SMB share i want the server to wake up.

Can anyone help a noob out?

Things to note: I have an Ubuntu server. All machines that are on the local network are directly connected to the router. I have one hub that some machines are connected to but all traffic should be going through the router.

EDIT: Just had a thought. What if i put the server in question on a separate VLAN and allowed for communication between the VLAN through the router. Then the traffic would have to go through the firewall and i could log the traffic there. Would anyone know how to set up such a system?

share|improve this question

migrated from stackoverflow.com Aug 13 '12 at 1:22

This question came from our site for professional and enthusiast programmers.

    
"If you're ever at home" ... you could always reach for the "On" button ;) –  paulsm4 Aug 12 '12 at 21:30
    
Not possible when the Some users don't have access to the building where the server is. –  Chris Rice Aug 12 '12 at 22:56
    
Just to clarify, do you want the computer to receive a WoL packet whenever something tries to open a TCP connection to it while it's off? That might be suboptimal, since the TCP connection would be very slow to start and the application might time out. Would it be acceptable if users connected to a web page on the router to trigger the WoL event? –  Gilles Aug 13 '12 at 21:26
    
That is sorta my plan for HTTP requests. I would have them be authenticated with a splash page that's served up by the router and then forwarded to the server once its been brought online. As for the other services its ok if they timeout once because i can just inform the users that they may have to try and connect to the server twice. I figured that most of the services have a ~30sec timeout which would be enough time to bring the server up. I would guess that my trigger would be an attempted TCP connection on a specific port. –  Chris Rice Aug 13 '12 at 22:27

3 Answers 3

up vote 0 down vote accepted

Solved it by moving the server in question to a dedicated VLAN and then logging the traffic between it and the rest of the network by using specific iptable rules triggered on some ports.

I will have a full writeup on my site when i finish the project and will update this answer then.

share|improve this answer
    
Here is the writeup: wetzelrice.com/blog/… –  Chris Rice Aug 27 '12 at 22:31

A fairly simple method would be to call wol manually from your router. While you could do it upon reception of a packet, it might not work so well in practice, because of the large delay between the time when the WoL packet is sent and the time when the target machine is ready for processing. The application may well time out before the target machine is awake.

The Linux packet filter can pass packets to userspace through the QUEUE target, and you can write programs to react to these packets with the netfilter_queue library. I'm not aware of any existing such program that sends a WoL packet or executes another program (such as /usr/sbin/wol), but it doesn't sound hard to write. Knowing when to do this is another kettle of fish: you woulnd't want to go through all that whenever the computer that may need to be woken up receives a packet.

I favor having users do some manual action to cause the WoL packet to be sent. An easy method is to have a dedicated user on the router, with a script calling /usr/sbin/wol as its shell, and give SSH keys to authorized users. An easier method is to run a web server on the router — it can be some very simple one that can run CGI scripts — and have it run /usr/sbin/wol when users visit a page and provide accepted credentials.

share|improve this answer

You should just run /usr/sbin/wol to wake locally. Not sure what OS you run and/or if that's even supported on your OS. You'd have to run the command before you do try to access your server though. So it wouldn't be automatic.

Do i need to somehow proxy all my traffic through my router?

Well, that's one way to make it automatic. If you really must do it this way, setup your DHCP's netmask to 255.255.255.255, that way every LAN request does a round trip to the router. But this is very inefficient. Setting the netmask to 255.255.255.255 makes every machine think it's on its own network and any packet sent to anything except itself will need to go through the gateway (your router).

share|improve this answer
    
Yea I am running Ubuntu server and dd-wrt router. I can't just run the command locally because I have several other people who will be accessing its services locally that do not have devices capable of sending the wol command manually. Like iPads, etc.. –  Chris Rice Aug 12 '12 at 22:55

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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