0

i have an issue with my network setting and i need a port forwarding a bit advanced.

I need : - All packets that arrive on my public_ip on port 54321 to be forward on port 12345 but i don't want any translation when it come from localhost.

Thanks

2
  • add a "! -i lo" ? From the man : [!] -i, --in-interface name Name of an interface via which a packet was received (only for packets entering the INPUT, FORWARD and PREROUTING chains). When the "!" argument is used before the interface name, the sense is inverted. If the interface name ends in a "+", then any interface which begins with this name will match. If this option is omitted, any interface name will match.
    – Dom
    Jan 16, 2015 at 18:35
  • Post what you tried. Jan 16, 2015 at 21:25

1 Answer 1

0

Try using REDIRECT of iptables.

    iptables -t nat -I PREROUTING -d <public ip> -p tcp --dport 54321 -j REDIRECT --to-port 12345

If you need udp, just change the protocol.

You must log in to answer this question.

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