[Solved] Redirect upcoming request on Google Cloud VM


Please confirm that you enabled port forwarding on both sides.

  • Here shows how to enable port forwarding on GCP
  • To enable it under the OS please run the followed commands as root:

# echo 1> / proc / sys / net / ipv4 / ip_forward

In order the forwarding bit remains active we will have to modify the file /etc/sysctl.conf and we will uncomment the line

# net.ipv4.ip_forward = 1

Uncomment the line and reload

sudo sysctl -p

Now you can run your commands

sudo iptables -t nat -A PREROUTING -p tcp --dport xx -j DNAT --to-destination XXX.XXX.XXX.XXX:xxxx

solved Redirect upcoming request on Google Cloud VM