How to Set Up a Private Network Between Multiple VPS Instances

When running multiple VPS instances that need to communicate (a web server and a separate database server, for example), routing that traffic over the public internet is both slower and less secure than using a private network. This guide covers the common approaches.

Why Use a Private Network

  • Traffic between your servers never traverses the public internet
  • Typically faster and lower latency than public routing
  • Reduces exposed attack surface — database ports don't need to be publicly reachable at all
  • Often free (no bandwidth charges) between instances in the same provider network

Option 1 — Provider-Native Private Networking

Many VPS providers offer a private networking feature that connects your instances (within the same account/region) via an internal, non-public network interface. Check your provider's control panel for a "Private Network" or "Internal Network" option when provisioning instances.

Once enabled, each server gets a second network interface with a private IP (typically in the 10.x.x.x or 192.168.x.x range):

ip addr show

Option 2 — WireGuard VPN Between Servers

If your provider doesn't offer native private networking, or your servers are with different providers, set up a WireGuard tunnel between them — see How to Set Up a WireGuard VPN Server on a Linux VPS, treating one server as the "server" and others as "clients," or configuring a full mesh for more than two servers.

Option 3 — SSH Tunneling (Simple, Temporary Use Cases)

ssh -L 3306:localhost:3306 deploy@DATABASE_SERVER_IP

Useful for occasional manual access, but not a substitute for a persistent private network for production traffic.

Configuring Services to Use the Private Network

Once a private network exists, bind services to the private IP instead of the public one:

MySQL example (bind to private IP only):

sudo nano /etc/mysql/mysql.conf.d/mysqld.cnf
bind-address = 10.0.0.5

Then connect from your application server using that private IP instead of the public one.

Firewall Rules for Private Networking

Even on a private network, apply firewall rules restricting which specific private IPs can reach sensitive services:

sudo ufw allow from 10.0.0.10 to any port 3306

Verifying Private Connectivity

ping 10.0.0.5

From the application server, targeting the database server's private IP.

Common Architecture: Web + Database Separation

ServerPublic IP UsePrivate IP Use
Web/App ServerServes HTTP/HTTPS to visitorsConnects to database over private network
Database ServerNo public exposure neededOnly reachable from app server's private IP

Common Errors

Private network interface not appearing — confirm private networking was actually enabled for this instance in your provider's control panel, sometimes requiring the instance to be recreated or explicitly attached.

Services still using public IP despite private network being available — explicitly reconfigure the service's bind address and update the application's connection string.

Best Practices

  • Never expose a database directly to the public internet if a private network option exists
  • Combine private networking with firewall rules restricting exactly which private IPs can connect
  • Verify private connectivity works before removing any public-facing fallback access during migration

Continue Reading

Browse more articles in Networking & DNS.

  • private network, vps internal network, database isolation, multi-server setup
  • 0 Els usuaris han Trobat Això Útil
Ha estat útil la resposta?

Articles Relacionats

DNS Fundamentals: A, AAAA, CNAME, MX, TXT & NS Records Explained

DNS translates human-readable domain names into the information servers actually need — IP...

How to Point a Domain to Your VPS (A/AAAA Records)

Before your website is reachable at yourdomain.com instead of a raw IP address, you need to...

How to Configure MX Records for Email Delivery

MX (Mail Exchange) records tell the internet which servers handle incoming email for your domain....

How to Use CNAME Records Correctly

CNAME records let you alias one domain name to another, but they come with important restrictions...

How to Configure a Static IP on a Linux VPS

Most VPS providers assign a static (unchanging) IP address by default, but understanding how...