Welcome to the most active Linux Forum on the web.
Go Back > Forums > Linux Forums > Linux - Networking
User Name
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.


  Search this Thread
Old 03-19-2008, 08:01 AM   #1
LQ Newbie
Registered: Nov 2007
Posts: 7

Rep: Reputation: 0
Forward all request on port 22

Hi Everyone,

In my iptables there aren't any rules defined. Now I want to forward all requests to port 22 on to port 22 on destination

This is the rule I use:

iptables -A FORWARD -p tcp --sport 22 --dport 22 -d -j ACCEPT

After inserting this rule and I try to connect to this server ( with putty on port 22. I'm getting the error message 'Connection refused'.

When I connect direct to on port 22 I can login to this computer. So my quess it a problem with the forwarding on, because the firewall of accepts all connections on port 22.

Even with the firewall off on it still doesn't work. What's wrong with my rule?

Thanks Arian

Last edited by Abstractt; 03-19-2008 at 08:03 AM.
Old 03-19-2008, 08:55 AM   #2
LQ Newbie
Registered: Oct 2007
Posts: 5

Rep: Reputation: 0
I'd suggest the sport is wrong here, I wouldn't specify it simply because it doesn't matter from which the connection comes as long as destination port is 22.
I just googled this description and I think you also need to do NAT:
Old 03-19-2008, 09:16 PM   #3
Registered: Jun 2004
Location: Sentado en mi trasero en Chile
Distribution: ArchLinux
Posts: 45

Rep: Reputation: 16
not not not no NO NONONONONO

You can not forward a request in the same net of the first recipient....

If you forward 10.0.0.A to 10.0.0.B and the request come from 10.0.0.C, the 10.0.0.B will response directly to 10.0.0.C and 10.0.0.C is waiting an answer from 10.0.0.A, so It get some strange things

I suggest you to use a alias to create a kind of fake tunnel between the A and B hosts. And/or NAT to MASQUERADE the requests.

Another thing the source port never is a lower port.

Last edited by CarLost; 03-19-2008 at 09:17 PM.


forward, iptables, port

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Apache: Forward request to another box? MasterC Linux - Networking 11 12-23-2014 09:37 PM
How2 let apache2 forward the request to another web-server on another machine boomy Linux - Software 9 12-04-2005 03:50 PM
Can forward port 80 but not others capbob Linux - Networking 4 05-20-2005 07:02 PM
A way to forward an IP/Port to another system's IP/Port astroboy5714 Linux - Networking 6 01-26-2004 05:45 PM
Forward port port 80 to lan web server dulaus Linux - Networking 9 10-04-2002 03:45 AM

All times are GMT -5. The time now is 01:10 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration