IPv4 gateway

Updated at:
Copy as MD

An IPv4 gateway is a VPC boundary component that centralizes control over all public IPv4 traffic entering and leaving a virtual private cloud (VPC). Without centralized control, unmanaged Internet access—such as business teams assigning public IP addresses to Elastic Compute Service (ECS) instances without approval—makes it difficult for operations and maintenance (O&M) teams to enforce consistent security policies. An IPv4 gateway and associated route tables let you direct all Internet-bound traffic through a single control point.

Billing: IPv4 gateways are free. Data transfer costs are generated by the public IP addresses attached to your resources—EIPs, static public IP addresses of ECS or Classic Load Balancer (CLB) instances—not by the gateway itself.

When to use an IPv4 gateway

Default Internet accessCentralized control with IPv4 gateway
ExampleAn ECS instance accesses the Internet directly using a static public IP address, an Elastic IP Address (EIP), or an Internet NAT gateway.Centralized management of all Internet access traffic for the VPC.
Use caseA small number of ECS instances require independent, direct Internet access. Ideal when Internet access requirements change frequently.Large-scale, multi-tiered network architectures. Enterprise environments with strict network security and compliance requirements.
ComplexitySimple and fast. No route configuration required.Requires network planning and routing rule configuration.
FlexibilityEach instance is managed independently, with no impact on others.Changes to network policies affect all instances in the VPC.
SecuritySecurity protection relies on the security group rules configured for each instance.Enforces consistent, VPC-wide network policies through centralized route control.

IPv4 gateway vs. Internet NAT gateway

An IPv4 gateway and an Internet NAT gateway serve different purposes and can be used together. For details on combining them, see Internet access.

IPv4 gatewayInternet NAT gateway
PurposeA VPC boundary component that controls public IPv4 traffic.A Network Address Translation (NAT) device inside the VPC.
ScenariosCentrally control Internet access traffic.Provide a unified egress for Internet-bound traffic.
Internet accessNo. Controls Internet traffic but does not provide connectivity itself.Provides Internet access by attaching EIPs. (EIPs provide the connectivity, not the NAT gateway itself.)

How it works

After you create an IPv4 gateway for a VPC, vSwitches fall into two categories based on their associated route tables:

  • Public vSwitch: The associated route table contains a route with Destination CIDR Block 0.0.0.0/0 and Next Hop set to the IPv4 gateway. Resources in this vSwitch can access the Internet if they have a public IP address.

  • Private vSwitch: The associated route table does not contain a route pointing to the IPv4 gateway. Resources in this vSwitch cannot directly access the Internet—even if they have a public IP address. What determines Internet access is the route, not the IP address.

Control Internet access using an IPv4 gateway

After you activate an IPv4 gateway, it centrally manages all Internet traffic for the VPC. Configure a 0.0.0.0/0 route on each vSwitch route table that should have Internet access, with the IPv4 gateway as the next hop. On the VPC details page, check IPv4 Internet Access Mode to confirm whether the IPv4 gateway is actively controlling Internet traffic.

Before activation, Internet traffic in the VPC is unaffected. A brief network interruption may occur during activation as traffic paths switch.
image

Use an IPv4 gateway with an Internet NAT gateway

Deploy the Internet NAT gateway in a public vSwitch. To give ECS instances in a private vSwitch Internet access, configure a route pointing to the Internet NAT gateway. Their Internet-bound traffic then flows to the NAT gateway, which uses its attached public IP address to reach the Internet.

image

Before combining the two gateways, check the EipBindMode setting of your Internet NAT gateway:

  • An Internet NAT gateway created in the console uses NAT mode by default. When calling CreateNatGateway, set EipBindMode to NAT. To change the mode after creation, call ModifyNatGatewayAttribute.

  • If your NAT gateway uses MULTI_BINDED mode (multi-EIP-to-ENI mode), you cannot create an IPv4 gateway—the two are incompatible.

  • If an IPv4 gateway already exists and you create an Internet NAT gateway with EipBindMode=MULTI_BINDED, you cannot attach EIPs to that NAT gateway.

Configure routes for private vSwitch resources before activating the IPv4 gateway to make sure they retain Internet access after activation.

Delete an IPv4 gateway

Before deleting the IPv4 gateway, disassociate the gateway route table. Then, in the Actions column of the target IPv4 gateway, click Delete, or call DeleteIpv4Gateway.

