---
title: "VPCs and subnets"
description: "Private networks between your instances, their subnets and private network interfaces, secondary private addresses for failover, and the guest hook that configures them."
---

> Documentation Index
> Fetch the complete documentation index at: https://docs.ezghcloud.com/llms.txt
> Use this file to discover all available pages before exploring further.

# VPCs and subnets

A **VPC** is a private, routed network in a project. Its **subnets** are ranges carved from it, and
instances join it through **private network interfaces**, each created in one subnet. Instances in
a VPC reach each other over private IPv4 and IPv6, whichever host they run on. In the console, open
**Private Networks**, then **VPCs** or **Subnets**.

- **Isolated.** A VPC never reaches another VPC or another project, and reaches the internet only
  through a [Network Gateway](/private-networks/network-gateways). There's no peering, VPN or route
  table.
- **Routed only.** An interface carries only the addresses assigned to it. There's no broadcast and
  no ARP-based address takeover: a secondary address moves to another interface through the API.
- **Additional or primary.** A private interface can be added beside a public primary, which keeps
  its addresses and firewalls. With a [Network Gateway](/private-networks/network-gateways), it can
  also be the instance's primary interface, with public addresses of its own; without one, internet
  access goes through a public interface.
- **No private DNS.** Instances keep the public resolvers. Nothing answers DNS at a subnet's `.2`.
- **Encrypted between hosts.** Traffic between instances on different hosts is encrypted with
  IPsec. Traffic between instances on the same host never leaves it. Use TLS in your applications
  for end-to-end confidentiality.
