# How to Create a VPC A Virtual Private Cloud (VPC) is a private network interface for collections of DigitalOcean resources. VPC networks are inaccessible from the public internet and other VPC networks, and traffic on them doesn’t count against bandwidth usage. You can link VPC networks to each other using VPC peering connections. ## Create a VPC Network Using the CLI The VPC creation command requires you to provide a datacenter region for the `--region` flag. Use [`doctl compute region list`](https://docs.digitalocean.com/reference/doctl/reference/compute/region/list/index.html.md) command to retrieve a list of available datacenter regions. ## How to Create a VPC Network Using the DigitalOcean CLI 1. [Install `doctl`](https://docs.digitalocean.com/reference/doctl/how-to/install/index.html.md), the official DigitalOcean CLI. 2. [Create a personal access token](https://docs.digitalocean.com/reference/api/create-personal-access-token/index.html.md) and save it for use with `doctl`. 3. Use the token to grant `doctl` access to your DigitalOcean account. ```shell doctl auth init ``` 4. Finally, run `doctl vpcs create`. Basic usage looks like this, but you can [read the usage docs](https://docs.digitalocean.com/reference/doctl/reference/vpcs/create/index.html.md) for more details: ```shell doctl vpcs create [flags] ``` The following example creates a VPC network named `example-vpc` in the `nyc1` region: ```shell doctl vpcs create --name example-vpc --region nyc1 ``` ## Create a VPC Network Using the API The VPC creation call requires you to provide a datacenter region for the `region` field. Use the [`/v2/regions`](https://docs.digitalocean.com/reference/api/digitalocean/index.html.md#operation/regions_list) endpoint to retrieve a list of available datacenter regions. ## How to Create a VPC Network Using the DigitalOcean API 1. [Create a personal access token](https://docs.digitalocean.com/reference/api/create-personal-access-token/index.html.md) and save it for use with the API. 2. Send a POST request to [`https://api.digitalocean.com/v2/vpcs`](https://docs.digitalocean.com/reference/api/digitalocean//index.html.md#operation/vpcs_create). ### cURL Using cURL: ```shell curl -X POST \ -H "Content-Type: application/json" \ -H "Authorization: Bearer $DIGITALOCEAN_TOKEN" \ -d '{"name":"my-new-vpc", "region":"nyc1", "ip_range": "10.10.10.0/24"}' \ "https://api.digitalocean.com/v2/vpcs" ``` ### Go Using [Godo](https://github.com/digitalocean/godo), the official DigitalOcean API client for Go: ```go import ( "context" "os" "github.com/digitalocean/godo" ) func main() { token := os.Getenv("DIGITALOCEAN_TOKEN") client := godo.NewFromToken(token) ctx := context.TODO() createRequest := &godo.VPCCreateRequest{ Name: "my-new-vpc", RegionSlug: "nyc1", IPRange: "10.10.10.0/24", } vpc, _, err := client.VPCs.Create(ctx, createRequest) } ``` ### Python Using [PyDo](https://github.com/digitalocean/pydo), the official DigitalOcean API client for Python: ```python import os from pydo import Client client = Client(token=os.environ.get("DIGITALOCEAN_TOKEN")) req = { "name": "env.prod-vpc", "description": "VPC for production environment", "region": "nyc1", "ip_range": "10.10.10.0/24" } resp = client.vpcs.create(body=req) ``` ## Create a VPC Network Using the Control Panel To create a VPC network, click **Networking** in the main menu, then click the **VPC** tab. In the **VPC** tab, click **Create VPC Network**. ![VPC Networks page showing a VPC network and its datacenter region, including the VPC name, and IP range.](https://docs.digitalocean.com/screenshots/vpc/overview.69056a8522251a5d03c57a21545c544a303f8d7c78d94b34dfc7601e8d939d18.png) On the **Create VPC Network** page, select a datacenter region for the VPC network. Any resources you add to the VPC network need to be in the network’s datacenter region. Under **Configure Private IP Range**, choose how you want your IP range to be generated. We strongly recommended **Generate an IP range for me** to save time calculating IP ranges and prevent your network ranges from overlapping. If you select **Configure my own IP range**, see [Planning Your Network Size](https://docs.digitalocean.com/products/networking/vpc/concepts/plan-your-network/index.html.md) for more information about how to plan the size and range of your VPC network. The IP range of your VPC network can’t overlap with the ranges other networks in your account. The control panel prevents you from creating networks with overlapping ranges. In the **Choose a name and description** section, name the VPC network and optionally add a description of it, then click **Create VPC network**. Once the VPC network is created, you can create new resources in the network. VPC networks currently support Droplets, managed databases, load balancers, and Kubernetes clusters. You can also [migrate existing managed databases and Droplets to a VPC network](https://docs.digitalocean.com/products/networking/vpc/how-to/migrate-resources/index.html.md), but currently cannot migrate Kubernetes clusters and load balancers.