The deletion behavior depends on the mode selected:

  • Public mode: The system automatically removes all routes pointing to the IPv4 gateway. The VPC reverts to its initial state—instances with a public IP address can access the Internet directly.

  • Private mode: Manually delete all routes pointing to the IPv4 gateway from the route table before proceeding. After deletion, all resources in the VPC lose Internet access—regardless of whether they have a public IP address. To restore direct Internet access, create a new IPv4 gateway and delete it in public mode.

Important

After deleting an IPv4 gateway in private mode, all VPC resources lose Internet access. Proceed with caution.

image

Centrally control Internet access

Use an IPv4 gateway to enforce consistent Internet access policies across a VPC. The steps below walk through creating and activating an IPv4 gateway, and configuring routing so the gateway controls all Internet-bound traffic.

Console

  1. Go to the IPv4 Gateway page in the VPC console. Select the region where the VPC is deployed, then click Create IPv4 Gateway.

  2. On the Create IPv4 Gateway page, select the VPC for which you want to centralize Internet access.

  3. On the Activate IPv4 Gateway page, select the route table associated with the public vSwitch. The system automatically adds a 0.0.0.0/0 route pointing to the IPv4 gateway, allowing resources with a public IP address in the public vSwitch to access the Internet.

    • If a 0.0.0.0/0 route already exists in the route table, click Activate Later. Update the next hop of the existing route to the IPv4 gateway, then activate.

    • If an ECS instance uses a public IP address attached to an Internet NAT gateway: place the ECS instance and the NAT gateway in separate vSwitches. The NAT gateway vSwitch route table must contain a 0.0.0.0/0 route pointing to the IPv4 gateway. The ECS vSwitch route table must contain a route pointing to the NAT gateway in the public vSwitch.

    • If an ECS instance uses a static public IP address or a directly attached EIP: add a 0.0.0.0/0 route pointing to the IPv4 gateway.

API

  • Call CreateIpv4Gateway to create an IPv4 gateway.

  • Call EnableVpcIpv4Gateway to activate it. Set RouteTableList to the route table associated with the public vSwitch. If this parameter is omitted, call CreateRouteEntry to manually add a 0.0.0.0/0 route pointing to the IPv4 gateway.

Terraform

Unlike the console, activating an IPv4 gateway via Terraform does not automatically add a 0.0.0.0/0 route. Configure the route manually.

Resources: alicloud_vpc, alicloud_vswitch, alicloud_vpc_ipv4_gateway, alicloud_route_table, alicloud_route_table_attachment, alicloud_vpc_route_entry, alicloud_instance, alicloud_security_group, alicloud_security_group_rule, alicloud_eip_address, alicloud_eip_association, alicloud_nat_gateway, alicloud_snat_entry
Data sources: alicloud_zones
# Specify the region where you want to create the IPv4 gateway.
provider "alicloud" {
  region = "cn-hangzhou"
}

# Automatically obtain the list of zones where vSwitches can be created based on the data source.
data "alicloud_zones" "available_zones" {
  available_resource_creation = "VSwitch" # Query the zones where resources can be created in the VPC.
}

# Create a VPC.
resource "alicloud_vpc" "example_vpc" {
  vpc_name   = "example_vpc_name"
  cidr_block = "10.0.0.0/16" # Specify the CIDR block.
}

# Define the vSwitch configurations.
locals {
  vswitches = {
    vsw1 = {
      name       = "example_vsw1_name"
      cidr_block = "10.0.0.0/24"
      zone_index = 0
    }
    vsw2 = {
      name       = "example_vsw2_name"
      cidr_block = "10.0.1.0/24"
      zone_index = 1
    }
    vsw3 = {
      name       = "example_vsw3_name"
      cidr_block = "10.0.2.0/24"
      zone_index = 0
    }
    vsw4 = {
      name       = "example_vsw4_name"
      cidr_block = "10.0.3.0/24"
      zone_index = 0
    }
  }

  # Define the route table configurations.
  route_tables = {
    rt1 = {
      name        = "example_rt1_name"
      vswitch_key = "vsw1"
    }
    rt2 = {
      name        = "example_rt2_name"
      vswitch_key = "vsw2"
    }
    rt3 = {
      name        = "example_rt3_name"
      vswitch_key = "vsw3"
    }
    rt4 = {
      name        = "example_rt4_name"
      vswitch_key = "vsw4"
    }
  }

  # Define the instance configurations.
  instances = {
    instance1 = {
      name        = "example_instance1_name"
      vswitch_key = "vsw1"
    }
    instance2 = {
      name        = "example_instance2_name"
      vswitch_key = "vsw3"
    }
    instance3 = {
      name        = "example_instance3_name"
      vswitch_key = "vsw4"
    }
  }

  # Define the EIP configurations.
  eips = {
    eip1 = {
      name = "example_eip1_name"
    }
    eip2 = {
      name = "example_eip2_name"
    }
  }

  # Define the SNAT entry configurations.
  snat_entries = {
    snat1 = {
      instance_key = "instance2"
    }
    snat2 = {
      instance_key = "instance3"
    }
  }
}

