I want to redirect all ports from VPN server to one of VPN client (except the SSH-5656 port and OpenVPN port-5757).

I know this command:

iptables -A FORWARD --proto tcp -p 1-5655 -j DSTNAT -d 10.8.0.x

But I don´t know, how to redirect more ports with one command.

For example: I want to redirect ports from 1-5655 to client (TCP + UDP) and then I want to redirect 5657-5756 & 5758-65535 (both protocols) to the same OpenVPN client.

Can you please help me with that?

Thanks :)


There is the parameter multiport

-m multiport --dports 1:5655,5758:65535 -j DSTNAT

Edit: with "-m multiport" specifies a match to use. In our case the module "multiport", after that is necessary to specify the destination (--dport) or source (--sport) port range with the syntax "from_port:to_port". You can add additional port range by separating it with a comma, for ex. (1:5655,5758:65535).

Note: "multiport" can only be used by specifying the protocol with -p tcp or -p udp

  • 2
    Can you please extend your answer, add some explanations... – Romeo Ninov May 24 '17 at 13:18
  • 1
    @RomeoNinov I have added an explaination! I hope it's more clear :) – DarkVex May 25 '17 at 17:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.