IAP TCP forwarding: the 35.235.240.0/20 firewall rule and IAM checklist
35.235.240.0/20 is the address range Identity-Aware Proxy connects
from for TCP forwarding; for VMs with IPv6, Google gives 2600:2d00:1:7::/64. Allow
ingress from it on tcp:22 for SSH, tcp:3389 for RDP and any other port
you tunnel, and grant the IAP-secured Tunnel User role. IAP then carries the connection to
Compute Engine VMs that have no external IP. A missing setting fails in ways that look alike,
so each one is listed below with its command and console path.
By Ostgate · Updated
The checklist
The examples use the project acme-prod, the VPC network default,
the VM example-vm and the account alice@example.com.
- A VPC firewall rule allows ingress from
35.235.240.0/20to each port you use. - The account holds
roles/iap.on the project or the instance.tunnelResourceAccessor - The account can list instances and log in:
roles/compute.viewer, plus an OS Login role or the right to write instance metadata for SSH. - The Compute Engine API is enabled, and the Cloud OS Login API if you use OS Login.
- The VM is running, and something listens on the port inside it.
- Your own network lets the client reach
tunnel.cloudproxy.appover HTTPS.
1. The firewall rule for 35.235.240.0/20
IAP does not connect from your Mac's address. It connects to the VM's internal address from
its own range, 35.235.240.0/20, so that is the range the VPC firewall must
admit. Without the rule, IAP accepts your request and then cannot reach the port.
In the Cloud Console: VPC network › Firewall › Create firewall rule. Choose the VM's
network, direction Ingress, action Allow, targets (all instances in the
network, or a target tag), source IPv4 range 35.235.240.0/20, and the TCP
ports. From the command line:
gcloud compute firewall-rules create allow-iap-ingress \
--project=acme-prod --network=default \
--direction=INGRESS --action=allow \
--rules=tcp:22,tcp:3389 \
--source-ranges=35.235.240.0/20
For VMs with IPv6 addresses, Google's IAP documentation gives the range
2600:2d00:1:7::/64. A VPC firewall rule holds either IPv4 or IPv6 ranges, never
both, so IPv6 takes a second rule:
gcloud compute firewall-rules create allow-iap-ingress-ipv6 \
--project=acme-prod --network=default \
--direction=INGRESS --action=allow \
--rules=tcp:22,tcp:3389 \
--source-ranges=2600:2d00:1:7::/64
The same rules in Terraform, with the Google provider's
google_compute_firewall resource:
resource "google_compute_firewall" "allow_iap" {
project = "acme-prod"
name = "allow-iap-ingress"
network = "default"
direction = "INGRESS"
source_ranges = ["35.235.240.0/20"]
allow {
protocol = "tcp"
ports = ["22", "3389"]
}
}
resource "google_compute_firewall" "allow_iap_ipv6" {
project = "acme-prod"
name = "allow-iap-ingress-ipv6"
network = "default"
direction = "INGRESS"
source_ranges = ["2600:2d00:1:7::/64"]
allow {
protocol = "tcp"
ports = ["22", "3389"]
}
}
To open the ports only on some VMs, add --target-tags=iap-ssh to the rule
(target_tags in Terraform) and the same network tag to those instances. To see
which rules already admit the range:
gcloud compute firewall-rules list --project=acme-prod \
--filter="sourceRanges:35.235.240.0/20"
Two things can still block traffic that this rule allows: a deny rule with a higher priority (a lower number) in the same network, and a firewall inside the guest, such as Windows Firewall on port 3389. On a Shared VPC, the rule belongs in the host project that owns the network.
2. IAM roles
IAP checks the permission iap.tunnelInstances.accessViaIAP before it opens any
tunnel. The predefined role that carries it is
roles/iap., shown in the console as
IAP-secured Tunnel User; Project Owner has it too. Grant it on the project:
gcloud projects add-iam-policy-binding acme-prod \
--member=user:alice@example.com \
--role=roles/iap.tunnelResourceAccessor
or, for single instances, in the console under Security › Identity-Aware Proxy on the SSH and TCP resources tab. The tunnel role only opens the pipe. Depending on what you do through it, the account also needs:
| To | Grant |
|---|---|
| List instances and read their status | roles/compute.viewer |
| SSH to VMs with OS Login | roles/compute.osLogin or roles/compute.osAdminLogin, and
roles/iam.serviceAccountUser on the VM's service account |
| SSH to VMs without OS Login, or set a Windows password | roles/compute.instanceAdmin.v1 |
3. Narrowing access with IAM conditions
A role binding can carry an IAM condition, so the tunnel role applies only while the condition holds. A time-limited grant for a contractor looks like this:
gcloud projects add-iam-policy-binding acme-prod \
--member=user:alice@example.com \
--role=roles/iap.tunnelResourceAccessor \
--condition='expression=request.time < timestamp("2026-12-31T00:00:00Z"),title=until-end-of-2026'
Google also documents condition attributes specific to IAP tunnels, such as the destination port, which lets you allow SSH but not RDP. Google evaluates conditions when the tunnel opens, so a client never needs to know about them. To grant the role on one VM only, as Azure Bastion users expect, see the per-VM grant.
4. APIs
- Compute Engine API: always. Clients use it to find the instance and its zone.
- Cloud OS Login API: when instances use OS Login, to publish your SSH key.
The tunnel endpoint itself is not one of the APIs you enable in APIs & Services.
If your organisation's setup guide also enables the Cloud Identity-Aware Proxy API
(iap.googleapis.com), leave it on; Ostgate's setup does not list it, and
Connection Doctor does not check it.
5. Ports: 22, 3389 and custom
IAP forwards any TCP port the firewall rule admits. The common ones:
- 22 for SSH and SFTP.
- 3389 for Remote Desktop to Windows VMs.
- Custom ports, such as 5432 for PostgreSQL or 8080 for an internal web app. Add each
to the rule, for example
--rules=tcp:22,tcp:3389,tcp:5432.
If sshd or RDP listens on a non-standard port, the rule must name that port. In Ostgate,
set SSH port or RDP port in Settings › Connections for the
instance, zone or project. IAP connects to the VM's first network interface,
nic0, by default.
6. Your own network
The client connects out to tunnel.cloudproxy.app over HTTPS (a secure
WebSocket), so a corporate proxy or egress filter must allow that host. Google evaluates
context-aware access levels based on identity or location as usual; Ostgate does not yet
support levels that require a device certificate.
If the project sits inside a VPC Service Controls perimeter, the perimeter's own rules may also decide whether API calls from your Mac are admitted. Ostgate does not diagnose perimeter denials, so check those with whoever manages the perimeter.
How Ostgate's Connection Doctor checks it
When an SSH, RDP or tunnel connection fails in Ostgate, click Diagnose. Connection Doctor works from the answer IAP gave and a live read of the instance. It does not inspect your firewall rules or IAM policy directly.
| Row | How it is decided |
|---|---|
| VM is running | Read live from the instance's status. |
| VM finished booting | Passes once the VM has been up for five minutes. Fails when IAP could not reach a VM that started moments ago. |
| IAP tunnel role granted | Fails when IAP refuses the tunnel as not authorized (relay code 4033). Passes when IAP authorized the tunnel but could not reach the port. |
| Port reachable from 35.235.240.0/20 | Fails when IAP could not connect to the VM port (relay code 4003): a missing firewall rule, a guest firewall, or nothing listening. |
Extra rows appear for SSH key publication to instance metadata, a changed host key, and
rejected Windows credentials. A row Ostgate has no evidence for stays
unknown. Under Fix, the Doctor gives one command to Copy for your
administrator: the tunnel role grant, the Compute Instance Admin grant, a firewall rule for
that port (written for the default network), or starting the VM. After the fix,
Retry after fix reconnects. For the messages themselves, see the
IAP tunnel errors guide.
FAQ
What is 35.235.240.0/20?
It is the address range Identity-Aware Proxy connects from when it forwards TCP to your
VMs. Google's IAP documentation says the range contains all IP addresses IAP uses for TCP
forwarding, and gives 2600:2d00:1:7::/64 for IPv6 VMs. A VPC firewall rule
must allow ingress from it to every port you reach through IAP, usually 22 for SSH and 3389
for RDP.
Is it safe to allow only this range?
Yes. It is the rule Google documents, and it is much narrower than 0.0.0.0/0:
the ports stay closed to other internet addresses, and IAP opens a tunnel only for accounts
that hold iap.tunnelInstances.accessViaIAP. Google also notes that the
default-allow-ssh and default-allow-rdp rules admit SSH and RDP
from all IP addresses, not only from IAP, so disable or delete them if IAP should be the
only way in.
Does 35.235.240.0/20 cover all regions?
Yes. Google documents one range for IAP TCP forwarding, not one per region, and VPC firewall rules are global resources of the network. One rule covers the network's VMs in every region and zone. On a Shared VPC, create it in the host project.
What is the Terraform rule for IAP?
A google_compute_firewall resource with direction = "INGRESS",
source_ranges = ["35.235.240.0/20"] and an allow block for
protocol tcp on ports 22 and 3389. A rule holds IPv4 or IPv6 ranges but not
both, so IPv6 VMs need a second resource with 2600:2d00:1:7::/64. Both blocks are in
the firewall rule section above.
What is the IAP-secured Tunnel User role?
The console name of roles/iap.. It carries
iap.tunnelInstances.accessViaIAP, the permission IAP checks before it opens a
tunnel. Project Owner also has it.
Does IAP TCP forwarding work for RDP and databases?
Yes. IAP forwards any TCP port the firewall rule admits: 22 for SSH, 3389 for RDP, and custom ports such as 5432 for PostgreSQL.
To set up SSH next, see SSH to a GCE VM without a public IP from a Mac.
Connect once the checklist is green. Ostgate opens SSH, RDP and tunnels through IAP from your Mac, with no gcloud to install. 7-day free trial, no sign-up.