I'm using latest debian relese and i need to do some port forwarding, but i dont know how.I have 2 stream sources coming to my server on the same udp port from 2 diferent ip-s via udp to (server) via udp to (server)

My qestion is: how to forward this port 1003 coming from 1.2 to some other port 1004 for example?

  • similar, but I can't find my answer in that topic. With this rule i can block that port coming from 1.2 but i dont know how to forward..iptables -A INPUT -s -i eth0 -p udp -m state --state NEW -m udp --dport 1003 -j DROP – user287842 May 7 '15 at 20:39
  • 1
    You could later re-ask this question by reformulating so that you exactly explain what is your UDP-specific specific problem. – peterh - Reinstate Monica May 8 '15 at 4:24

You need to use the PREROUTING chain to forward port :

iptables -t nat -A PREROUTING -p udp -i eth0 -d --dport 1003 -j DNAT --to-destination

By the way, it seems filter is happening directly on the target host, so you could use REDIRECT in that case :

iptables -t nat -A PREROUTING -i eth0 -d -p udp --dport 1003 -j REDIRECT --to-ports 1004

In both case, don't forget to allow traffic on port UDP/1004 after NAT (assuming UDP/1003 is already allowed) :

iptables -A FORWARD -i eth0 -p udp -d --dport 1004 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
| improve this answer | |

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