Take the tour ×  I need to change the outgoing port number of
all UDP packets originating from a local process. For example:
local machine udp dest: port 2222  should become (before leaving
the local machine):  udp dest: port 3333  What I tried is this
iptables rule:  iptables -t nat -A OUTPUT -d -p udp --dport 2222
-j DNAT  --to-destination :3333  However it changes also the
destination IP address. From another question in serverfault I
saw that according to netfilter documentation (
http://www.netfilter.org/documentation/HOWTO/NAT-HOWTO.txt,
section 6.3.7) iptables can't do this.  My question is how can I
accomplish this task in Linux? Maybe there is another tool which
can do the job?  share|improve this question I would suggest
just doing it in the process. You can LD_PRELOAD an interceptor
library that hooks bind, recvmsg, and getsockname. –  David
Schwartz Dec 6 '12 at 18:16 add comment  2 Answers  up vote 1
down vote accepted  I can't think of any tool that would do that
out of the box. This is quite r