Link to home
Start Free TrialLog in
Avatar of xoundboy
xoundboy

asked on

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

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
Avatar of ai_ja_nai
ai_ja_nai
Flag of Italy image

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
Then, of course, you have to transmit your packets to port 9999 of your server ;)
Avatar of xoundboy
xoundboy

ASKER

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.


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
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]

if you tunnel the magic packet from port 22 on the source to 9 on the target it should work.. shouldn't?
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
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
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?
hi, the link i sent if read its saying how to change listning port.
>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
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
@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.
you can tunnel to the router which your sleeping system is attached to and from there you can send the magic packet
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.
you should replace the normal firmware with the linux stack, they really rock
ASKER CERTIFIED SOLUTION
Avatar of xoundboy
xoundboy

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
That'snot true, I proposed one on comment #23661420 (tunnel through the router)
OK, so maybe would care to explain exactly what you mean by "tunnel through the router" given that my router is a wrt54gc.
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
>> 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.
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?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
if you take a closer look at 'that page' you will see that what you are suggesting is impossible
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)
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.

Dunno what to say. Are you sure you can't install a more advanced firmware?
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 :)


Thanks Vee_Mod for your advice - I as wondering how to handle this - you read my mind.