?
Solved

How to change the port that a NIC listens on for WOL on Ubuntu server

Posted on 2009-02-16
31
Medium Priority
?
1,048 Views
Last Modified: 2013-12-06
I would like to change the listening port of my home server's NIC (which is currently set to the default of port 9) because my workplace blocks port 9 and I can't send out my magic packet. Anyone know how to do this?

thanks
0
Comment
Question by:xoundboy
  • 14
  • 12
  • 4
30 Comments
 
LVL 16

Expert Comment

by:ai_ja_nai
ID: 23652375
say you want to change from port 9 to port 9999; use iptables to forward traffic coming to port 9999 of your server to its port 9.

iptables -A PREROUTING -dport 9 -j REDIRECT -to-ports 9999
0
 
LVL 16

Expert Comment

by:ai_ja_nai
ID: 23652380
Then, of course, you have to transmit your packets to port 9999 of your server ;)
0
 
LVL 2

Author Comment

by:xoundboy
ID: 23652739
Thanks for the comments. I should have mentioned a couple of things (sorry about that)...

1. I need to use port 22 as this is the only port I know of that my workplace's firewall will allow me to use.
2. I need port 22 for SSH once the server's switched on.


0
Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

 
LVL 16

Expert Comment

by:ai_ja_nai
ID: 23653517
Ok, you can use ssh to forward connections like this

ssh -NL 22:remoteaddress:remoteport user@remotehost

this will tunnel everything sent through port 22 to the specified port on the remote server. See 'man ssh' for more infos
0
 
LVL 29

Expert Comment

by:fosiul01
ID: 23657436
Hi good morning

i was reading about this magic packet and wakeup lan method.

from my understanding its default listen on port 9,
so if you want to change this port from 9 to 9999 dont you have to change the port number in your ehtercard aswell ??

have a look this one it might h elp you to change port number in ethercard in you home server

http://ubuntuforums.org/archive/index.php/t-360901.html   [ first solution]

0
 
LVL 16

Expert Comment

by:ai_ja_nai
ID: 23657912
if you tunnel the magic packet from port 22 on the source to 9 on the target it should work.. shouldn't?
0
 
LVL 29

Expert Comment

by:fosiul01
ID: 23657923
yes, the way you saying, it should work , in that case he does not need to change his port 9 to anything else beause request is going via ssh by definning remote port 9
0
 
LVL 16

Expert Comment

by:ai_ja_nai
ID: 23658581
To be honest, I did not know that WOL was wake-on-lan :p I thought it was some kind of World of Warcraft stuff.

Actually, I don't know if you can change predefinite port 9 for wol to an arbitrary one
0
 
LVL 2

Author Comment

by:xoundboy
ID: 23658773
I imagine that I have to reset the port on which the NIC is listening to port 22 (from 9) and then close down the server. I can then send a magic packet over port 22 thus getting through my work's firewall. The packet will then be received by my home server's NIC and the server will start up again. The option of tunneling is not available because the destination server is switched off! I simply need to know how to change the NIC's WOL listening port. I had quite a good look on google but couldn't find anything about it - was just wondering whether anyone had ever done this?
0
 
LVL 29

Expert Comment

by:fosiul01
ID: 23658839
hi, the link i sent if read its saying how to change listning port.
0
 
LVL 16

Expert Comment

by:ai_ja_nai
ID: 23658896
>The option of tunneling is not available because the destination server is switched off!

if you tunnel a packet through port 22 it will get at port 9. The server doens't need to have ssh running on the other side
0
 
LVL 29

Expert Comment

by:fosiul01
ID: 23659043
Hi as i said, i didnot work on wakeup lan so i cant say anything to aj_ja_nai

but if you want to change port number for ethernet card

you need to install wakeuplan softwae on your ubuntu and you need to do this

i just copied from taht link

wakeonlan -i 192.168.1.255 00:16:EC:4C:45:56 # broadcasts to the subnet broadcast address

# wakeonlan -i 192.168.1.255 -p 7 00:16:EC:4C:45:56 # broadcasts to the subnet broadcast address on port 7

# wakeonlan 00:16:EC:4C:45:56 # broadcasts to the limited broadcast address

# wakeonlan 00:16:EC:4C:45:56 -p 7 # broadcasts to the limited broadcast address on port 7
0
 
LVL 2

Author Comment

by:xoundboy
ID: 23660486
@ai_ja_nai

>> >The option of tunneling is not available because the destination server is switched off!

>>if you tunnel a packet through port 22 it will get at port 9. The server doens't need to have ssh running on the other side

In that case I don't quite understand what you mean by "tunneling"- the only time I've ever used tunnelling (eg. SFTP and accessing  a MySQL db through SSH because direct connections are not allowed from remote machines) this has required that the ssh server be running on the target machine. In this case the target machine is switched off. What other way is there of tunneling?

@fosiul01

thanks - I will attempt your steps when I get home from work tonight.
0
 
LVL 16

Expert Comment

by:ai_ja_nai
ID: 23661420
you can tunnel to the router which your sleeping system is attached to and from there you can send the magic packet
0
 
LVL 2

Author Comment

by:xoundboy
ID: 23661823
I didn't think about that - I'm not sure if this is possible with my router - its a Linksys WRT54g and can do basic port forwarding but I don't think it can do IP tables - maybe it can though - I'll take a look.
0
 
LVL 16

Expert Comment

