Our college local network has many computers with local IPs, and there's a gateway or a server which sends and receives the traffic and it has a static IP. So when I am away from that network and I want to access my computers in that network, I know their MAC addresses and their local IPs in that network and the static live IP of that network.

I have Ubuntu on my systems. I can turn on the systems locally, but I also want to know:

  • How can I do that over the internet?
  • How to even ping a system in that network?
  • How to do port forwarding in this situation? or if there is any method in which you don't have to forward the ports in routers?

I tried this but it doesn't work!


The magic packet sent using Wake-On-LAN is not transmitted over the internet. You need to send this packet from one of the computers in the LAN, eg through a remote login.

The router or gateway in your universities LAN seems to do NAT. Unless you have administrative access to the gateway - eg to configure port forwarding - or you can login to one of the machines on the LAN, there is no way gaining access to a machine behind the NAT.

You could circumvent the NAT if the network uses IPv6, as NAT in IPv6 is not commonly used (and shouldn't). But this still wont help you sending the magic packet.


You will need to be able to ssh to the gateway, from there, assuming your network cards support it, you will be able to turn your machines on.

First, make sure your network cards support wakeonlan. From the target machine, run

 sudo aptitude install ethtool
 sudo ethtool eth0

If the output of ethtool contains a line like Supports Wake-on: g, you should be fine. Now, set up the machine to allow it:

sudo nano /usr/bin/wakewol

Add these lines to the file you just created:

ethtool -s eth0 wol g

Save the file and run sudo chmod 755 wakewol to make it executable. Now, run

sudo nano /etc/network/interfaces

and add this line to the end of the file:

post-down /usr/bin/wakewol

Your machine should now support wakeonlan. However, there is no way to do this without first logging in to the gateway server. Something like this:

rana@local $ ssh rana@gateway
rana@gateway $ wakeonlan 01:02:03:04:05:06

Just change 01:02:03:04:05:06 to the actual MAC address of the machine you want to turn on. This assumes that wakeonlan is already installed on the gateway server.

This can be further simplified by passing the wakeonlan command to ssh to be executed on the gateway:

ssh rana@gateway wakeonlan 01:02:03:04:05:06



  • You don't need access to the gateway I guess. If the gateway forwards ssh to another machine, it should work too. – Baarn Dec 4 '13 at 18:17
  • @Baarn you mean a tunnel? One way or the other, you need to get access to the remote LAN or the machines will not be visible. – terdon Dec 4 '13 at 18:19
  • Simple port forwarding. Eg: my router forwards port 22 on WAN to another machines port 22 from where I control the rest of the network. It might be possible that the universities remote login computer - if there is any - isn't the same as the gateway. – Baarn Dec 4 '13 at 18:22
  • @Baarn true enough but since the OP mentioned a gateway that has a static IP, presumably he has access to it and port forwarding (which will require a high level of administrative power) is not needed. – terdon Dec 4 '13 at 18:36

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.