1

I have a Centos 6 64 bit server with OpenVPN installed.

I'm using this iptables rule to forward a port for an OpenVPN user:

iptables -t nat -A PREROUTING -p tcp -m tcp --dport PORT -j DNAT --to-destination 10.8.1.X:PORT

This works perfect but if I forward the same port for another user. The port will not work for both. How can I forward the same port to 2 different users?

I know I can put the user on a different subnet with a different external IP and forward the traffic on a port on that IP to the client and have the same port open for 2 users like that but that's not what I want to do. I want the users to be on the same subnet.

Thanks in advance!

1 Answer 1

1

You need to put a match on the destination IP using -d IP.

iptables -t nat -A PREROUTING -p tcp -m tcp -d 9.8.7.X --dport PORT -j DNAT --to-destination 10.8.1.X:PORT

Considering that 9.8.7.X is your external IP getting the traffic and 10.8.1.X is your internal IP that needs redirecting to.

2
  • Could you give an example? I already use this: "--to-destination 10.8.1.X:PORT" in my iptables rule.
    – Niel
    Aug 26, 2014 at 18:04
  • There we go. I hope it helps. Also, you should read more about IPTABLES :) Aug 26, 2014 at 18:50

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .