0

I got 2 servers Named A and B, both are in different data centers and just have internet access. I need the incoming UDP connections to a particular port on server A to be forwarded to a specific port on server B. ssh tunneling is just for TCP. I could not get udp2raw working. any idea? thanks in advance.

xtg
  • 1
  • 1

1 Answers1

1
iptables -t nat -A PREROUTING -p UDP -i eth0 -d 192.0.2.1 --dport 9999 -j DNAT --to-destination 192.0.2.2:8888

eventually add this if your FROWARD policy is not ACCEPTing all

iptables -A FORWARD -p UDP -d 192.0.2.1 --dport 9999 -j ACCEPT
exeral
  • 1,787
  • 11
  • 21
  • I got confused a bit, Imagine I'm going to forward incoming UDP connections on port 10 in Host B with address B.B.B.B to UDP port 20 on host A with address A.A.A.A Can you edit the command with these parameters? then I can replace parameters – xtg Jun 27 '23 at 11:11
  • Don't I need a process to listen the specific port on forwarding host? – xtg Jun 27 '23 at 11:13
  • your statement "forward incoming UDP connections on port 10 in Host B with address B.B.B.B to UDP port 20 on host A" is the opposite of your original question: "incoming UDP connections to a particular port on server A to be forwarded to a specific port on server B" that's not clear. No, you don't need a listening process. iptables (linux kernel) intercept the packet before – exeral Jun 27 '23 at 13:10
  • I just replaced A with B, imagine the second statement, now how parameters should be replaced? – xtg Jun 27 '23 at 16:37