I need to redirect incoming UDP traffic to two services listening different UDP ports on localhost. I tried:
iptables -t nat -I PREROUTING -p udp -d 10.11.12.13 --dport 22 -j DNAT --to-destination 127.0.0.1:1234 --to-destination 127.0.0.1:4321
But the error was:
iptables v1.6.0: DNAT: Multiple --to-destination not supported
The same thing with
iptables v1.6.0: REDIRECT: option "--to-ports" can only be used once
Then I tried iptables
TEE. But in
--gateway option it implies just IP address, so I can't do even like:
iptables -t mangle -I PREROUTING -p udp -d 10.11.12.13 --dport 22 -j TEE --gw 127.0.0.1:1234
Is there a way to "duplicate" UDP traffic using iptables or in some other handy way in Linux?
P.S. The question is about one-direction UDP traffic (e.g. incoming syslog traffic). It's obviously that it has nothing to do with TCP in such
scamscheme, because TCP has connection and it's impossible to establish connection from one port to two another ports. But it seems that it can be done with UDP (because there is no need to establish a connection).