Networking Interview Questions for Cloud Engineers, Proved in Labs
What you build: 10 cloud networking interview answers, each proved on Google Cloud: CIDR, Cloud NAT, firewall priority, DNS, TLS and routes. Every step tested.

✍️ Translate this blog into Hindi, Tamil or Telugu
Cloud interviews always include networking: private and public IPs, CIDR, NAT, firewalls, DNS, routes, HTTP and TLS. Reciting definitions is easy; showing that you have seen them work is what stands out. In this post, every one of 10 classic questions is answered and then proved with a real command on Google Cloud, with the real output.
Who it is for: anyone preparing for cloud, DevOps or SRE interviews. Time: about 1 hour to run everything. Cost: two tiny VMs and a Cloud NAT for about 15 minutes, covered by the free trial credit.
Every command below was run for real by the CareerByteCode Team, and every output is the real result we got. The gcloud commands ran on a Cloud Shell-like Linux machine; the commands marked "on netlab-vm" ran on a test VM over SSH through IAP.
The lab behind the answers
Two small VMs with no public IP in the default network: netlab-vm, where we run the tests, and web-vm, which serves a tiny web page on port 8080 (Python's built-in web server, run as a systemd unit). netlab-vm runs as a service account that may only read Compute Engine settings (compute-ro).

# The lab: two small VMs with NO public IP in the default network. web-vm runs a tiny web server on port 8080
gcloud compute instances create netlab-vm --zone=us-east1-b --machine-type=e2-micro --no-address --service-account=lab-shell@$PROJECT_ID.iam.gserviceaccount.com --scopes=compute-ro --image-family=debian-12 --image-project=debian-cloud > /dev/null 2>&1
gcloud compute instances create web-vm --zone=us-east1-b --machine-type=e2-micro --no-address --tags=web --image-family=debian-12 --image-project=debian-cloud --metadata=startup-script='mkdir -p /srv && echo hello > /srv/index.html && systemd-run --unit=web python3 -m http.server 8080 --directory /srv' > /dev/null 2>&1
gcloud compute instances list --filter="name~^(netlab|web)-vm" --format="table(name,networkInterfaces[0].networkIP,networkInterfaces[0].accessConfigs[0].natIP:label=PUBLIC_IP)"
until gcloud compute ssh netlab-vm --zone=us-east1-b --tunnel-through-iap --command="true" > /dev/null 2>&1; do sleep 10; done; echo "SSH through IAP works"SSH through IAP worksQ1. What IP addresses does a cloud VM have, and what is the MTU?
Answer: every VM has a private IP from its subnet. A public IP is optional; without one, the internet cannot reach the VM directly. The MTU (largest packet size) on Google Cloud VPCs is 1460 bytes by default, not the 1500 you see at home, which matters for VPNs and tunnels.
Proof (on netlab-vm):
# Q1. Private IP, public IP and MTU: what does the VM itself see?
ip -4 -brief addr show ens4
ip link show ens4 | grep -oE "mtu [0-9]+"
echo "public IP from the metadata server: '$(curl -s -H 'Metadata-Flavor: Google' http://metadata.google.internal/computeMetadata/v1/instance/network-interfaces/0/access-configs/0/external-ip)'"ens4 UP 10.142.0.31/32 metric 100
mtu 1460
public IP from the metadata server: ''A private IP, MTU 1460, and an empty answer from the metadata server for the public IP: there is none.
Q2. How many addresses are in a subnet?
Answer: a /N range has 2^(32-N) addresses: a /24 has 256, a /20 has 4,096. Google Cloud reserves 4 in every subnet (network, gateway, second-to-last and broadcast), so you can use the rest.
Proof (on netlab-vm, with Python's ipaddress module):
# Q2. CIDR math: how many addresses does this subnet have, and how many can VMs use?
R=$(gcloud compute networks subnets describe default --region=us-east1 --format="value(ipCidrRange)"); echo "subnet default in us-east1: $R"
python3 -c "import ipaddress, sys; n = ipaddress.ip_network(sys.argv[1]); print(f'{n.num_addresses} addresses, {n.num_addresses - 4} usable on Google Cloud (4 reserved), first {n[0]}, gateway {n[1]}, last {n[-1]}')" $R
python3 -c "import ipaddress; print('a /24 has', ipaddress.ip_network('10.0.0.0/24').num_addresses, 'addresses; a /28 has', ipaddress.ip_network('10.0.0.0/28').num_addresses)"subnet default in us-east1: 10.142.0.0/20
4096 addresses, 4092 usable on Google Cloud (4 reserved), first 10.142.0.0, gateway 10.142.0.1, last 10.142.15.255
a /24 has 256 addresses; a /28 has 16
Q3. My VM has no public IP and cannot download updates. Why, and how do I fix it?
Answer: without a public IP and without NAT, a VM has no way out to the internet. Cloud NAT gives private VMs a shared way out, while still nothing can connect in.
Break it (on netlab-vm):
# Q3. Break it: a VM without a public IP tries to reach the internet (for example apt-get)
curl -sS -m 10 -o /dev/null -w "HTTP %{http_code}\n" https://deb.debian.org/ 2>&1 | cut -c1-120curl: (28) Connection timed out after 10000 milliseconds
HTTP 000Fix it: a Cloud Router plus Cloud NAT for the region:
# Q3. Fix it: Cloud NAT gives private VMs a way OUT to the internet, while nothing can come IN
gcloud compute routers create netlab-router --network=default --region=us-east1 > /dev/null
gcloud compute routers nats create netlab-nat --router=netlab-router --region=us-east1 --auto-allocate-nat-external-ips --nat-all-subnet-ip-ranges > /dev/null
gcloud compute routers nats list --router=netlab-router --region=us-east1 --format="table(name,natIpAllocateOption,sourceSubnetworkIpRangesToNat)"; sleep 60Creating router [netlab-router]...
........done.
Creating NAT [netlab-nat] in router [netlab-router]...
..........done.
NAME NAT_IP_ALLOCATE_OPTION SOURCE_SUBNETWORK_IP_RANGES_TO_NAT
netlab-nat AUTO_ONLY ALL_SUBNETWORKS_ALL_IP_RANGESThe same request now works, and we install the tools we need for the next questions (on netlab-vm):
# Q3. The same request now works through Cloud NAT, and we can install the tools we need
curl -sS -o /dev/null -w "HTTP %{http_code}\n" https://deb.debian.org/
sudo apt-get update -qq > /dev/null 2>&1 && sudo apt-get install -y -qq dnsutils traceroute > /dev/null 2>&1 && echo "dnsutils and traceroute installed"HTTP 200
dnsutils and traceroute installed
Q4. What happens when you open a URL?
Answer: DNS turns the name into an address, a TCP connection is opened, a TLS handshake sets up encryption, the HTTP request is sent and the first byte comes back. curl can time each stage.
Proof (on netlab-vm):
# Q4. What happens when you open a URL? DNS lookup, TCP connect, TLS handshake, first byte: curl measures each
dig +noall +answer www.google.com A | head -1 | awk '{print "DNS: " $1 " -> an address, ttl " $2 " s"}'
curl -s -o /dev/null -w "dns %{time_namelookup}s | tcp connect %{time_connect}s | tls done %{time_appconnect}s | first byte %{time_starttransfer}s | total %{time_total}s\n" https://www.google.com/DNS: www.google.com. -> an address, ttl 300 s
dns 0.005123s | tcp connect 0.007062s | tls done 0.065698s | first byte 0.107084s | total 0.107850sDNS took 5 ms, the TCP connection was ready at 7 ms, TLS took most of the time (ready at 66 ms), and the first byte arrived at 107 ms.
Q5. How do firewall rules and priority work?
Answer: Google Cloud firewall rules are checked by priority: the lowest number wins. Ingress is denied by default unless a rule allows it. Rules can target VMs by network tag.
Proof (on netlab-vm): port 8080 on web-vm works, and the rules show why (default-allow-internal allows all internal traffic):
# Q5. Ports and firewalls: is port 8080 open on web-vm, and who allows it?
WEB=$(gcloud compute instances describe web-vm --zone=us-east1-b --format="value(networkInterfaces[0].networkIP)")
curl -s -m 5 -o /dev/null -w "netlab-vm -> web-vm:8080 HTTP %{http_code}\n" http://$WEB:8080/
gcloud compute firewall-rules list --filter="network=default AND direction=INGRESS" --format="table(name,priority,sourceRanges.list(),allowed[].map().firewall_rule().list())"netlab-vm -> web-vm:8080 HTTP 200
NAME PRIORITY SOURCE_RANGES ALLOW
default-allow-icmp 65534 0.0.0.0/0 icmp
default-allow-internal 65534 10.128.0.0/9 tcp:0-65535,udp:0-65535,icmp
default-allow-rdp 65534 0.0.0.0/0 tcp:3389
default-allow-ssh 65534 0.0.0.0/0 tcp:22
lab-ssh-from-iap 1000 35.235.240.0/20 tcp:22Break it: a DENY rule for port 8080 at priority 900, aimed at VMs tagged web:
# Q5. Break it: a DENY rule with a higher priority (lower number) for port 8080 on VMs tagged "web"
gcloud compute firewall-rules create netlab-deny-8080 --network=default --direction=INGRESS --action=DENY --rules=tcp:8080 --target-tags=web --source-ranges=10.0.0.0/8 --priority=900 2>&1 | tail -1; sleep 20netlab-deny-8080 default INGRESS 900 tcp:8080 False# Q5. The same test from netlab-vm after the deny rule
WEB=$(gcloud compute instances describe web-vm --zone=us-east1-b --format="value(networkInterfaces[0].networkIP)")
curl -s -m 5 -o /dev/null -w "netlab-vm -> web-vm:8080 HTTP %{http_code}\n" http://$WEB:8080/; echo "(000 = no answer: the packet was dropped)"netlab-vm -> web-vm:8080 HTTP 000
(000 = no answer: the packet was dropped)Fix it: remove the deny rule. The allow rule at 65534 was there all along; the deny at 900 simply won:
# Q5. Fix it: remove the deny rule. Priority 900 beat the allow rule at 65534, so it decided
gcloud compute firewall-rules delete netlab-deny-8080 --quiet 2>&1 | tail -1; sleep 20Deleted [https://www.googleapis.com/compute/v1/projects/your-project-id/global/firewalls/netlab-deny-8080].# Q5. The same test after the fix
WEB=$(gcloud compute instances describe web-vm --zone=us-east1-b --format="value(networkInterfaces[0].networkIP)")
curl -s -m 5 -w "netlab-vm -> web-vm:8080 HTTP %{http_code}, body: " http://$WEB:8080/📝⭐ Recommended by CareerByteCode · Certification examGoogle Analytics Certification (GA4) PracticeTake the examTake the exam →hello
netlab-vm -> web-vm:8080 HTTP 200, body:Q6. How many hops between two VMs in one VPC?
Answer: one. Inside a VPC, Google's network delivers packets directly; the VM's only route is to the subnet gateway, which is not a real router hop.
Proof (on netlab-vm):
# Q6. How many hops? Inside one VPC the other VM is one hop away; the internet path leaves through Cloud NAT
WEB=$(gcloud compute instances describe web-vm --zone=us-east1-b --format="value(networkInterfaces[0].networkIP)")
traceroute -n -m 3 -q 1 $WEB | tail -n +2 | sed 's/^/to web-vm: /'
ip route | head -3to web-vm: 1 10.142.0.32 1.168 ms
default via 10.142.0.1 dev ens4 proto dhcp src 10.142.0.31 metric 100
10.142.0.1 dev ens4 proto dhcp scope link src 10.142.0.31 metric 100
169.254.169.254 via 10.142.0.1 dev ens4 proto dhcp src 10.142.0.31 metric 100One hop to web-vm in about 1 ms. The VM's routing table sends everything (default) to the gateway .1.
Q7 and Q8. HTTP status codes and TLS certificates
Answer: 2xx means success, 3xx a redirect, 4xx the caller's mistake (404 not found), 5xx the server's failure. A TLS certificate proves the server's name, is signed by a certificate authority (the issuer), and expires.
Proof (on netlab-vm):
# Q7 and Q8. HTTP status codes and TLS certificates
WEB=$(gcloud compute instances describe web-vm --zone=us-east1-b --format="value(networkInterfaces[0].networkIP)")
for p in / /missing-page; do curl -s -o /dev/null -w "GET $p -> HTTP %{http_code}\n" http://$WEB:8080$p; done
curl -s -o /dev/null -w "GET http://google.com -> HTTP %{http_code} (redirect to %{redirect_url})\n" http://google.com/
echo | openssl s_client -connect www.google.com:443 -servername www.google.com 2>/dev/null | openssl x509 -noout -subject -issuer -enddateGET / -> HTTP 200
GET /missing-page -> HTTP 404
GET http://google.com -> HTTP 301 (redirect to http://www.google.com/)
subject=CN = www.google.com
issuer=C = US, O = Google Trust Services, CN = WE2
notAfter=Jan 26 08:29:36 2027 GMT
Q9. How does a packet know where to go in a VPC?
Answer: each VPC has routes: one per subnet (so subnets reach each other) and a default route (0.0.0.0/0) to the internet gateway. Custom and BGP routes can be added.
Proof:
# Q9. Routes: how does a packet know where to go? Each VPC has a default route and one route per subnet
gcloud compute routes list --filter="network=default" --format="value(destRange,nextHopGateway.basename())" | awk '{ if ($1 == "0.0.0.0/0") d++; else s++ } END { print "default route to the internet:", d, "| subnet routes:", s }'default route to the internet: 1 | subnet routes: 44The default network has one subnet in every region, hence 44 subnet routes, plus one default route.
Q10. Can two subnets in a VPC overlap?
Answer: no. Every subnet range in a VPC (and in peered VPCs) must be unique, or routing would be ambiguous.
Proof: we try to create a subnet with exactly the range of the existing default subnet:
# Q10. Can two subnets overlap? Try to add one that overlaps the default subnet of us-east1
R=$(gcloud compute networks subnets describe default --region=us-east1 --format="value(ipCidrRange)")
gcloud compute networks subnets create netlab-overlap --network=default --region=us-east1 --range=$R 2>&1 | grep -oE "conflicts with[^.]*|overlap[^.]*|already[^.]*" | head -1overlap with 10
Google Cloud refused it with an overlap error. (Our filter cut the message at the first dot of the address, so only "overlap with 10" is shown; run the command without the filter to read the whole message.)
Clean up (delete everything)
# Clean up: VMs, Cloud NAT and its router, the test firewall rule
gcloud compute instances delete netlab-vm web-vm --zone=us-east1-b --quiet 2>&1 | tail -2
gcloud compute routers nats delete netlab-nat --router=netlab-router --region=us-east1 --quiet > /dev/null 2>&1; gcloud compute routers delete netlab-router --region=us-east1 --quiet 2>&1 | tail -1
gcloud compute firewall-rules delete netlab-deny-8080 --quiet > /dev/null 2>&1; gcloud compute networks subnets delete netlab-overlap --region=us-east1 --quiet > /dev/null 2>&1
echo "left: $(gcloud compute instances list --filter='name~^(netlab|web)-vm' --format='value(name)' | wc -l) VMs, $(gcloud compute routers list --filter='name=netlab-router' --format='value(name)' | wc -l) routers"Deleted [https://www.googleapis.com/compute/v1/projects/your-project-id/zones/us-east1-b/instances/netlab-vm].
Deleted [https://www.googleapis.com/compute/v1/projects/your-project-id/zones/us-east1-b/instances/web-vm].
Deleted [https://www.googleapis.com/compute/v1/projects/your-project-id/regions/us-east1/routers/netlab-router].
WARNING: The following filter keys were not present in any resource : name
left: 0 VMs, 0 routersQuick answers to remember
| Question | One-line answer | Proved in |
|---|---|---|
| Private, public IP, MTU | Private always, public optional, MTU 1460 | Q1 |
| CIDR size | 2^(32-N), minus 4 reserved | Q2 |
| No internet | Add Cloud NAT (out only) | Q3 |
| Opening a URL | DNS, TCP, TLS, HTTP, timed by curl | Q4 |
| Firewall priority | Lowest number wins | Q5 |
| Hops inside a VPC | One | Q6 |
| HTTP and TLS | 2xx, 3xx, 4xx, 5xx; issuer and expiry | Q7 Q8 |
| Routes | One per subnet plus a default route | Q9 |
| Overlapping subnets | Not allowed | Q10 |
What next
- Connect two networks: the site-to-site VPN lab in this series.
- Learn the Linux side of networking: Linux Networking Commands Every Cloud Engineer Needs.
- More hands-on posts: ByteBlog. Practice in ByteLabs and see the courses.
Prepared by the CareerByteCode Team from our tested lab, with AI help for the write-up.
⭐ Keep learning with CareerByteCode
Hand-picked to go deeper on this topicGet CareerByteCode Team's next blog by email
One email a week when they publish. Add the weekly Best of ByteBlog too. No spam, unsubscribe with one click.
We email you once to confirm. By subscribing you agree to the privacy policy.
Related blogs
CareerByteCode TeamIstio Service Mesh for Beginners on Kubernetes
What you build: Istio on GKE with a 90/10 canary split, strict mTLS that refuses outsiders, and retries that hide a flaky service, in your own Google Cloud account. Every step tested.
#cloud
CareerByteCode TeamCloud Security Interview Questions with Hands-On Labs
What you build: 7 cloud security interview answers proved on Google Cloud: least privilege, Secret Manager, public buckets, keys, audit logs, firewall, Shielded VM. Every step tested.
#beginners
CareerByteCode TeamCloud DNS: Host Your Domain on Google Cloud
What you build: Cloud DNS public and private zones, a caching resolver that serves an old answer until its TTL runs out, and the lower-TTL-first fix. Every step tested.
#advanced
CareerByteCode TeamCilium CNI: eBPF Networking and Security for Kubernetes
What you build: Cilium network policies on GKE Dataplane V2: default deny, dropped packets seen in the kernel, egress control and a DNS mistake fixed. Every step tested.
💬 Comments (0)
Top · NewestSign in to comment