# Create multiple vSwitches.
resource "alicloud_vswitch" "example_vsw" {
  for_each = local.vswitches

  vswitch_name = each.value.name
  cidr_block   = each.value.cidr_block
  vpc_id       = alicloud_vpc.example_vpc.id
  zone_id      = data.alicloud_zones.available_zones.zones[each.value.zone_index].id
}

# Create multiple custom route tables.
resource "alicloud_route_table" "example_route_table" {
  for_each = local.route_tables

  route_table_name = each.value.name
  vpc_id           = alicloud_vpc.example_vpc.id
}

# Associate the route tables with the vSwitches.
resource "alicloud_route_table_attachment" "example_route_table_attachment" {
  for_each = local.route_tables

  vswitch_id     = alicloud_vswitch.example_vsw[each.value.vswitch_key].id
  route_table_id = alicloud_route_table.example_route_table[each.key].id
}

# Specify the instance type.
variable "instance_type" {
  default = "ecs.e-c1m1.large"
}

# Specify the image ID.
variable "image_id" {
  default = "aliyun_3_x64_20G_alibase_20221102.vhd"
}

# Create a security group.
resource "alicloud_security_group" "example_security_group" {
  security_group_name = "example_security_group_name"
  vpc_id              = alicloud_vpc.example_vpc.id
}

# Create a security group rule. Modify the protocol and port number as needed.
resource "alicloud_security_group_rule" "allow_Internet" {
  type              = "ingress"
  ip_protocol       = "icmp"
  nic_type          = "intranet"
  policy            = "accept"
  port_range        = "-1/-1"
  priority          = 1
  security_group_id = alicloud_security_group.example_security_group.id
  cidr_ip           = "0.0.0.0/0"
}

# Create multiple servers.
resource "alicloud_instance" "example_instance" {
  for_each = local.instances

  instance_name        = each.value.name
  vswitch_id           = alicloud_vswitch.example_vsw[each.value.vswitch_key].id
  instance_type        = var.instance_type
  image_id             = var.image_id
  system_disk_category = "cloud_essd"
  security_groups      = [alicloud_security_group.example_security_group.id]
  instance_charge_type = "PostPaid"           # Set the billing method to pay-as-you-go.
  spot_strategy        = "SpotWithPriceLimit" # Set the instance as a spot instance for which you can specify a maximum price.
}

# Create multiple EIPs.
resource "alicloud_eip_address" "example_eip" {
  for_each = local.eips

  address_name = each.value.name
  isp          = "BGP"
  netmode      = "public"
  bandwidth    = "1"
  payment_type = "PayAsYouGo"
}

# Associate the ECS instance with an EIP.
resource "alicloud_eip_association" "example_eip_ecs_association" {
  allocation_id = alicloud_eip_address.example_eip["eip1"].id
  instance_type = "EcsInstance"
  instance_id   = alicloud_instance.example_instance["instance1"].id
}

# Create an Internet NAT gateway.
resource "alicloud_nat_gateway" "example_natgw" {
  nat_gateway_name = "example_natgw_name"
  vpc_id           = alicloud_vpc.example_vpc.id
  vswitch_id       = alicloud_vswitch.example_vsw["vsw2"].id
  nat_type         = "Enhanced"
  eip_bind_mode    = "NAT" # Specify the EIP association mode. The value must be NAT.
  payment_type     = "PayAsYouGo"
}