by:ai_ja_nai
ID: 23662089
you should replace the normal firmware with the linux stack, they really rock
0
 
LVL 2

Accepted Solution

by:
xoundboy earned 0 total points
ID: 24010101
Sorry for the delay chaps - it's been a busy time.


@ai_ja_nai
I took a look at the WRT54G linux stack option but unfortunately I have the 'C' compact version which doesn't support this firmware. I'm seriously considering getting the L version though now after you aroused my interest.

ANyway, in the end I decided the only way that I could really solve the problem was to use port 9 but to place a PHP script on a web server that I can browse whenever I need to switch my home server on remotely. I set it up and blogged a tutorial for it here:

http://blog.xoundboy.com/?p=196

thanks for your efforts everyone but I'm going to keep the points cause no-one really came up with a solution that worked. I had to figure it out myself.

0
 
LVL 16

Expert Comment

by:ai_ja_nai
ID: 24012142
That'snot true, I proposed one on comment #23661420 (tunnel through the router)
0
 
LVL 2

Author Comment

by:xoundboy
ID: 24013787
OK, so maybe would care to explain exactly what you mean by "tunnel through the router" given that my router is a wrt54gc.
0
 
LVL 16

Expert Comment

by:ai_ja_nai
ID: 24014625
Other than port 22, you surely will have port 80 open on your workplace. You configure your router to forward packets incoming from port 80 to port 9 of your sleeping pc. Then, send the magic packet over port 80 of your router and you are done, the router will forward it to the right port and your system will wake up
0
 
LVL 2

Author Comment

by:xoundboy
ID: 24016978
>> You configure your router to forward packets incoming from port 80 to port 9 of your sleeping pc

I logged into the router's admin pages and looked everywhere for a means of doing this but couldn't find one... that's not to say that it's not possible. Maybe you could explain the steps that I would need to take to set this up. Thanks.
0
 
LVL 16

Expert Comment

by:ai_ja_nai
ID: 24017616
0
 
LVL 2

Author Comment

by:xoundboy
ID: 24018810
this does not explain how traffic arriving at the router on port 80 can be forwarded to my server on port 9. This type of simple port forwarding would only forward traffic to my server's IP address the same port (ie port 80) or am I missing something?
0
 
LVL 16

Assisted Solution

by:ai_ja_nai
ai_ja_nai earned 1000 total points
ID: 24020091
Simply, set in that page that all the traffic coming on port 80 of your router must be forwarded on port 9 of the interface connected to your sleeping pc.
From your office you send your magic packet through port 80 of your router. Your router sends the magic packet to port 9 of your sleeping pc and we are done.

Clearer than this is impossible...
0
 
LVL 2

Author Comment

by:xoundboy
ID: 24022998
if you take a closer look at 'that page' you will see that what you are suggesting is impossible
0
 
LVL 16

Expert Comment

by:ai_ja_nai
ID: 24030097
it's not impossible, it's simply incomplete. you also need this page (http://portforward.com/english/routers/port_triggering/Linksys/WRT54G/). Set port 80 triggered (start=80, end=80) to port 9 forwarded (start=9, end=9). Then, in port forwarding page set port 9 to the ip of your sleeping machine (you'll need a static ip, so that it just sends the packet to that interface)
0
 
LVL 2

Author Comment

by:xoundboy
ID: 24038106
sorry for the delay

these are the steps I took:
1. changed the magic packet sending port on remote machine to port 80
2. configured port triggering as outlined in your previous post
3. set up port forwarding for inbound traffic on port 9 to be sent to my server's IP address
4. sent the magic packet.

unfortunately this didn't work. So I then launched wireshark on the server to monitor incoming packets on port 9 and re-triggered the packet. There was definitely nothing received.

Now because I've no previous experience with port triggering I read up about it on wikipedia and it would appear that this method is flawed. For this to work an outbound connection from within the LAN would need to be initiated to the remote computer triggering the Magic Packet in order for the port triggering to function correctly. This is obviously not possible considering the whole point of the exercise is to switch on the server from a remote location without relying on any other hardware within my home LAN (except for the router of course).

If you can't think of another method then let's close this thread. I am happy to split the points 50-50 with you since you tried hard to help me and I appreciate it.

0
 
LVL 16

Expert Comment

by:ai_ja_nai
ID: 24038132
Dunno what to say. Are you sure you can't install a more advanced firmware?
0
 
LVL 2

Author Comment

by:xoundboy
ID: 24038939
fairly sure - that was the first thing I checked out but apparently the "GC" version of my router doesn't support openWRT or any other linux firmware -

http://yasha.okshtein.net/wrt54gc/

I'm looking to buy the WRT-54GL now so I can play around with the router's configuration a bit more.

Thanks for your help though :)


0
 
LVL 2

Author Comment

by:xoundboy
ID: 24063415
Thanks Vee_Mod for your advice - I as wondering how to handle this - you read my mind.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Join Greg Farro and Ethan Banks from Packet Pushers (http://packetpushers.net/podcast/podcasts/pq-show-93-smart-network-monitoring-paessler-sponsored/) and Greg Ross from Paessler (https://www.paessler.com/prtg) for a discussion about smart network …
This article will show you step-by-step instructions to build your own NTP CentOS server.  The network diagram shows the best practice to setup the NTP server farm for redundancy.  This article also serves as your NTP server documentation.
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
Suggested Courses
Course of the Month14 days, 9 hours left to enroll

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question