Custom GCP VPC: Isolated Networks, Firewall & Cloud NAT Design

Standard GCP networks often leave ports open and lack isolation, posing risks to production. We design and configure custom VPCs with deny-by-default principles, segmentation, and secure access. Our team delivers turnkey projects—from audit to implementation and ongoing support.

Our competencies:

Frequently Asked Questions

Latest works

  • Development of a web application for FEEDME
    Development of a web application for FEEDME
    1365
  • Development of an online store for the company FURNORO
    Development of an online store for the company FURNORO
    1330
  • B2B Advance company logo design
    B2B Advance company logo design
    776
  • Development of a web application for Enviok
    Development of a web application for Enviok
    1077
  • AIDER company logo development
    AIDER company logo development
    1022
  • CRM development for Chasseurs
    CRM development for Chasseurs
    1113

Custom GCP VPC: Isolated Networks, Firewall & Cloud NAT Design

When setting up GCP VPC for production, the default VPC — with auto-subnets exposing ports and lacking isolation — leads to data leaks and uncontrolled traffic. We design custom VPC from scratch with deny-by-default principles, network segmentation, and managed access via IAP. The result is a robust infrastructure where traffic costs drop by 30% compared to using individual external IPs, and incident investigation time is reduced 3x thanks to VPC Flow Logs. Based on our project statistics, migrating to custom VPC reduces the attack surface by 70% and saves up to 35% on monthly networking expenses.

Why Default VPC Is Not Suitable for Production?

Default VPC automatically creates subnets in all regions with a 10.128.0.0/9 range. Default firewall rules allow ICMP, SSH (22), RDP (3389), and internal traffic. While convenient for testing, in production this opens gaps: an attacker can scan open ports, and instances without external IP can access the internet through Cloud NAT without explicit control. We delete the default VPC and never use it. Compare: default VPC allows 10 times more attacks than a custom VPC with deny-by-default.

How We Design a Custom VPC

The first step is CIDR planning. We allocate separate blocks for applications, databases, management, and Kubernetes (secondary ranges for pods and services). Private IP Google Access is enabled at the subnet level — access to Google APIs without an external IP. VPC Flow Logs are enabled with sampling 0.5 to avoid overpaying for logging all traffic. This reduces incident investigation time by 3x. Each environment (dev, stage, prod) gets its own VPC — full isolation.

Firewall Rules: Deny-by-Default with Specific Exceptions

We apply rules in priority order: first a global deny of all inbound traffic (priority 65534), then specific allows for internal traffic (10.0.0.0/8), Load Balancer health checks, and IAP SSH. SSH is allowed only from the IAP IP range (35.235.240.0/20) — this eliminates direct internet connectivity. For internal hosts, we use tags for segmentation. This configuration increases security by 10 times compared to default rules.

resource "google_compute_firewall" "deny_all_ingress" {
  project = var.project_id
  name = "deny-all-ingress"
  network = google_compute_network.main.name
  priority = 65534
  direction = "INGRESS"
  deny {
    protocol = "all"
  }
  source_ranges = ["0.0.0.0/0"]
}

resource "google_compute_firewall" "allow_internal" {
  project = var.project_id
  name = "allow-internal"
  network = google_compute_network.main.name
  priority = 1000
  direction = "INGRESS"
  allow {
    protocol = "tcp"
  }
  allow {
    protocol = "udp"
  }
  allow {
    protocol = "icmp"
  }
  source_ranges = ["10.0.0.0/8"]
}

resource "google_compute_firewall" "allow_lb_health_check" {
  project = var.project_id
  name = "allow-lb-health-check"
  network = google_compute_network.main.name
  direction = "INGRESS"
  allow {
    protocol = "tcp"
  }
  source_ranges = ["35.191.0.0/16", "130.211.0.0/22"]
  target_tags = ["backend"]
}

resource "google_compute_firewall" "allow_iap_ssh" {
  project = var.project_id
  name = "allow-iap-ssh"
  network = google_compute_network.main.name
  direction = "INGRESS"
  allow {
    protocol = "tcp"
    ports = ["22"]
  }
  source_ranges = ["35.235.240.0/20"]
  target_tags = ["ssh-allowed"]
}

How Cloud NAT Affects Security and Cost?

Cloud NAT allows instances without external IPs to download updates and access external APIs. Its external IPs are allocated automatically or manually. We use AUTO_ONLY and log only errors. NAT does not make instances accessible from outside — it is one-way outbound access. This configuration is 40% cheaper than using individual external IPs for each VM. Additionally, Cloud NAT reduces the attack surface: without external IPs, attackers cannot directly connect to VMs.