# Associate the EIP with the Internet NAT gateway.
resource "alicloud_eip_association" "example_eip_natgw_association" {
  allocation_id = alicloud_eip_address.example_eip["eip2"].id
  instance_type = "NAT"
  instance_id   = alicloud_nat_gateway.example_natgw.id
}

# Add a route that points to the NAT gateway.
resource "alicloud_route_entry" "example_rt3_route" {
  route_table_id        = alicloud_route_table.example_route_table["rt3"].id
  destination_cidrblock = "0.0.0.0/0"
  nexthop_type          = "NatGateway"
  nexthop_id            = alicloud_nat_gateway.example_natgw.id
}

# Add a route that points to the NAT gateway.
resource "alicloud_route_entry" "example_rt4_route" {
  route_table_id        = alicloud_route_table.example_route_table["rt4"].id
  destination_cidrblock = "0.0.0.0/0"
  nexthop_type          = "NatGateway"
  nexthop_id            = alicloud_nat_gateway.example_natgw.id
}

# Create an SNAT entry.
resource "alicloud_snat_entry" "example_snat_entry" {
  for_each = local.snat_entries

  snat_table_id = alicloud_nat_gateway.example_natgw.snat_table_ids
  source_cidr   = alicloud_instance.example_instance[each.value.instance_key].primary_ip_address
  snat_ip       = alicloud_eip_address.example_eip["eip2"].ip_address
}

# Create an IPv4 gateway.
resource "alicloud_vpc_ipv4_gateway" "example_ipv4gw" {
  ipv4_gateway_name = "example_ipv4gw_name"
  vpc_id            = alicloud_vpc.example_vpc.id
  enabled           = true
}

# Add a route that points to the IPv4 gateway.
resource "alicloud_route_entry" "example_rt1_route" {
  route_table_id        = alicloud_route_table.example_route_table["rt1"].id
  destination_cidrblock = "0.0.0.0/0"
  nexthop_type          = "Ipv4Gateway"
  nexthop_id            = alicloud_vpc_ipv4_gateway.example_ipv4gw.id
}

# Add a route that points to the IPv4 gateway.
resource "alicloud_route_entry" "example_rt2_route" {
  route_table_id        = alicloud_route_table.example_route_table["rt2"].id
  destination_cidrblock = "0.0.0.0/0"
  nexthop_type          = "Ipv4Gateway"
  nexthop_id            = alicloud_vpc_ipv4_gateway.example_ipv4gw.id
}

Privately used public CIDR block

By default, a VPC uses RFC 1918 private CIDR blocks: 10.0.0.0/8, 172.16.0.0/12, and 192.168.0.0/16. When a VPC connects to an on-premises data center or a peer VPC that uses a non-standard CIDR block (for example, 30.0.0.0/16), cloud resources with Internet access send requests to that non-standard block over the Internet rather than following the configured private route.

After you activate an IPv4 gateway, all traffic is forwarded based on the route table. Add a 0.0.0.0/0 route pointing to the IPv4 gateway for the vSwitch. Based on the longest prefix match rule, traffic destined for ECS02 matches the 30.0.0.0/16 route and routes to the peer VPC instead of going through the Internet.

image

Console

  1. Go to the IPv4 Gateway page in the VPC console. Select the region where the VPC is deployed, then click Create IPv4 Gateway.

  2. On the Create IPv4 Gateway page, select the VPC that needs to access the non-standard private CIDR block.

  3. On the Activate IPv4 Gateway page, select the route table associated with the vSwitch that needs to access the non-standard CIDR block. The system automatically adds a 0.0.0.0/0 route pointing to the IPv4 gateway, enabling resources in the vSwitch to reach the non-standard CIDR block via more specific routes.

    • If the route table already contains a 0.0.0.0/0 route, click Activate Later, delete that route, then activate again.

    • After activation, the IPv4 gateway centrally controls Internet-bound traffic, and all traffic is forwarded based on the route table.

API

  • Call CreateIpv4Gateway to create an IPv4 gateway.

  • Call EnableVpcIpv4Gateway to activate it. Set RouteTableList to the route table associated with the public vSwitch. If this parameter is omitted, call CreateRouteEntry to manually add a 0.0.0.0/0 route pointing to the IPv4 gateway.

Terraform

Unlike the console, activating an IPv4 gateway via Terraform does not automatically add a 0.0.0.0/0 route. Configure the route manually.

