Networks

Private networks with address ranges, subnets and private names.

Overview

A network is a private space for your resources with its own address range. Resources in it reach each other by name; resources in different networks can’t reach each other.

With several machines, a network spans all of them.

When to use it

  • Keep a project’s database away from everything else.
  • Fixed addresses in a range you choose.
  • Subnets for apps and data.

How it works

Bridge networks
Each network is one Docker bridge network whose range is your CIDR.
Private DNS
Every resource answers to <name>.<kind>.internal inside its network.
WireGuard mesh
Across machines, a mesh container per machine carries the network over an encrypted tunnel.

Subnets are named ranges inside the network, so they reach each other directly. A network without internet has no route out. On two or more machines, every network exists on each of them with the same range, and a stand-in on each machine answers for resources that run on another.

Architecture

Networks architectureResources in one network reach each other by name, even on different machines.orders.database.internalencryptedapimachine mainMesh (WireGuard)mainMesh (WireGuard)rack-1ordersmachine rack-1
Resources in one network reach each other by name, even on different machines.
  • api to Mesh (WireGuard): orders.database.internal
  • Mesh (WireGuard) to Mesh (WireGuard): encrypted
  • Mesh (WireGuard) to orders

Flows

Reaching a database on another machine

  1. The app looks up orders.database.internal.
  2. On its machine, a stand-in answers with the database’s address.
  3. Packets cross the WireGuard tunnel to the database’s machine.

Set it up

In the console

  1. Open Networks and choose New network.
  2. Name it and give it a range like 10.20.0.0/16.
  3. Choose it in the forms of what you create next.

With the CLI

enclave network create backend --cidr 10.20.0.0/16 --wait

With OpenTofu

OpenTofu configuration
resource "enclave_network" "backend" {
  name = "backend"
  cidr = "10.20.0.0/16"
}

Settings reference

Every setting and output of the OpenTofu resource; the console and the CLI use the same names in their own words. Generated from platform 4d30582.

enclave_network
NameTypeUseWhat it does
cidrtextrequiredPrivate IPv4 range, /16 to /28, e.g. 10.40.0.0/16.
nametextrequiredName of the network: 3–40 lowercase letters, digits or hyphens, starting with a letter. Changing it replaces the network.
internettrue or falseoptionalRoute to the internet. Without it, nothing in the network can publish a host port.
projecttextoptionalThe project to create it in. Defaults to the provider's project (ENCLAVE_PROJECT, else default). Changing it replaces the resource.
subnetlist of objectsoptionalNamed ranges inside the network (default: one subnet covering it).
docker_networktextoutputThe engine network's name.
gatewaytextoutputThe network's gateway address.
idtextoutputResource ID.

Limits and security

Good to know

  • Ranges may not overlap another network or the default one.

Security

  • Networks are isolated from each other; tunnels between machines are encrypted.