I have an ubuntu machine at IP 192.168.3.1, another machine is connected to it at fixed IP of 192.168.3.2, This machine is also connected to a router over usb0 which has shared the IP 172.30.220.17 to the machine
What I wanna do is to forward any TCP or UDP packet received by this machine over the 192.168.3.1 IP towards 172.30.220.19 from the router, and vice versa
For example if the machine at 192.168.3.2 sends a "Hello" TCP packet on port 33000 towards the main computer, it should send the packet to 172.30.220.19:33000
After reading the iptables documentation and a few former questions I tried the commands below for NAT but it doesn't work, I don't know why. I would be glad if anyone could direct me as to what I've done wrong. Thanks for your time
sudo iptables -t nat -A PREROUTING -p tcp -j DNAT --to-destination 172.30.220.19
sudo iptables -t nat -A POSTROUTING -p tcp -d 172.30.220.19 -j SNAT --to-source 192.168.3.2