Resources: alicloud_vpc, alicloud_vswitch, alicloud_vpc_ipv4_gateway, alicloud_route_table, alicloud_route_table_attachment, alicloud_vpc_route_entry, alicloud_instance, alicloud_security_group, alicloud_security_group_rule, alicloud_eip_address, alicloud_eip_association, alicloud_vpc_peer_connection
Data sources: alicloud_zones
In this example, the VPCs in the peering connection belong to the same account. For a cross-account peering connection, also create an alicloud_vpc_peer_connection_accepter so the peer account accepts the request.
# Specify the region where you want to create the IPv4 gateway.
provider "alicloud" {
  region = "cn-hangzhou"
}

# Automatically obtain the list of zones where vSwitches can be created based on the data source.
data "alicloud_zones" "available_zones" {
  available_resource_creation = "VSwitch" # Query the zones where resources can be created in the VPC.
}

# Specify the instance type.
variable "instance_type" {
  default = "ecs.e-c1m1.large"
}

# Specify the image ID.
variable "image_id" {
  default = "aliyun_3_x64_20G_alibase_20221102.vhd"
}

# Create a VPC.
resource "alicloud_vpc" "example_vpc1" {
  vpc_name   = "example_vpc1_name"
  cidr_block = "10.0.0.0/16" # Specify the CIDR block.
}

# Create a VPC.
resource "alicloud_vpc" "example_vpc2" {
  vpc_name   = "example_vpc2_name"
  cidr_block = "30.0.0.0/16" # Specify the CIDR block.
}

# Create a vSwitch.
resource "alicloud_vswitch" "example_vsw1" {
  vswitch_name = "example_vsw1_name"
  cidr_block   = "10.0.1.0/24"
  vpc_id       = alicloud_vpc.example_vpc1.id
  zone_id      = data.alicloud_zones.available_zones.zones.0.id
}

# Create a vSwitch.
resource "alicloud_vswitch" "example_vsw2" {
  vswitch_name = "example_vsw2_name"
  cidr_block   = "30.0.1.0/24"
  vpc_id       = alicloud_vpc.example_vpc2.id
  zone_id      = data.alicloud_zones.available_zones.zones.1.id
}

# Create a security group.
resource "alicloud_security_group" "example_security_group1" {
  security_group_name = "example_security_group1_name"
  vpc_id              = alicloud_vpc.example_vpc1.id
}

# Create a security group rule. Modify the protocol and port number as needed.
resource "alicloud_security_group_rule" "allow_Internet1" {
  type              = "ingress"
  ip_protocol       = "icmp"
  nic_type          = "intranet"
  policy            = "accept"
  port_range        = "-1/-1"
  priority          = 1
  security_group_id = alicloud_security_group.example_security_group1.id
  cidr_ip           = "0.0.0.0/0"
}

# Create a security group.
resource "alicloud_security_group" "example_security_group2" {
  security_group_name = "example_security_group2_name"
  vpc_id              = alicloud_vpc.example_vpc2.id
}

# Create a security group rule. Modify the protocol and port number as needed.
resource "alicloud_security_group_rule" "allow_Internet2" {
  type              = "ingress"
  ip_protocol       = "icmp"
  nic_type          = "intranet"
  policy            = "accept"
  port_range        = "-1/-1"
  priority          = 1
  security_group_id = alicloud_security_group.example_security_group2.id
  cidr_ip           = "0.0.0.0/0"
}

# Create an ECS instance.
resource "alicloud_instance" "example_instance1" {
  instance_name        = "example_instance1_name"
  vswitch_id           = alicloud_vswitch.example_vsw1.id
  instance_type        = var.instance_type
  image_id             = var.image_id
  system_disk_category = "cloud_essd"
  security_groups      = [alicloud_security_group.example_security_group1.id]
  instance_charge_type = "PostPaid"
  spot_strategy        = "SpotWithPriceLimit"
}

# Create an EIP.
resource "alicloud_eip_address" "example_eip" {
  address_name = "example_eip_name"
  isp          = "BGP"
  netmode      = "public"
  bandwidth    = "1"
  payment_type = "PayAsYouGo"
}

# Associate the ECS instance with an EIP.
resource "alicloud_eip_association" "example_eip_ecs_association" {
  allocation_id = alicloud_eip_address.example_eip.id
  instance_type = "EcsInstance"
  instance_id   = alicloud_instance.example_instance1.id
}

