Question 17

How to config firewall rule to allow RDP (3389/TCP) access from the Internet using gcloud command?


To configure a firewall rule in Google Cloud to allow Remote Desktop Protocol (RDP) access (TCP port 3389) from the Internet, you can use the gcloud command-line tool. Here’s how you can do it:

  1. Open your terminal where you have the gcloud SDK installed and authenticated.

  2. Run the following command to create a firewall rule that allows RDP access:

    gcloud compute firewall-rules create allow-rdp \
        --direction=INGRESS \
        --priority=1000 \
        --network=default \
        --action=ALLOW \
        --rules=tcp:3389 \
        --source-ranges=0.0.0.0/0 \
        --target-tags=rdp-access

    Here’s a breakdown of the command:

    • allow-rdp: This is the name of the firewall rule. You can choose any name you prefer.
    • --direction=INGRESS: This specifies that the rule applies to incoming traffic.
    • --priority=1000: This sets the priority of the rule. Lower numbers indicate higher priority.
    • --network=default: This specifies the network where the rule will be applied. Change it if you are using a different network.
    • --action=ALLOW: This allows the traffic that matches the rule.
    • --rules=tcp:3389: This specifies that the rule applies to TCP traffic on port 3389.
    • --source-ranges=0.0.0.0/0: This allows traffic from any IP address. Be cautious with this setting as it exposes your RDP port to the entire Internet.
    • --target-tags=rdp-access: This specifies the target instances that the rule will apply to. You need to add this tag to your VM instances that you want to allow RDP access.
  3. Add the target tag to your VM instance (if you haven't done so already). You can do this with the following command:

    gcloud compute instances add-tags INSTANCE_NAME --tags=rdp-access

    Replace INSTANCE_NAME with the name of your VM instance.

  4. Verify the firewall rule by listing the existing rules:

    gcloud compute firewall-rules list

This will create a firewall rule that allows RDP access from any IP address to the specified instances. Make sure to consider security implications and restrict access to specific IP ranges if possible.

This page was last edited on 2025-03-01 15:52

Powered by Wiki|Docs

This page was last edited on 2025-03-01 15:52

Mac
To whom it may concern

Powered by Wiki|Docs