Linux - NetworkingThis forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
I want to have a service listening in port X and it will simply forward traffic to a service in port Y (can't use iptables' REDIRECT, which is the simplest solution).
I assume from your post you mean X and Y are on the same machine ? If so I think this will suffice:
ssh localhost -g -L x:127.0.0.1:y
The -g allows remote hosts to connect to local tunneles ports (i.e., allow non-localhost computers to make use of the forward).
If the two ports aren't local, just change the line above appropriately.
Now I have to ask the obvious question: if you're chaning a service port locally, why not just edit the service's config file, or make a change in xinetd if the service supports it? That way you won't have the added overhead of the encryption...
Oh, well.... because the service will actually listen in it's natural port.. plus this other port(s).
Let me explain myself a little better:
We have (will have, should I say) three internet connections attached to a single host. This host will provide openVPN connection.
The problem is that as the box will have three internet connections to get to a given host, to avoid choosing the wrong path, I will use a different port for each network interface (plus the normal not tunneled openVPN port). According to the port the packet came in, I pass traffic back thru the network interface the request traffic came from.
Because I need to be able to differ traffic acording to the source port when the response traffic is going out... and If I do REDIRECT, the source port by the time the response hits POSTROUTING is the actual port the traffic was redirected TO, and not the APPARENT port.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.