Enforce IAP TCP Forwarding for SSH Access to Private VMs
A company uses Identity-Aware Proxy (IAP) to secure access to a group of Compute Engine instances running a web application. The instances have no external IP addresses and are accessed via IAP TCP forwarding. Recently, the security team discovered that some users can access the instances directly via SSH from other instances within the same VPC, bypassing IAP. What is the most effective way to ensure all SSH access goes through IAP?
Quick Answer
The answer is to modify the VPC firewall rule to deny ingress traffic on TCP port 22 from all sources except the IAP IP range (35.235.240.0/20). This is correct because IAP TCP forwarding relies on this specific source range to proxy SSH connections, and without a firewall rule explicitly restricting port 22 to only that range, any internal VM in the same VPC can bypass IAP and connect directly via SSH. On the Google Professional Cloud Network Engineer exam, this scenario tests your understanding that IAP does not inherently block internal VPC traffic—you must enforce the restriction at the firewall level. A common trap is assuming IAP alone secures all access, but the key is that IAP acts as a tunnel, not a firewall. Remember the memory tip: “IAP’s IP is the only key to port 22’s door.”
⚠ Common exam trap
Google Cloud often tests the misconception that IAP alone enforces access control, when in reality it relies on VPC firewall rules to restrict traffic to only the IAP source IP range; candidates may incorrectly choose options that change authentication (OS Login) or authorization (service account roles) instead of addressing the network path.
Answer choices
Why each option matters
Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.
Correct answer & explanation
✓
Modify the VPC firewall rule to deny ingress traffic on TCP port 22 from all sources except the IAP IP range (35.235.240.0/20).
The IAP TCP forwarding source IP range (35.235.240.0/20) is the only range that should be allowed to initiate SSH connections to the instances. By modifying the VPC firewall rule to deny all other sources on TCP port 22, you ensure that any SSH traffic not originating from the IAP IP range is blocked, even from other instances within the same VPC. This directly addresses the bypass scenario where users SSH from other internal instances.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✓
Modify the VPC firewall rule to deny ingress traffic on TCP port 22 from all sources except the IAP IP range (35.235.240.0/20).
Why this is correct
This ensures only IAP can initiate SSH connections.
- ✗
Assign a service account to each instance with the IAP-secured Tunnel User role.
Why it's wrong here
The IAP-secured Tunnel User role is granted to users, not instances.
- ✗
Remove SSH keys from the instances and use OS Login.
Why it's wrong here
OS Login still allows SSH access from within the VPC if firewall rules permit.
- ✗
Create a new firewall rule that allows SSH only from the IAP IP range and delete the existing SSH rule.
Why it's wrong here
Deleting the existing rule is not necessary; modifying it or adding a higher-priority deny rule is sufficient.
Visual reference
Go deeper
Related to this question
About these practice questions
This PCNE question is part of Courseiva's 961-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam dumps. Learn why practice questions differ from exam dumps →
Same concept, more angles
2 more ways this is tested on PCNE
These questions test the same concept from different angles. Work through them to make sure you can recognise it however the exam phrases it.
Variation 1. A security engineer wants to allow SSH access to a VM that has no external IP. The VM is in a VPC with IAP configured. What is the simplest way to enable secure SSH without a bastion host?
easy- ✓ A.Use Identity-Aware Proxy (IAP) TCP forwarding with the gcloud compute start-iap-tunnel command.
- B.Create a VPN tunnel to the VPC and SSH over the VPN.
- C.Configure a SOCKS proxy on a bastion host.
- D.Assign an external IP to the VM and use a firewall rule to restrict access.
Why A: Identity-Aware Proxy (IAP) TCP forwarding allows secure SSH access to a VM without an external IP by tunneling traffic through the IAP service. The `gcloud compute start-iap-tunnel` command establishes an encrypted tunnel from your local machine to the VM via the IAP proxy, using the VM's internal IP and port 22. This eliminates the need for a bastion host or public IP while leveraging IAP's identity-based access controls.
Variation 2. A company uses Identity-Aware Proxy (IAP) to secure access to Compute Engine VMs. Users report that they can SSH into some VMs but not others, even though they have the IAP-secured Tunnel User role. Both VMs are in the same project and have the same network tags. What is the most likely reason?
medium- ✓ A.Firewall rules allow ingress from IAP's IP ranges only for some VMs.
- B.The VMs are in different zones with different DNS resolution.
- C.The VMs that can be accessed have external IP addresses; the others only have internal IP addresses.
- D.The VMs do not have OS Login enabled.
Why A: IAP TCP forwarding relies on firewall rules that allow ingress from the IAP proxy's IP ranges (35.235.240.0/20) to the VM. If these rules are applied inconsistently across VMs (e.g., missing on some subnets or instances), users will be unable to SSH into those VMs. The fact that both VMs share the same network tags does not guarantee identical firewall configurations if rules are applied based on other criteria like target tags or service accounts. Options B and D are incorrect as DNS resolution and OS Login are not prerequisites for IAP TCP forwarding. Option C is wrong because IAP TCP forwarding works with internal IPs; external IPs are not required.
JA
Written by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
This PCNE practice question is part of Courseiva's free Google Cloud certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the PCNE exam.