# How to Create a VPC Peering 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. VPC peering joins two VPC networks with a secure, private connection. This allows resources in those networks to connect to each other’s private IP addresses as if they were in the same network. VPC peering is available across all regions and enables routing between any two VPC networks. The one exception is that peering between datacenters is not available in BLR1. Peering works with the following resources: - **Droplets** - Droplets created after 2 October 2024 on a peered VPC network are configured for peering automatically. If you add a peering to an existing Droplet’s VPC network, restart the Droplet’s networking stack to add the necessary peering route information. See [How to Update Droplet Routes to Enable VPC Peering](https://docs.digitalocean.com/products/networking/vpc/how-to/update-peering-routes/index.html.md) for instructions. - Droplets created before 2 October 2024 must be updated manually to enable peering traffic. See [How to Update Droplet Routes to Enable VPC Peering](https://docs.digitalocean.com/products/networking/vpc/how-to/update-peering-routes/index.html.md) for instructions. - **Managed Databases** - All managed databases are compatible with VPC peering. - **Managed Kubernetes (DOKS)** - Worker nodes created after 2 October 2024 on a peered VPC network are configured for peering automatically. If you created the nodes before this date, or added your first peering connection after the nodes were created, recycle your worker nodes to add the new peering routes. ## Create a VPC Peering Using the CLI The VPC peering creation command requires you to provide two VPC network IDs for the `--vpc-ids` flag. Use [`doctl vpcs list`](https://docs.digitalocean.com/reference/doctl/reference/compute/region/list/index.html.md) command to retrieve a list of your VPC networks and their IDs. ## How to Create a VPC Peering 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 peerings create`. Basic usage looks like this, but you can [read the usage docs](https://docs.digitalocean.com/reference/doctl/reference/vpcs/peerings/create/index.html.md) for more details: ```shell doctl vpcs peerings create [flags] ``` The following example creates a VPC Peering named `example-peering-name` : ```shell doctl vpcs peerings create example-peering-name --vpc-ids f81d4fae-7dec-11d0-a765-00a0c91e6bf6,3f900b61-30d7-40d8-9711-8c5d6264b268 ``` ## Create a VPC Peering Using the API The VPC peering creation call requires you to provide two VPC network IDs for the `vpc_ids` field. Use the [`/v2/vpcs`](https://docs.digitalocean.com/reference/api/reference/vpcs/index.html.md#vpcs_list) endpoint to retrieve a list of your VPC networks and their IDs. ## How to Create a VPC Peering 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/vpc_peerings`](https://docs.digitalocean.com/reference/api/reference/vpc-peerings/index.html.md#vpcPeerings_create). ### cURL Using cURL: ```shell curl -X POST \ -H "Content-Type: application/json" \ -H "Authorization: Bearer $DIGITALOCEAN_TOKEN" \ -d '{"name": "my-first-vpc-peering", "vpc_ids": [ "997615ce-132d-4bae-9270-9ee21b395e5d", "e51aed59-3bb1-4a6a-8de0-9d1329e9c997"]}' \ "https://api.digitalocean.com/v2/vpc_peerings" ``` ## Create a VPC Peering Using the Control Panel To create a VPC peering, click **Networking** in the main menu, then click the **VPC** tab. In the **VPC** tab, click **Actions** then **Create a Peering Connection** to open the **Create VPC Peering** window. In the **Create VPC Peering** window, select a VPC network, and a second VPC network to peer it with. The VPC selection fields update to show matching VPCs as you type. Create a name for the peering or use the default generated name, then click **Create peering connection** to finish. ## View a VPC’s Peering Connections To view a VPC network’s peering connections, click **Networking** in the main menu, then click the **VPC** tab. Peering connections are listed under the **Connections** column in the **VPC Networks** list. You can also click an individual VPC network to go to its details page, then click the **Peering Connections** tab. All active connections are listed, and you can click **Create a Peering Connection** to peer another network to this VPC.