How to connect to VM without external ip in Google Cloud platform

Forum / NoMachine for Windows / How to connect to VM without external ip in Google Cloud platform

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
  • #28281

    How can I connect to a VM without an external ip (ideally a Linux desktop)  in Google Cloud Platform? Ideally, I would like to use a bastion host in GCP. Obviously, I mean using NoMachine. Let’s say my home computer is a Windows 10.

    Thank you


    Yes, this example uses the external ip of the virtual machine. I was looking for a solution that does not rely on the external ip so that I can turn off the external ip on virtual machine.


    you must configure Bastion host  as an intermediate host between the home computer and the destination host (Linux host).

    I assume that the Linux desktop you want to connect to has disabled external IP connections. Bastion host and Linux desktop are in the same internal LAN.

    In the VPC network in Firewall:
    1) Add a rule allowing connections to port 4000 (you can set a different port) e.g. using „Targets tags”. If your Windows host has a fixed IP you can set the connection permission only for that IP.
    2) Add a rule that accepts connections from the local network to any port or only to port 4000 e.g. using „Targets tags”

    In Compute Engine:

    Assign this rule 1 to the  Bastion host, e.g. using „Targets tags”.
    Assign the rule 2 to a Linux host, e.g. with “Target tags”.

    Log in to the Bastion host and add rules to redirect traffic on port 4000 to Linux host using iptables

    Set traffic redirection from port 4000 to Linux host:

    sysctl net.ipv4.ip_forward=1

    iptables -t nat -A PREROUTING -p tcp –dport 4000 -j DNAT –to-destination x.x.x.x:4000

    iptables -t nat -A PREROUTING -p udp –dport 4000 -j DNAT –to-destination x.x.x.x:4000

    iptables -t nat -A POSTROUTING -j MASQUERADE

    Where x.x.x.x is the local Linux host IP.

    Now connecting to Bastion host on port 4000 using NXPlayer the connection will be transferred to your Linux host.


Viewing 4 posts - 1 through 4 (of 4 total)

This topic was marked as solved, you can't post.