# Create an ECS instance.
resource "alicloud_instance" "example_instance2" {
  instance_name        = "example_instance2_name"
  vswitch_id           = alicloud_vswitch.example_vsw2.id
  instance_type        = var.instance_type
  image_id             = var.image_id
  system_disk_category = "cloud_essd"
  security_groups      = [alicloud_security_group.example_security_group2.id]
  instance_charge_type = "PostPaid"
  spot_strategy        = "SpotWithPriceLimit"
}

# Create a custom route table.
resource "alicloud_route_table" "example_route_table1" {
  route_table_name = "example_route_table1_name"
  vpc_id           = alicloud_vpc.example_vpc1.id
}

# Associate the route table with the vSwitch.
resource "alicloud_route_table_attachment" "example_route_table_attachment1" {
  vswitch_id     = alicloud_vswitch.example_vsw1.id
  route_table_id = alicloud_route_table.example_route_table1.id
}

# Create a custom route table.
resource "alicloud_route_table" "example_route_table2" {
  route_table_name = "example_route_table2_name"
  vpc_id           = alicloud_vpc.example_vpc2.id
}

# Associate the route table with the vSwitch.
resource "alicloud_route_table_attachment" "example_route_table_attachment2" {
  vswitch_id     = alicloud_vswitch.example_vsw2.id
  route_table_id = alicloud_route_table.example_route_table2.id
}

# Create a VPC peering connection.
resource "alicloud_vpc_peer_connection" "example_vpc_peer" {
  peer_connection_name = "example_vpc_peer_name"
  vpc_id               = alicloud_vpc.example_vpc1.id
  accepting_ali_uid    = "1234****" # The ID of the account to which the peer VPC belongs. In this example, a same-account VPC peering connection is created. If you create a cross-account peering connection, you must create an alicloud_vpc_peer_connection_accepter to make sure that the peer account accepts the VPC peering connection request.
  accepting_region_id  = "cn-hangzhou"
  accepting_vpc_id     = alicloud_vpc.example_vpc2.id
}

# Configure a route for the peering connection.
resource "alicloud_route_entry" "example_peer_route1" {
  route_table_id        = alicloud_route_table.example_route_table1.id
  destination_cidrblock = "30.0.0.0/16"
  nexthop_type          = "VpcPeer"
  nexthop_id            = alicloud_vpc_peer_connection.example_vpc_peer.id
}

# Configure a route for the peering connection.
resource "alicloud_route_entry" "example_peer_route2" {
  route_table_id        = alicloud_route_table.example_route_table2.id
  destination_cidrblock = "10.0.0.0/16"
  nexthop_type          = "VpcPeer"
  nexthop_id            = alicloud_vpc_peer_connection.example_vpc_peer.id
}

# Create an IPv4 gateway.
resource "alicloud_vpc_ipv4_gateway" "example_ipv4gw" {
  ipv4_gateway_name = "example_ipv4gw_name"
  vpc_id            = alicloud_vpc.example_vpc1.id
  enabled           = true
}

# Add a route that points to the IPv4 gateway.
resource "alicloud_route_entry" "example_igw_route" {
  route_table_id        = alicloud_route_table.example_route_table1.id
  destination_cidrblock = "0.0.0.0/0"
  nexthop_type          = "Ipv4Gateway"
  nexthop_id            = alicloud_vpc_ipv4_gateway.example_ipv4gw.id
}

Redirect inbound Internet traffic to a security device

An IPv4 gateway centralizes control over outbound Internet traffic. To inspect inbound traffic as well, attach a gateway route table to the IPv4 gateway. The gateway route table redirects inbound traffic to a security device for deep inspection and filtering before it reaches your workloads. Combined with a custom route table on the outbound path, this gives you comprehensive inbound and outbound security protection.

Each VPC supports exactly one IPv4 gateway and one gateway route table, attached in a one-to-one relationship. A gateway route table is a route table type for border gateways.
To redirect inbound traffic, modify the system route entry in the gateway route table and set the next hop for the vSwitch CIDR block to the security appliance. The Add Route Entry button is not available in gateway route tables—custom routes cannot be added this way.

Single-point architecture

image

GWLB high availability architecture

