Skip to content

Network Gateways

A VPC's internet path. Public IPv4 addresses mapped onto private interfaces, public IPv6 /64s on them, subnets that assign them at launch, and instances whose primary interface is private.

Updated View as Markdown

A Network Gateway is a VPC’s internet path. Attach one to a VPC, route the subnets’ traffic to it with route tables, and the VPC’s private interfaces can have public addresses:

  • a public IPv4 address, mapped to the interface’s primary private address. The instance never sees it: it keeps using its private address, and EZGH translates;
  • a public IPv6 /64, beside the interface’s private IPv6 address. The instance configures it.

An instance can then have its primary interface in a subnet, with no public interface at all. In the console, open Private Networks, then Network Gateways.

  • One per VPC. A gateway is attached to at most one VPC, and a VPC has at most one gateway.
  • Routes decide. A subnet reaches the internet only when its route table routes 0.0.0.0/0 (IPv4) or ::/0 (IPv6) to the gateway. Attaching a gateway adds no routes; the console and the CLI offer to add them to the main table (Attaching a Network Gateway). An interface without public addresses can’t reach the internet.
  • Free. Gateways aren’t billed. Public IPv4 addresses are billed as on a public interface.

Create and attach

Action Console API CLI
Create (detached) Create Network Gateway CreateNetworkGateway { name, description?, tags? } ezgh compute network-gateways create <name>
Attach to a VPC Attach, then a VPC; Add a default route to the main table is on by default AttachNetworkGateway { vpc }, then SetRoutes on the main table ezgh compute network-gateways attach <gateway> --vpc <vpc> (adds the default routes; --add-default-route=false doesn’t)
Detach Detach DetachNetworkGateway ezgh compute network-gateways detach <gateway>
Delete Delete DeleteNetworkGateway ezgh compute network-gateways delete <gateway>
ezgh compute network-gateways create edge
ezgh compute network-gateways attach edge --vpc main
Field Meaning
vpc The VPC it’s attached to (vpc_…), or null
attachmentState attached or detached
status available
Refusal When
409 vpc_has_gateway Attach: the VPC already has a gateway
409 gateway_attached Attach: the gateway is attached to another VPC. Delete: it’s attached; detach it first
409 gateway_in_use Detach: a public IPv4 address is mapped onto one of the VPC’s interfaces (mappings), or one of them has a public IPv6 /64 (ipv6Prefixes). Disassociate those addresses and delete those interfaces first
400 invalid_request Attach: the VPC is in another project

A VPC with a gateway attached can’t be deleted (409 vpc_in_use). Detaching or deleting a gateway removes no routes: routes to it turn blackhole until it’s attached to the VPC again.

Public IPv4 on a private interface

Associate an IPv4 address with a private interface as with a public one. The address is mapped to the interface’s primary private IPv4 address; the instance never sees it: configure nothing in the guest. Traffic from the private address to the internet leaves from the public one, and traffic to the public address arrives at the private one, while the subnet’s route table routes 0.0.0.0/0 to the gateway. Without that route the address stays associated but carries no traffic.

  • The address’s association.privateIpv4Address is the private address it’s mapped to; the interface’s ipv4Address is the public address.
  • Without an attached gateway the association is refused (409 vpc_has_no_gateway).
  • Moving an address between a public and a private interface works as any reassociation (allowReassociation).
ezgh compute ipv4-addresses associate web-public --network-interface app-1

Public IPv6 on a private interface

A private interface can have a public IPv6 /64, given when the interface is created (ipv6: { allocate: true }), never added later. The interface’s ipv6Prefix is the /64 and publicIpv6Address its ::1; ipv6Address stays its private address. The instance configures it: cloud-init puts <prefix>::1/64 on the interface beside its private address. It carries traffic while the subnet’s route table routes ::/0 to the gateway. The /64 lives and dies with the interface: it’s released when the interface is deleted.

Auto-assign

A subnet’s autoAssignPublicIpv4 and autoAssignPublicIpv6 (default off) decide whether a new interface in it gets a public IPv4 address or a public /64 when the request doesn’t say. They apply to new interfaces only. Either needs the VPC’s gateway (409 vpc_has_no_gateway when an interface would get an address).

