Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a Linux VPS (virtuozzo) server and I need to setup port forwarding, but my hosting provider does not allow iptables-nat kernel modules so iptables -t nat - is not working.

I'm looking for other ways how to do it. I know I can forward port using openssh, but I need to forward 20+ different ports, tcp and udp so this is not an option.

Is there is any software for linux that can do port forwarding?

share|improve this question
huh good question +1. i am not aware of a solution, looking forward to see whether tehre is something here. – The Shurrican Mar 26 '11 at 13:14
And then, what about a program that lets you forward ports to different destinations based on the source IP? – dpk May 10 '11 at 16:16
Avoid the problem entirely by never using Virtuozzo/OpenVZ based VPSes. – Michael Hampton Feb 9 '13 at 19:41
@MichaelHampton: Not extremely constructive... – Nicolas Raoul Sep 11 '14 at 8:26

Use the tool called "socat", it is great tool for such things and it is already packaged in many linux distribution. Read about it here :

Port forwarding example with socat :

socat TCP4-LISTEN:80,fork

This redirect all TCP connections on port 80 to port 8080 TCP.

share|improve this answer
Don't forget https is default on port 443, instead of port 80 :) – keiki Sep 30 '13 at 10:20
Socat is the only tool that worked for me on a ipv6-only raspberry pi – chotchki Nov 7 '13 at 3:09
Perfect, solved my problem instantly. Note, you need to make sure that the incoming port is open in iptables if you have such. – jancha Mar 23 '15 at 17:18

What about rinetd ?
Its a daemon that redirects TCP connections. Have a look at the man page to see if it suits your needs:

share|improve this answer
Looks interesting, but it is limited to TCP only as you said. – troex Mar 26 '11 at 13:28

xinetd supports a redirect attribute which will do what you want. As others have noted there are a number of programs which handle redirects.

Using xinetd or other program which uses the tcpwrappers library will allow you to apply access restrictions if and when it becomes necessary.

share|improve this answer

There's a tiny, light resources program called redir which is pretty configurable.

apt-get install redir on Debian-based distributions.

share|improve this answer
up vote 3 down vote accepted

I found small util called portfwd it does exactly what I need (TCP and UDP forwarding), homepage says it was last updated in 2002, but latest release is 2007, and it works on 2.6 kernel.

share|improve this answer
I'll accept my answer as it seams this is the only software which fully supports both TCP and UDP protocols. – troex Apr 3 '11 at 14:41

xinet/inetd. For e. g.:


Allows a tcp service to be redirected to another host. When xinetd receives a tcp connection on this port it spawns a process that establishes a connection to the host and port number specified, and forwards all data between the two hosts.

share|improve this answer
Looks interesting, but it is limited to TCP only as you said – Doud Sep 7 '12 at 16:16

SSH Does port forwarding, so long as you can tunnel in an SSL connection.

share|improve this answer

Ok here is the simple answer that should work, it's not rocket science but most people over complicate the answer and confuse all the new to Linux users.

ufw allow 2xxx

2xxx = what ever your port number is just type that command into your server terminal and your desired port is opened up.

share|improve this answer

Your Answer


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.