In a single-point architecture, a security device failure affects the availability of your entire system. A Gateway Load Balancer (GWLB) lets you deploy security devices in a highly available configuration, eliminating single points of failure.

image

All examples in this architecture use the Gateway Load Balancer endpoint (GWLBe) as the traffic insertion point between workloads and the IPv4 gateway.

Inbound IPv4 Internet traffic path:

  1. IPv4 traffic enters the business VPC through the IPv4 gateway.

  2. The gateway route table directs the traffic to the GWLBe.

  3. The GWLBe forwards the traffic to the GWLB, which distributes it to a security device.

  4. After the security check, the traffic returns to the GWLB and then to the GWLBe through PrivateLink.

  5. The route table for the GWLBe subnet forwards the traffic to the business server.

Outbound IPv4 Internet traffic path:

  1. The route table for the business server subnet directs traffic to the GWLBe.

  2. The GWLBe forwards the traffic to the GWLB, which distributes it to a security device.

  3. After the security check, the traffic returns to the GWLB and then to the GWLBe through PrivateLink.

  4. The route table for the GWLBe subnet directs the traffic to the IPv4 gateway.

  5. The IPv4 gateway routes the traffic to the Internet.

To configure the gateway route table: find the system route for the target vSwitch CIDR block, click Edit in the Actions column, and set the GWLBe as the next hop. After saving, the route entry appears on the Custom Route tab.

Console

Attach a gateway route table

On the details page of the target IPv4 gateway, click Bind. Alternatively, on the Associated Border Gateway tab of the target gateway route table's details page, click Associate Border Gateway and select the target IPv4 gateway.

Detach a gateway route table

On the details page of the target IPv4 gateway, or on the Associated Border Gateway tab of the target gateway route table's details page, click Unbind.

API

Terraform

Resource: alicloud_vpc_gateway_route_table_attachment
# Specify the region where the IPv4 gateway is deployed.
provider "alicloud" {
  region = "cn-hangzhou"
}

# Specify the ID of the IPv4 gateway.
variable "ipv4_gateway_id" {
  default = "ipv4gw-hp3v******" # Replace the value with the actual ID of the IPv4 gateway.
}

# Specify the ID of the gateway route table.
variable "route_table_id" {
  default = "vtb-hp3w******" # Replace the value with the actual ID of the gateway route table.
}

# Attach the gateway route table.
resource "alicloud_vpc_gateway_route_table_attachment" "example_attachment" {
  ipv4_gateway_id = var.ipv4_gateway_id
  route_table_id  = var.route_table_id
}

Limitations

  • A VPC supports only one IPv4 gateway, and an IPv4 gateway can be associated with only one VPC.

  • An IPv4 gateway cannot be created if any resources in the VPC operate in cut-through mode. For example, if the EIP association mode of an Internet NAT gateway in the VPC is set to the multi-EIP-to-ENI mode (MULTI_BINDED), the Internet NAT gateway is incompatible with an IPv4 gateway. Call ModifyNatGatewayAttribute to change the EipBindMode to NAT before creating the IPv4 gateway.

  • In a shared VPC, only the resource owner can create, modify, or delete an IPv4 gateway. The principal does not have these permissions.

  • For private-facing CLB instances with an EIP or Anycast EIP attached, behavior varies by region:

    • In other regions: Internet access traffic is not restricted by the IPv4 gateway.

    The supported regions are subject to change.

    image

Supported regions

AreaRegions
Asia-Pacific - ChinaChina (Hangzhou), China (Shanghai), China (Nanjing - Local Region - Decommissioning), China (Qingdao), China (Beijing), China (Zhangjiakou), China (Hohhot), China (Ulanqab), China (Shenzhen), China (Heyuan), China (Guangzhou), China (Chengdu), China (Hong Kong), China (Wuhan - Local Region), China (Fuzhou - Local Region - Decommissioning)
Asia-Pacific - OtherJapan (Tokyo), South Korea (Seoul), Singapore, Malaysia (Kuala Lumpur), Indonesia (Jakarta), Philippines (Manila), Thailand (Bangkok)
Europe and AmericasGermany (Frankfurt), UK (London), US (Silicon Valley), US (Virginia), Mexico
Middle EastUAE (Dubai), SAU (Riyadh - Partner Region)

Quotas

QuotaDefault limitAdjustable
IPv4 gateways per VPC1No
Gateway route tables per IPv4 gateway1