I need to change the outgoing port number of all UDP packets originating from a local process. For example:
local machine udp dest:192.168.10.1/255.255.255.0 port 2222
should become (before leaving the local machine):
udp dest:192.168.10.1/255.255.255.0 port 3333
What I tried is this iptables rule:
iptables -t nat -A OUTPUT -d 192.168.10.1/255.255.255.0 -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?