How to set up VPC networking on DigitalOcean
Setting up VPC networking on DigitalOcean involves creating a Virtual Private Cloud through the networking panel, configuring IP ranges, and connecting droplets to the VPC for secure internal communication. This allows resources to communicate privately without using public internet traffic.
Prerequisites
- Active DigitalOcean account
- Basic understanding of networking concepts
- SSH key configured for droplet access
- Familiarity with DigitalOcean control panel
Step-by-Step Instructions
Access the VPC Section
Create a New VPC
Configure IP Range and Settings
10.116.0.0/20). You can customize this range based on your needs. Leave the Description field optional or add notes about the VPC's purpose.Review and Create VPC
Create Droplets in the VPC
Configure Droplet Networking
ssh root@your-droplet-ip to verify network configuration.Test VPC Connectivity
ping 10.116.0.x Replace the IP with your target droplet's private VPC IP address. Successful pings confirm proper VPC networking setup.Add Existing Resources to VPC
Common Issues & Troubleshooting
Droplets cannot communicate within VPC
Check that both droplets are in the same VPC network and region. Verify firewall settings allow internal traffic and ensure you're using private IP addresses for communication.
VPC creation fails with IP range error
Ensure you're using valid private IP ranges in CIDR notation. Avoid conflicts with existing VPCs in the same region by choosing different IP ranges like 10.117.0.0/20.
Cannot add existing droplet to VPC
Verify the droplet is in the same region as the VPC. Some older droplets may not support VPC networking - consider creating new droplets if the option is unavailable.
High data transfer costs between droplets
Ensure you're using private VPC IP addresses for internal communication instead of public IPs. Traffic within a VPC doesn't incur bandwidth charges between droplets in the same datacenter.