On this page
Networks and subnets
Networks are private layer-2 segments for your instances; subnets give them IP address ranges. Together they define how your resources reach each other before anything touches the internet.
Every project starts with room to build its own private topology. A network is an isolated broadcast domain, and a subnet is the address plan you lay on top of it. An instance attached to a network gets a fixed IP from one of that network's subnets and can talk to any other instance on the same network without leaving Patrii Cloud.
Networks stay private until you connect them to a router with an external gateway. This is deliberate: you decide exactly when and how traffic leaves your project, which keeps a database tier or an internal service unreachable from the internet by default.
Key concepts
Network — An isolated layer-2 segment. Instances on the same network share a broadcast domain.
Subnet — An IP address plan (a CIDR range) bound to a network, with a gateway and optional DHCP.
CIDR — The notation for an address range, for example 10.0.0.0/24 (256 addresses).
DHCP — The service that automatically hands a fixed IP from the subnet to each instance as it boots.
Fixed IP — The private address an instance holds on a network, drawn from the subnet's range.
Before you start
- A project with available network quota.
- A rough address plan so subnets do not overlap with each other or with networks you plan to connect over a VPN.
Step by step
- Open Networks
Go to Networking and open Networks to see the networks already in your project.
Screenshot — The Networks list with the Create network buttonThe Networks list with the Create network button - Create the network
Choose Create network and give it a clear name such as
app-tierordata-tier.Screenshot — The Create network formThe Create network form - Add a subnet
- Add a subnet and enter a CIDR range that does not overlap anything else you run.
- Leave DHCP enabled so instances receive an address automatically.
- Optionally set custom DNS resolvers for instances on the subnet.
Screenshot — The subnet form showing the CIDR and DHCP fieldsThe subnet form showing the CIDR and DHCP fields - Attach instances
When you create an instance, select this network so it joins the segment. An instance can attach to more than one network.
Examples
patrii network create --name app-tier \ --cidr 10.10.0.0/24 --subnet-name app-tier-a patrii subnet create --network app-tier --name app-tier-b \ --cidr 10.10.1.0/24 --dhcp
patrii network list patrii subnet list --network <network-id>
resource "patrii_network" "app" {
name = "app-tier"
}
resource "patrii_subnet" "app" {
network_id = patrii_network.app.id
name = "app-tier-a"
cidr = "10.10.0.0/24"
enable_dhcp = true
}Limits & specifications
Common subnet settings:
| Setting | What it controls |
|---|---|
CIDR | The address range, e.g. 10.10.0.0/24. Plan it so subnets never overlap. |
Gateway | The subnet's default gateway address, used for routing off the subnet. |
DHCP | When on, instances get a fixed IP automatically at boot. |
DNS resolvers | The resolvers instances on the subnet use for name resolution. |
Best practices
- Plan CIDRs up front and avoid overlap with any network you may later join over a VPN or router.
- Separate tiers onto their own networks (web, app, data) so security groups and routing stay simple.
- Keep private-only tiers off any router with an external gateway.
- Use short, descriptive network names so they read well in the console and in automation.
FAQ
Can an instance be on more than one network?
Do instances on the same network need a router to talk?
Why can't my instance reach the internet after I attached it?
Learn more
Everything you can do here in the console is also available through the Patrii Cloud API for automation and scripting.