- **Free.** VPCs, subnets and private traffic aren't billed. They're limited by
  [quotas](#limits).

## VPCs

| Field | Meaning |
| --- | --- |
| `ipv4Cidr` | The IPv4 range you choose at create, `/8` to `/28`. Fixed for the VPC's life |
| `ipv6Cidr` | A unique local `/56` (`fd00::/8`), generated. Fixed for the VPC's life |
| `mtu` | `8900`, for every private interface in the VPC. Not settable |
| `defaultFirewall` | The VPC's [default firewall](#firewalls) (`fwl_…`) |
| `status` | `available`, or `deleting` while a delete finishes |
| `failureReason` | Why a create or delete hasn't finished yet, or `null`. `default_firewall_unavailable`, `default_firewall_conflict` and `addresses_withdrawing` are retried for you; `vpc_in_use` needs you: delete its subnets, then delete the VPC again |

The IPv4 range must be inside one of these pools, with its host bits zero:

| Pool | |
| --- | --- |
| `10.0.0.0/8`, `172.16.0.0/12`, `192.168.0.0/16` | Private address space (RFC 1918) |
| `100.64.0.0/10` | Shared address space (RFC 6598), meant for carrier-grade NAT |
| `198.18.0.0/15` | Benchmarking address space (RFC 2544) |

A VPC can use a whole pool, `10.0.0.0/8` included. Ranges may overlap between VPCs, since VPCs
never meet. Choose ranges that don't overlap networks you connect instances to by other means.

In the console, **Create VPC** takes the VPC's name and IPv4 range, then optionally a **First
subnet**, then a **Review**. If the subnet is refused, the VPC is kept and the dialog offers
**Create subnet** again. With the API, call [CreateVpc](/network-api/CreateVpc/); from the CLI:

```sh
ezgh compute vpcs create main --ipv4-cidr 10.0.0.0/16
```

**Deleting a VPC** ([DeleteVpc](/network-api/DeleteVpc/), `ezgh compute vpcs delete`) also
deletes its default firewall and its main [route table](/private-networks/route-tables). It's
refused while the VPC has subnets or custom route tables (`409 vpc_in_use`), and while
its default firewall is attached to an interface or named in another firewall's rule
(`409 vpc_default_firewall_referenced`; the VPC stays `available`). A delete can answer `204` and
leave the VPC `deleting` for a while, with `failureReason: addresses_withdrawing`, while the
addresses of its deleted interfaces are withdrawn; it's then removed with nothing more to do.

## Subnets

| Field | Meaning |
| --- | --- |
| `vpc` | Its VPC (`vpc_…`) |
| `ipv4Cidr` | Inside the VPC's range, `/8` to `/28`, not overlapping another of its subnets. Fixed |
| `ipv6Cidr` | The VPC's next free `/64`. Fixed |
| `availableIpv4Addresses` | Addresses free for interfaces |
| `autoAssignPublicIpv4`, `autoAssignPublicIpv6` | Whether a new interface in it gets a public IPv4 address or a public IPv6 `/64` unless it says otherwise. Default `false`; see [auto-assign](/private-networks/network-gateways#auto-assign) |
| `routeTable` | The [route table](/private-networks/route-tables) it uses (`rtb_…`): its own, or the VPC's main table. Change it with `{ routeTable }` on [UpdateSubnet](/network-api/UpdateSubnet/) (`null` for the main table) |

Subnets are regional, like their VPC: there are no zones to choose. All subnets of a VPC route to
each other: every route table has `local` routes for the VPC's ranges.

**Reserved addresses.** In IPv4, the network address, `.1` (the subnet's router), `.2`, `.3` and
the broadcast address. In IPv6, `::0` to `::3` of the `/64`, with `::1` the router. They're never
given to an interface.

In the console, **Create subnet** on the **Subnets** page or a VPC's **Subnets** tab. With the API,
call [CreateSubnet](/network-api/CreateSubnet/); from the CLI:

```sh
ezgh compute subnets create app --vpc main --ipv4-cidr 10.0.1.0/24
ezgh compute subnets list --vpc main
```

| Refusal | When |
| --- | --- |
| `409 subnet_cidr_overlap` | The range overlaps another subnet of the VPC |
| `409 vpc_ipv6_exhausted` | The VPC has 256 subnets, every `/64` of its `/56` |
| `409 subnet_addresses_withdrawing` | An address the new subnet reserves, such as its `.1`, is still being withdrawn from a deleted interface. Retry shortly |
| `409 vpc_deleting` | The VPC is being deleted |
| `409 subnet_in_use` | Delete: interfaces are still in the subnet |

## Private network interfaces

A private interface is a [network interface](/private-networks/network-interfaces) created in a subnet. It
has a **primary private IPv4** address and a **primary IPv6** address (`/128`) in the subnet, both
fixed for its life. Its public addresses, a mapped IPv4 address and a `/64`, need the VPC's
[Network Gateway](/private-networks/network-gateways) (`409 vpc_has_no_gateway` without one). Its
MTU is 8900. Its subnet is fixed for its life.

- **The primary IPv4** is the one you choose, or the lowest free address, preferring one released
  more than an hour ago. **The primary IPv6** is random within the subnet's `/64`.
- **Firewalls.** Omitted, a private interface gets its **VPC's default firewall**, not the
  project's; `[]` means none. See [Firewalls](#firewalls).
- **Attach and detach** work as for any secondary interface: only while the instance is stopped.
  An instance's primary interface can be private when it's launched that way
  ([private primary](/private-networks/network-gateways#instances-with-a-private-primary)).
- **One private interface per subnet per instance.** An instance can have private interfaces in
  several subnets of one VPC, and in several VPCs. It can't have two in one subnet
  (`409 subnet_conflict`), or two in different VPCs whose IPv4 ranges overlap
  (`409 vpc_range_conflict`).

### Create one

| Where | How |
| --- | --- |
| Console, **Create network interface** | **Network**: a subnet instead of **Public**; optionally its private IPv4 address |
| Console, **Launch instance** | **Network & firewall**, **Add private interface**: a subnet and optionally an IPv4 address, per interface |
| API | [CreateNetworkInterface](/network-api/CreateNetworkInterface/) with `subnet` and optionally `privateIpv4Address`; or [CreateInstance](/compute-api/CreateInstance/) with `networkInterfaces[i]` `{ subnet, privateIpv4Address?, ipv4?, ipv6?, firewallIds? }` |
| CLI | `--subnet` and `--private-ipv4` on `ezgh compute network-interfaces create` and `ezgh compute instances launch` |

```sh
ezgh compute network-interfaces create db-a-private --subnet app --private-ipv4 10.0.1.20
ezgh compute instances attach-network-interface db-a db-a-private   # while db-a is stopped

# At launch: the i-th --private-ipv4 is the i-th --subnet's; without one, the lowest free address
ezgh compute instances launch web-1 --instance-type <type> --image linux/ubuntu:24.04 --ssh-key me \
  --subnet app --private-ipv4 10.0.1.21 --subnet mgmt
```

`ipv6` without `subnet`, or `privateIpv4Address` without it, is `400 invalid_request`. Other
refusals: `409 vpc_has_no_gateway` (a public address without the VPC's gateway), `409 address_in_use` (the address is taken or still being withdrawn), `409 subnet_full`,
`409 subnet_not_available` (the subnet or its VPC is being created or deleted),
`409 vpc_interface_limit` and `409 vpc_address_budget_exhausted` (the VPC's
[4,000 addresses](#limits)).

### In the guest

At every boot, cloud-init configures each private interface (`eth0`, `eth1`, … in device order)
with its primary addresses only:

- the primary IPv4 with the subnet's prefix length, and the primary IPv6 as a `/64`;
- routes to the VPC's IPv4 range via the subnet's `.1`, and to its IPv6 `/56` via `fe80::1`;
- MTU 8900, no router advertisements; beside a public primary, no default route in the main table
  and no DNS servers. A [private primary](/private-networks/network-gateways#instances-with-a-private-primary)
  gets default routes and DNS servers, and a public `/64` is configured beside the private
  address.

**Several interfaces in one VPC** need per-interface routing, or a reply from one interface's
address leaves by another and is dropped. cloud-init sets it up: the VPC's routes in the main table
go through the VPC's interface with the lowest device index, and each interface also gets its own
routing table, `100 + <device index>` (by the index itself, not the `eth` name: with device
indexes 1 and 3, `eth1` and `eth2` use tables 101 and 103), with the VPC's routes through it and rules sending traffic
from its addresses to that table. Only images whose cloud-init uses netplan or systemd-networkd
get the rules:

| Image | One private interface per VPC | Several in one VPC |
| --- | --- | --- |
| `linux/ubuntu:24.04`, `linux/ubuntu:26.04`, `linux/debian:12`, `linux/debian:13` | Yes | Yes |
| `linux/rocky:9`, `linux/rocky:10`, `linux/alpine:3.24` | Not tested | No |

The guest may lower an interface's MTU below 8900.

## Firewalls

[Firewalls](/compute/firewalls) apply to private interfaces as to public ones, and the same
firewalls can be attached to both.

- **The VPC's default firewall** is made with the VPC. It allows all inbound traffic from the VPC's
  IPv4 range and IPv6 `/56`, and all outbound traffic (the internet too, once the VPC has a
  [Network Gateway](/private-networks/network-gateways#firewalls-and-mtu)). You can edit its rules; it can't be deleted
  on its own (`409 default_firewall_protected`) and goes with the VPC. It attaches only to
  interfaces in its own VPC (`409 firewall_vpc_mismatch` elsewhere). The console marks it **VPC
  default**.
- **A firewall peer** in a private interface's rules admits only that firewall's members in the
  **same VPC**, never another VPC's interfaces that use the same addresses, nor public interfaces.
  A member contributes all its private addresses, primary and secondary, and its public IPv6 `/64`
  when it has one, and nothing of its subnet-mates. Rules can also name a range, such as a
  delegated prefix, a subnet or the VPC's range. When a member gains or loses a prefix, firewalls
  that reference its firewall briefly recompile. For a cluster, rules naming the subnet or VPC range
  are the recommended way to allow node-to-node traffic.

## Delegated prefixes

A private interface can hold **delegated prefixes** from its own subnet: IPv4 `/28` blocks and IPv6
`/80` blocks, for example to give each pod on a node its own address. You add and remove them while
the instance runs. Name a prefix, or let EZGH pick a free aligned block of the `family`.

- **Limits.** 16 IPv4 and 2 IPv6 prefixes per interface. Prefixes count toward the VPC's 5,000
  member prefixes. A subnet of `/27` or smaller has no eligible `/28`.
- **`409 prefix_unavailable`** means the subnet has no free aligned block, even if addresses are free.
- **A prefix can't move between interfaces.** Unassign it, then assign it on the other interface.
  Unassigning takes a moment, and traffic on that interface may pause briefly.
- **Assign and unassign are asynchronous operations**, the same as for secondary addresses:
  `Idempotency-Key`, `202` with an operation, followed through the
  [operations](#operations) endpoints. In an operation, `address` holds the prefix in CIDR form.
- Live migration and stop and start keep an interface's prefixes. The interface's
  [firewalls](#firewalls) apply to them.

| Action | API | CLI |
| --- | --- | --- |
| Assign one: the prefix you give, or a free one of `family` | [AssignPrivatePrefix](/network-api/AssignPrivatePrefix/) `{ family, prefix? }` | `ezgh compute network-interfaces private-prefixes assign <interface> [--prefix p \| --family ipv4\|ipv6]` |
| Unassign one | [UnassignPrivatePrefix](/network-api/UnassignPrivatePrefix/) `{ family, prefix, expectedGeneration }` | `… unassign <interface> <prefix>` |

The interface's `privatePrefixAssignments` lists `{ family, prefix, generation }`. A stale
`expectedGeneration` is `409 address_generation_conflict`. Errors are those of secondary addresses
(`public_interface`, `address_in_use`, `address_operation_in_progress`, `interface_not_available`,
`migration_in_progress`, `private_address_limit_exceeded`), plus `400 invalid_request` for a prefix of
the wrong length, not aligned, outside the subnet or overlapping reserved addresses.

### Use prefixes in the guest

EZGH doesn't configure the guest for a prefix: route it yourself. The [metadata service](/compute/user-data-and-metadata#private-interfaces)
lists `delegatedPrefixes`.

- **Use a routed CNI or ipvlan L3.** An interface has one MAC address, so macvlan and bridged pods
  don't work, and ipvlan L2 doesn't work.
- **An interface other than the first** needs its own policy routing. It isn't set up for prefixes.
- **Addresses on the node's own stack.** An address from a prefix bound on the node, for example on
  `lo`, sends ARP with that source, which is refused, so replies to peers in the subnet fail. Set
  `arp_announce=2`, or put pods in their own network namespaces.
- **Internet access.** A [Network Gateway](/private-networks/network-gateways) mapping covers only
  the interface's primary address. SNAT pod traffic to it for IPv4, or for IPv6 to an address in the
  interface's `/64` where it has one.

## Secondary private addresses

A private interface can also own **secondary** addresses of its own subnet, IPv4 or IPv6, up to 2 in total.
Each has one owner at a time. A secondary address can be moved to another private interface in
the same subnet, while both instances run, so an application or database can fail over to another
instance. Primary addresses can't be unassigned or moved.

A move is application failover, not a migration: the new owner doesn't inherit the old one's
established connections or the permissions firewall peers gave it. Clients reconnect. The address
follows the destination interface's firewalls.

| Action | API | CLI |
| --- | --- | --- |
| Assign one: the address you give, or the next free one of `family` | [AssignPrivateAddress](/network-api/AssignPrivateAddress/) `{ family, address? }` | `ezgh compute network-interfaces private-addresses assign <interface> [--address a \| --family ipv6]` |
| Unassign one | [UnassignPrivateAddress](/network-api/UnassignPrivateAddress/) `{ family, address, expectedGeneration }` | `… unassign <interface> <address>` |
| Move one to `destinationInterface` | [ReassignPrivateAddress](/network-api/ReassignPrivateAddress/) `{ family, address, expectedGeneration, destinationInterface }` | `… reassign <interface> <address> --to <interface>` |
| Follow an operation | [GetPrivateAddressOperation](/network-api/GetPrivateAddressOperation/), [ListPrivateAddressOperations](/network-api/ListPrivateAddressOperations/) | `… operations get <operation> [--wait]`, `… operations list [--network-interface i]` |

In the console, an interface's **Private addresses** tab lists its primary and secondary
addresses and recent operations, with **Assign address**, and **Move** and **Unassign** on each
secondary address.

- **`expectedGeneration`** is the address's `generation` in the interface's
  `privateAddressAssignments`. A stale one is `409 address_generation_conflict`: read the
  interface again. The CLI and console read it for you.
- **Idempotency.** Each request needs an `Idempotency-Key` header (1–200 characters). Retrying
  with the same key answers the same operation as it is now, so a lost answer never starts a second
  one. The key is kept at least seven days after the operation finishes.
- **One address per request.** Moving an IPv4 and an IPv6 address is two operations, each on its own.
- **Moving needs** `network.networkInterfaces.reassignPrivateAddress` on both interfaces.

### Operations

Each request answers `202` with an operation, a `Location` header naming it and `Retry-After: 2`,
even when it's already done. Poll it, following `Retry-After`, which is present while it's open:

```json
{
  "id": "019a12f0-1234-7000-8000-000000000001",
  "type": "reassign",
  "status": "running",
  "phase": "withdrawing",
  "family": "ipv4",
  "address": "10.0.1.50",
  "sourceInterface": "eni_5q2m9x0a7k1d",
  "destinationInterface": "eni_8k2m4x7b1c3d",
  "expectedGeneration": "7",
  "generation": "8",
  "blockedReason": "waiting_for_withdrawal",
  "createdAt": "2026-10-24T22:00:00Z",
  "updatedAt": "2026-10-24T22:00:01Z",
  "finishedAt": null,
  "error": null
}
```

| Field | Values |
| --- | --- |
| `status` | `queued`, `running`, `succeeded` or `failed` |
| `phase` | `reserved`, `withdrawing` (the address is removed from its old owner everywhere), `activating` (the new owner gets it), `complete` |
| `blockedReason` | `null`, or why it's waiting: `waiting_for_withdrawal`, `waiting_for_fence` (a server that held the address isn't responding; the operation waits until it's confirmed off or back), `waiting_for_destination` (the destination interface hasn't taken the address yet) or `dependency_unavailable`. It keeps retrying |
| `generation` | The address's next ownership generation, a decimal string |
| `error` | On `failed`, `{ code, message }` |

- **`succeeded`** means the address has been withdrawn from its old owner everywhere and the
  destination's host has it. It doesn't mean either guest has configured it: see
  [the guest hook](#configure-secondary-addresses-in-the-guest). A destination whose instance isn't
  running gets the address when it starts.
- **Waiting can take time.** An operation stays `running` until it can finish safely; nothing
  times it out and there's no cancel. The address stays reserved meanwhile, and the interfaces
  involved can't be deleted (`409 address_operation_in_progress`).
- An operation can be read after its interfaces are deleted.

With `--wait`, the CLI waits until the operation has succeeded, for at most `--wait-timeout`
(10 minutes by default). If that runs out, it exits `1` and the operation carries on: follow it
with `ezgh compute network-interfaces private-addresses operations get <operation>`. Without
`--wait`, the command prints the accepted operation. In the console, an operation shows **Accepted**, **Waiting** with its reason,
then **Succeeded** or **Failed**.

| Refusal | When |
| --- | --- |
| `400 invalid_request` | A missing or bad `Idempotency-Key`, an address outside the subnet or reserved, a family that doesn't match the address, or the destination is the source |
| `404 not_found` | An interface, destination or operation you can't see, or in another project |
| `409 public_interface` | An interface involved is public |
| `409 primary_address_immutable` | Unassign or move a primary address |
| `409 address_not_assigned` | The interface doesn't own the address |
| `409 address_generation_conflict` | `expectedGeneration` is stale |
| `409 address_in_use` | Assign: the address is owned, reserved or still being withdrawn |
| `409 address_operation_in_progress` | Another operation is changing the address |
| `409 subnet_mismatch` | The destination is in another subnet |
| `409 subnet_full` | Assign: no free address of the family |
| `409 private_address_limit_exceeded` | The interface would have more than 2 secondary addresses, or the VPC more than 4,000 addresses |
| `409 interface_not_available` | An interface involved is being deleted |
| `409 migration_in_progress` | An instance involved is being live-migrated. Retry once it's done |
| `409 idempotency_conflict` | The `Idempotency-Key` was used for a different request |
| `409 idempotency_in_progress` | The first request with that key is still being accepted. Retry after `Retry-After` |

### Configure secondary addresses in the guest

cloud-init never configures secondary addresses: they move, and the boot configuration doesn't.
The **`ezgh-vpc-addresses`** hook configures them from the
[metadata service](/compute/user-data-and-metadata#private-interfaces), which lists only the
addresses each private interface owns now. Don't also put secondary addresses in netplan,
systemd-networkd or NetworkManager files: a moved address would come back at the next boot.

**The hook is installed for you.** On an instance with a private interface, the instance's
cloud-init vendor-data installs the hook at every boot, once networking is up, and keeps it at
the version EZGH Compute pins: it downloads each file from `get.ezghcloud.com` and installs
it only if its SHA-256 matches. If a download fails or doesn't match, nothing changes. Its log is
`journalctl -u ezgh-vpc-addresses-install`. The instance needs outbound HTTPS (port 443) to
`get.ezghcloud.com` at boot, without a proxy: if a firewall rule blocks it, the hook isn't
installed and each boot logs `download failed`.

| Image | The hook |
| --- | --- |
| `linux/ubuntu:24.04`, `linux/ubuntu:26.04`, `linux/debian:12`, `linux/debian:13` | Supported, installed automatically |
| `linux/rocky:9`, `linux/rocky:10` | Not supported, not installed |
| `linux/alpine:3.24` | Not supported (no systemd), not installed |

VLANs, bonds and bridges over private interfaces aren't supported: a VPC is routed only. The hook
configures secondary addresses on the link that holds the interface's primary private IPv4
address.

**What a pass does** (`ezgh-vpc-addresses reconcile`):

- It reads the instance's metadata, over IPv4, or IPv6 if IPv4 can't connect.
- It removes secondary addresses it added that an interface no longer owns, with their rules, then
  adds the ones it now owns: IPv4 as a `/32`, IPv6 as a `/128` that new connections don't pick as
  their source, each with a rule `from <address> lookup <100 + device index>`.
- It changes only what it added itself, recorded in `/var/lib/ezgh-vpc-addresses/`. Addresses and
  rules you add by hand are left alone.
- **When ownership isn't known**, for example when metadata can't be reached or isn't ready yet, it
  changes nothing. At boot that means no secondary address comes up; while the instance runs, the
  addresses already configured stay. At every boot it first removes what it configured before the
  reboot.

It exits `0` once every private interface's addresses are configured, `75` while they aren't known
or ready yet, and `1` on any other failure. `reconcile --wait` retries, from 1 second doubling to
30, until it exits `0`.

Each boot replaces the hook's binary and units if they differ from the pinned version, and
enables them again. Customize the units with drop-ins (`systemctl edit`), not by editing them.

**To opt out**, turn vendor-data off in the instance's [user data](/compute/user-data-and-metadata):

```yaml
#cloud-config
vendor_data: {enabled: false}
```

This also stops cloud-init from applying network configuration at every boot: a network interface
attached while the instance is stopped then isn't configured at its next start. A hook that's
already installed stays installed.

**To install the hook by hand**, for an image without cloud-init or after opting out:

```sh
v=1.0.0; base=https://get.ezghcloud.com/guest/vpc-addresses/v$v
for f in SHA256SUMS ezgh-vpc-addresses-linux-amd64 ezgh-vpc-addresses.service ezgh-vpc-addresses-ready.service ezgh-vpc-addresses.timer systemd-networkd.conf; do
  curl -fsSLO --proto =https "$base/$f"
done
sha256sum --check SHA256SUMS
sudo install -m 0755 ezgh-vpc-addresses-linux-amd64 /usr/local/bin/ezgh-vpc-addresses
sudo install -m 0644 ezgh-vpc-addresses.service ezgh-vpc-addresses-ready.service ezgh-vpc-addresses.timer /etc/systemd/system/
sudo install -D -m 0644 systemd-networkd.conf /etc/systemd/system/systemd-networkd.service.d/ezgh-vpc-addresses.conf
sudo systemctl daemon-reload
sudo systemctl enable --now ezgh-vpc-addresses.timer
sudo systemctl enable ezgh-vpc-addresses.service
```

The hook has two services:

- **`ezgh-vpc-addresses.service` runs one pass.** It runs at every boot, after cloud-init's
  networking. `ezgh-vpc-addresses.timer` runs it again 30 seconds after each pass, and the
  `systemd-networkd` drop-in runs it when systemd-networkd restarts, since that drops addresses
  and rules it didn't configure. Exit `75` isn't a failure, and boot never waits for this service.
- **`ezgh-vpc-addresses-ready.service` runs `reconcile --wait`**: it finishes once a pass succeeds.
  Nothing starts it but the applications that require it.

After `netplan apply`, run a pass by hand.

**Order your application after the ready service.** While ownership isn't known, the ready service
keeps retrying and an application that requires it waits. To start the application at boot, give
it a target of its own. Enabled from `multi-user.target`, it would hold that target back, and with
it cloud-init's final stage (your user data scripts):

```ini
# /etc/systemd/system/myapp.service.d/vpc-addresses.conf
[Unit]
Requires=ezgh-vpc-addresses-ready.service
After=ezgh-vpc-addresses-ready.service

[Install]
WantedBy=myapp.target
```

```ini
# /etc/systemd/system/myapp.target
[Unit]
Description=My application, once its VPC addresses are configured
DefaultDependencies=no

[Install]
WantedBy=multi-user.target
```

```sh
sudo systemctl enable myapp.service myapp.target
```

Every start of the application, at boot included, then waits for a pass to succeed. The
application starts only once its addresses are configured.

- Use `Requires=`, not `BindsTo=`: a later failed pass then doesn't stop a running application.
- While the application waits at boot, its start is still part of boot:
  `systemctl is-system-running` says `starting` until it starts.
- A restart of the application while metadata is unavailable waits too. If you'd rather it went
  ahead, use `Wants=` and check the addresses in the application.
- Start the ready service with `systemctl start`, never `restart`: `Requires=` carries a restart
  through to the application.

**Fail over** with a move, in this order:

1. Stop or quiesce the application on the source instance, if you can reach it.
2. Move the address: `ezgh compute network-interfaces private-addresses reassign db-a-private 10.0.1.50 --to db-b-private --wait`, naming the network interfaces.
3. On the source, run a pass until it succeeds: `sudo systemctl start ezgh-vpc-addresses-ready`. It removes the address.
4. On the destination, run a pass, then start the application.

After an assign or unassign, run a pass on that instance the same way, or let the timer do it.
No keepalived or Pacemaker integration is provided.

## Limits

| Limit | Value | |
| --- | --- | --- |
| VPCs per project | 5 | [Quota](/quotas/default-quotas#network) `network.vpcsPerProject`, up to 50 |
| Subnets per project | 50 | Quota `network.subnetsPerProject`, up to 1,000 |
| Network interfaces per project | 50 | Quota `network.networkInterfacesPerProject`; private interfaces count |
| Subnets per VPC | 256 | Fixed |
| Network interfaces per VPC | 1,000 | Fixed (`409 vpc_interface_limit`) |
| Private interfaces per instance | One per subnet, within the instance type's interface limit | Fixed |
| Secondary addresses per interface | 2, IPv4 and IPv6 together | Fixed |
| Delegated prefixes per interface | 16 IPv4 (/28) and 2 IPv6 (/80) | Fixed |
| Member prefixes per VPC | 5,000, delegated prefixes included | Fixed |
| Private addresses per VPC | 4,000: IPv4 and IPv6, primary and secondary (each interface's two primaries count), including addresses still being withdrawn | Fixed |
| MTU | 8900 | Fixed |

## IAM

| Action | On |
| --- | --- |
| `network.vpcs.list`, `network.vpcs.create` | The project |
| `network.vpcs.get`, `network.vpcs.update`, `network.vpcs.delete` | The VPC |
| `network.subnets.list`, `network.subnets.create` | The project |
| `network.subnets.get`, `network.subnets.update`, `network.subnets.delete` | The subnet |
| `network.networkInterfaces.create` | The project: creating an interface in a subnet needs nothing more |
| `network.networkInterfaces.assignPrivateAddress`, `unassignPrivateAddress` | The interface |
| `network.networkInterfaces.assignPrivatePrefix`, `unassignPrivatePrefix` | The interface |
| `network.networkInterfaces.reassignPrivateAddress` | Both interfaces |
| `network.networkInterfaces.get` | Each interface involved, to read an operation |
| `network.networkInterfaces.list` | The project, to list operations; the list keeps only those whose every interface you may get |
| `network.networkGateways.*` | See [Network Gateways](/private-networks/network-gateways#iam) |
| `network.routeTables.*` | See [Route tables](/private-networks/route-tables#iam); associating a subnet also needs `network.subnets.update` |

`NetworkFullAccess` has them all; `NetworkReadOnlyAccess` and `ReadOnlyAccess` have the list and
view actions. See [IAM](/compute/iam).

Source: https://docs.ezghcloud.com/private-networks/vpcs/index.mdx
