Skip to content

Setting up a private network between cloud instances

Two cloud instances need to talk without going over the public internet. Here is how we actually wire up a private network on Virtuozzo Cloud Compute.

You have an application VM and a database VM in the same project and region. The application is reaching the database over the public IP. It works, it is billable as egress, and it is the wrong topology. The fix is a private network between the two instances — what Virtuozzo calls an internal network — plus some routing hygiene.

What’s happening

By default, a new Cloud Compute instance gets one public-facing NIC. Two instances in the same project can reach each other over public IPs, and that traffic is counted, routed through the edge, and exposed. A private network is a separate Layer 2 segment scoped to your project. Instances attached to it get an additional NIC on a private CIDR (we typically use 10.10.0.0/24) and can speak directly without leaving the hypervisor fabric. The public NIC stays for inbound traffic and outbound updates; the private NIC carries app-to-database, app-to-cache, and app-to-app traffic.

How to verify

Before changing anything, confirm the current path. From the application VM:

ip -br addr
ip route get <db-public-ip>
mtr -n -c 20 <db-public-ip>

If the route shows the default gateway and mtr shows more than one hop, traffic is leaving the host. After attaching the private NIC, the same ip route get <db-private-ip> should resolve directly through the private interface with zero intermediate hops.

To confirm the database is actually listening on the private interface:

ss -ltnp | grep 5432

A bind on 0.0.0.0:5432 will accept private traffic, but a bind on the public IP only will not. Re-bind to the private IP or to 0.0.0.0 and restrict access at the firewall.

The fix

  1. In the Cloud Compute panel, create a private network in the project and attach both instances to it. Note the assigned private IPs.
  2. On each instance, bring up the new interface (ip link set ens4 up, then DHCP or static, depending on what the panel issued) and persist the configuration in /etc/netplan/ or /etc/network/interfaces.d/.
  3. Update the application’s database connection string to the database’s private IP. Do not leave the public IP as a fallback — it will silently mask future routing breakage.
  4. Tighten the database firewall to drop 5432/3306 from the public NIC entirely. The only path in is now the private network.

The egress line on next month’s bill drops, latency between the tiers drops, and the database stops being exposed to the internet on a port it never needed to be.

If you want this done as part of an environment build-out, our Cloud Compute service includes private networking in the standard topology — talk to us.