Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I've set up a port triggering rule to listen for activity on port 5016 (arbitrary choice) and forward port 80 to port 80. As far as I'm aware, this has been set up correctly.

How can I activate the trigger with a terminal command? Do I really have to connect to something on that port? I feel like there must be a simpler method.

Everything I've read either glosses over this aspect of port forwarding, or suggests you use an IRC client and the associated ports to trigger the forward. It seems very silly to have to use an IRC client to do this though.

share|improve this question

1 Answer 1

If you just need some activity to start the forward, you can simply "telnet <hostname> 5106" - that should have enough activity to trigger the rule. If you need the forwarding in place even without activity, you're better off using iptables or it's equivalent to set up the forwarding without the need for activity on 5106.

EDIT: Assuming your router is running a Red Hat based linux and you have a root terminal on it, you can do the following:

  1. edit /etc/sysctl.conf and change the line that says "net.ipv4.ip_forward = 0" to "net.ipv4.ip_forward = 1"
  2. run "sysctl -p" to activate that change
  3. To forward port 80 to ${otherhost} (port80), run the following commands:

    /sbin/iptables -t nat -A PREROUTING -p tcp -i eth0 -d ${localhost ip} --dport 80 -j DNAT --to ${otherhost}:80

    /sbin/iptables -A FORWARD -p tcp -i eth0 -d 192.168.0.2 --dport 80 -j ACCEPT

  4. run "service iptables save" to make the forwarding persist across reboots

share|improve this answer
    
no luck! user~$ telnet 5016 Trying 0.0.19.152... telnet: Unable to connect to remote host: Invalid argument –  nona urbiz Feb 21 '11 at 20:12
    
missing the host: telnet hostnameOrIP 5106 –  shellholic Feb 21 '11 at 20:18
    
I guess I didn't make my question clear enough. I don't want to have to actually telnet a server just to forward my port... it seems silly to have to communicate with a server just so that I can tell my router on 10.0.0.1 to do something. –  nona urbiz Feb 21 '11 at 21:40
    
Edited to make the hostname portion visible - I keep forgetting HTML does strange things with bare angle brackets. –  John Feb 22 '11 at 19:27

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.