Where Set it Override it per interface
Console The subnet’s Edit: Auto-assign public IPv4, Auto-assign public IPv6 Launch instance, a subnet primary: Public IPv4 address, Public IPv6 prefix
API UpdateSubnet { autoAssignPublicIpv4, autoAssignPublicIpv6 } ipv4 and ipv6 on CreateNetworkInterface ({ allocate: true | false }) and on CreateInstance’s networkInterfaces[i] (true | false)
CLI ezgh compute subnets update <subnet> --auto-assign-public-ipv4=true --ipv4/--no-ipv4, --ipv6/--no-ipv6 with --primary-subnet on ezgh compute instances launch; --allocate-ipv4/--no-allocate-ipv4, --allocate-ipv6/--no-allocate-ipv6 with --subnet on ezgh compute network-interfaces create (ezgh 0.36.0 or later)

Instances with a private primary

An instance’s primary interface (device index 0) can be in a subnet:

ezgh compute instances launch web-1 --instance-type <type> --image linux/ubuntu:24.04 --ssh-key me \
  --primary-subnet app --ipv4 --ipv6

With the API, put { subnet, ipv4?, ipv6? } first in CreateInstance’s networkInterfaces. In the console, Launch instance, Network & firewall, Primary interface: In a subnet.

  • No public interface beside it. An instance whose primary is private has only private interfaces (409 primary_is_private), and a private interface can’t be the primary of an instance that has a public one (409 instance_has_public). An instance with a public primary can still have private interfaces with public addresses.
  • A default route, always. cloud-init gives a private primary default routes via the subnet’s .1 and fe80::1 in the main table, and the public DNS resolvers, whether or not it has public addresses. Without public addresses, internet traffic is refused at once rather than timing out. It also routes the metadata service’s addresses through the subnet’s .1 and fe80::1.

Private interfaces with public addresses beside a public primary

An instance with a public primary can have private interfaces with public addresses. Replies from such an interface’s public addresses must leave by that interface, so cloud-init gives its own routing table (100 + <device index>) a default route for each family it has a public address in, set up at boot: IPv4 via the subnet’s .1 when it has a mapped IPv4 address, and IPv6 via fe80::1 when it has a public /64. The main table keeps the public primary’s defaults.

  • An IPv4 address associated with such an interface after boot answers incoming connections only once the instance is stopped and started: until then, replies from it leave by the primary interface and are dropped.

  • Images without routing rules (linux/rocky:*, linux/alpine:*) get the routes but no rules, and their cloud-init puts the table’s default routes in the main table. Remove those, then add the table and rules by hand, for example for device index 1 with private address 10.0.1.20:

    ip route del default via 10.0.1.1 dev eth1                # the misplaced default
    ip route add default via 10.0.1.1 dev eth1 table 101      # with a mapped IPv4 address
    ip rule add from 10.0.1.20/32 table 101
    ip -6 route add default via fe80::1 dev eth1 table 101    # with a public /64
    ip -6 rule add from 2602:f54f:10:1a2b::/64 table 101

Firewalls and MTU

  • The VPC’s default firewall allows all outbound traffic: with a gateway, that includes the internet. Inbound traffic from the internet is denied until a firewall attached to the interface allows it.
  • The internet path’s MTU is 1500, while private interfaces have 8900. Path MTU discovery works: the “fragmentation needed” or “packet too big” error comes from the subnet’s .1 (IPv4) or <subnet>::1 (IPv6).

What stays inside the VPC

Traffic between private addresses of one VPC stays in the VPC, as before. Traffic from one instance’s public address to another’s public address goes over the internet path, even within one VPC: use private addresses between instances.

If instances do reach each other by public address, the receiver sees the sender’s public address as the source, not its private one. The VPC’s default firewall allows only the VPC’s own ranges, so add rules to the receiver’s firewalls that allow the peers’ public addresses.

Metadata

On a private interface, the metadata service gives publicIpv4 (the mapped address, or null) and ipv6Prefix (its public /64, or ""); ipv4 stays null. An instance with a private primary reaches the metadata service on that interface, from its private IPv4 or IPv6 address.

Limits

Limit Value
Network Gateways per project 5 Quota network.networkGatewaysPerProject, up to 50
Network Gateways per VPC 1 Fixed

IAM

Action On
network.networkGateways.list, network.networkGateways.create The project
network.networkGateways.get, network.networkGateways.update, network.networkGateways.delete The gateway
network.networkGateways.attach, network.networkGateways.detach The gateway, and network.vpcs.update on the VPC
network.publicIps.allocate The project, for an interface that gets a public IPv4 address, including from a subnet’s auto-assign

NetworkFullAccess has them all; NetworkReadOnlyAccess and ReadOnlyAccess have the list and view actions. See IAM.

Navigation

Type to search…

↑↓ navigate↵ selectEsc close