# How to Create a Network

Source: https://docs.quake.ai/docs/network/how-to/create-network
Markdown: https://docs.quake.ai/docs/network/how-to/create-network.md

---

# How to create a network

Create a private network with a subnet to connect your instances. Each network requires at least one subnet that defines the IP address range, DNS servers, and gateway settings.

<PrerequisiteBlock methods={["console", "cli", "api", "terraform"]} />

## Create the network and subnet

<MethodTabs>
<Method label="Console">

1. Select **Network** > **Networks** > **Create Network**.
2. Enter a **Network Name** and an optional **Description**.
3. Leave the **Create Subnet** checkbox selected (the default) and fill in the subnet fields:
    - **Subnet Name**: a name for the subnet.
    - **IP Version**: combobox defaulting to `ipv4`.
    - **CIDR**: a private address range such as `10.0.0.0/8`, `172.16.0.0/12`, or `192.168.0.0/16`.
    - **DNS**: a multi-line field that takes one DNS server address per line. For a public DNS, enter Cloudflare's `1.1.1.1` and `1.0.0.1` on separate lines. Comma- or space-separated addresses fail validation.
4. Select **OK** to create the network.

**Advanced Options**

Select **Expand Advanced Options** to reveal:

- **Disable Gateway** (off by default; enabling this prevents the subnet from having a default gateway, an inverse-toggle: checking it disables the gateway).
- **Gateway IP** (the address that acts as the subnet's default gateway when the toggle above is off).
- **DHCP** (`Enabled` / `Disabled` radio buttons; default `Enabled`).
- **Allocation Pools** (the in-subnet IP ranges Neutron may hand out).
- **Host Routes** (static routes injected into instance DHCP leases).
- **MTU** (leave blank for the default).
- **Port Security Enabled** (enabled by default; when disabled, the network bypasses all anti-spoofing and security-group enforcement at the port level). Security groups themselves attach to ports and are managed on **Network** > **Security Groups**; this field controls the network-level default for port security, not security-group selection.

</Method>
<Method label="CLI">

Create the network:

```bash
openstack network create my-network
```

Create a subnet on the network with DNS servers:

```bash
openstack subnet create \
  --network my-network \
  --subnet-range 192.168.1.0/24 \
  --dns-nameserver 1.1.1.1 \
  --dns-nameserver 1.0.0.1 \
  my-subnet
```

You should see output confirming the subnet was created, including the assigned `id`, `network_id`, and `cidr`.



To disable DHCP or set a specific gateway, add `--no-dhcp` or `--gateway YOUR_GATEWAY_IP` to the subnet create command. Run `openstack subnet create --help` for all options.



</Method>
<Method label="API">

Create the network:

```bash
curl -X POST "$OS_NETWORK_URL/v2.0/networks" \
  -H "X-Auth-Token: $OS_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "network": {
      "name": "my-network",
      "admin_state_up": true
    }
  }'
```

The response includes the network `id`. Use it to create a subnet:

```bash
curl -X POST "$OS_NETWORK_URL/v2.0/subnets" \
  -H "X-Auth-Token: $OS_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "subnet": {
      "network_id": "NETWORK_ID",
      "name": "my-subnet",
      "ip_version": 4,
      "cidr": "192.168.1.0/24",
      "dns_nameservers": ["1.1.1.1", "1.0.0.1"]
    }
  }'
```




```python
import openstack

conn = openstack.connect(cloud="rumble")

network = conn.network.create_network(name="my-network")

subnet = conn.network.create_subnet(
    network_id=network.id,
    name="my-subnet",
    ip_version=4,
    cidr="192.168.1.0/24",
    dns_nameservers=["1.1.1.1", "1.0.0.1"],
)

print(f"Network: {network.id}")
print(f"Subnet: {subnet.id}")
```




</Method>
<Method label="Terraform">

```hcl
resource "openstack_networking_network_v2" "my_network" {
  name           = "my-network"
  admin_state_up = true
}

resource "openstack_networking_subnet_v2" "my_subnet" {
  name       = "my-subnet"
  network_id = openstack_networking_network_v2.my_network.id
  cidr       = "192.168.1.0/24"
  ip_version = 4

  dns_nameservers = ["1.1.1.1", "1.0.0.1"]
}
```

See the [simple VM template](/resources/iac-templates/simple-vm) for a complete example that includes network, subnet, router, and instance resources.

</Method>
</MethodTabs>

## Verify the result

<MethodTabs>
<Method label="Console">

Navigate to **Network** > **Networks**. The new network appears in the list with its associated subnet.

</Method>
<Method label="CLI">

```bash
openstack network list
openstack subnet list --network my-network
```

</Method>
<Method label="API">

```bash
curl -s "$OS_NETWORK_URL/v2.0/networks?name=my-network" \
  -H "X-Auth-Token: $OS_TOKEN" | python3 -m json.tool
```

</Method>
<Method label="Terraform">

```bash
tofu show
```

The network and subnet resources appear in the state output.

</Method>
</MethodTabs>

## See also

- [Network API Reference](/reference/network): full parameter documentation for the Network API
- [Network CLI reference](/reference/network/cli)
- [Network API reference](/reference/network/api)
- [How to create a router](/docs/network/how-to/create-router)
- [How to create a security group](/docs/network/how-to/create-security-group)
- [Network console](/reference/network/console/index)
- [Network service](/docs/network/index)
