Routing traffic using IPtables
by hyperion10 from LinuxQuestions.org on (#5NDYA)
I'm having trouble routing traffic using IPtables.
I have a server that I intend to use as a router (r1) so it can redirect all incmoing udp traffic on port 7775 to server a(10.1.0.5) or b(10.1.0.6) on the same port depending on source address.
for example if the source is 192.168.0.5 -> R1 -> a
if the source is 192.168.0.10 -> R1 -> b
i've tried the following :-
sysctl -w net.ipv4.ip_forward=1
iptables -t nat -A PREROUTING -p udp -s 192.168.0.5 --dport 7775 -j DNAT --to 10.1.0.5:7775
iptables -t nat -A PREROUTING -p udp -s 192.168.0.10 --dport 7775 -j DNAT --to 10.1.0.6:7775
but no luck


I have a server that I intend to use as a router (r1) so it can redirect all incmoing udp traffic on port 7775 to server a(10.1.0.5) or b(10.1.0.6) on the same port depending on source address.
for example if the source is 192.168.0.5 -> R1 -> a
if the source is 192.168.0.10 -> R1 -> b
i've tried the following :-
sysctl -w net.ipv4.ip_forward=1
iptables -t nat -A PREROUTING -p udp -s 192.168.0.5 --dport 7775 -j DNAT --to 10.1.0.5:7775
iptables -t nat -A PREROUTING -p udp -s 192.168.0.10 --dport 7775 -j DNAT --to 10.1.0.6:7775
but no luck