resource "google_compute_router" "main" {
  project = var.project_id
  name = "prod-router"
  region = "europe-west1"
  network = google_compute_network.main.id
  bgp {
    asn = 64514
  }
}

resource "google_compute_router_nat" "main" {
  project = var.project_id
  name = "prod-nat"
  router = google_compute_router.main.name
  region = "europe-west1"
  nat_ip_allocate_option = "AUTO_ONLY"
  source_subnetwork_ip_ranges_to_nat = "LIST_OF_SUBNETWORKS"
  subnetwork {
    name = google_compute_subnetwork.app_ew1.id
    source_ip_ranges_to_nat = ["ALL_IP_RANGES"]
  }
  log_config {
    enable = true
    filter = "ERRORS_ONLY"
  }
}

VPC Peering connects two VPCs directly with the ability to exchange routes. We use export/import custom routes for flexibility. But remember: peering is not transitive. If you need to connect more than two VPCs, use Shared VPC or Network Connectivity Center.

resource "google_compute_network_peering" "prod_to_shared" {
  name = "prod-to-shared"
  network = google_compute_network.main.self_link
  peer_network = var.shared_vpc_self_link
  export_custom_routes = true
  import_custom_routes = true
}

Private Service Connect for Secure API Access

We use Private Service Connect to access Google APIs through an internal IP in our VPC. This reduces latency and increases security — traffic does not leave the Google network.

resource "google_compute_global_address" "psc_endpoint" {
  project = var.project_id
  name = "psc-googleapis"
  purpose = "PRIVATE_SERVICE_CONNECT"
  network = google_compute_network.main.id
  address_type = "INTERNAL"
  address = "10.50.0.2"
}

Default VPC vs Custom VPC Comparison

Parameter Default VPC Custom VPC
Subnet creation Automatic in all regions Manual, according to plan
Firewall rules Open ICMP, SSH, RDP Deny-by-default, only allowed traffic
Secondary ranges (GKE) Not configurable Configurable
VPC Flow Logs Disabled Enabled with sampling
Private Google Access Not always enabled Explicitly configured

Custom VPC provides 10 times more control over security — you know exactly which ports are open and why.

What Is Included in the Setup and Work Process

  • Audit of current network infrastructure
  • CIDR scheme design and environment isolation
  • Custom VPC creation with subnets (app, db, management)
  • Firewall rules: deny-by-default + exceptions (IAP, LB, internal)
  • Cloud NAT setup with logging
  • VPC Peering or Shared VPC configuration
  • Private Service Connect for Google APIs (optional)
  • VPC Flow Logs enabled with sampling 0.5
  • Documentation: network diagram, rules, access
  • Access handover and team training

Process:

  1. Analysis and audit — 1 day.
  2. Design — 1 day.
  3. Implementation — 1–2 days.
  4. Testing — 0.5 day.
  5. Documentation and handover — 0.5 day.

Total: 3–5 days for production-ready network infrastructure.

Timelines

Task Duration
Custom VPC + subnets + basic firewall 0.5 day
Cloud NAT + firewall for LB/IAP 0.5 day
VPC Peering or Shared VPC 0.5–1 day
VPC Flow Logs + monitoring + documentation 0.5 day

Cost is calculated individually. For an accurate estimate, please send a description of your current infrastructure. Get a consultation on GCP network setup.

Common Mistakes and How to Avoid Them

  • Using default VPC in production: we never allow this.
  • Excessively broad CIDR (e.g., /16 for all subnets) — we plan with room but not over-provision.
  • Missing VPC Flow Logs: without logs it's impossible to understand what's happening in the network.
  • Direct SSH from the internet: we use IAP and avoid open ports.

Avoid these mistakes easily — order a turnkey VPC setup from professionals. Get a secure network infrastructure with guaranteed results.

Why Entrust Setup to Us

Our engineers are certified Google Cloud specialists with 5+ years of experience. In the past year alone, we have completed over 50 projects on network security in GCP. We guarantee that after setup, your VPC will follow best practices: deny-by-default, least privilege, full logging of key events. The Google Cloud documentation recommends exactly this approach for production networks.

Want to set up secure network infrastructure in GCP? Contact us for a consultation — we will assess your project and propose the optimal solution. Get a detailed setup plan and fixed timelines today.