Private networking explained
A private network is a set of addresses that only your own machines can reach, so internal traffic such as database queries never sits on a public port. CheapVPS servers come with a public IPv4 and an IPv6 /64 and no private network product; you get the same result in the OS with an encrypted WireGuard overlay, services bound to the tunnel address and a firewall that closes the public side.
Networking and security guide, updated 2026-12-03
What is a private network in plain terms?
Think of two kinds of addresses. A public address such as 203.0.113.10 is routed across the whole internet, so anyone can try to open a connection to it. A private address comes from ranges set aside for internal use: 10.0.0.0/8, 172.16.0.0/12 and 192.168.0.0/16 for IPv4, and unique local addresses under fd00::/8 for IPv6. Routers on the internet do not carry these ranges, so a service listening only on a private address is invisible from outside.
A private network, then, is a group of machines that share one of those ranges and can talk to each other on it. In an office it is a switch and a cable. Between rented servers in data centres it is almost always a virtual construct: packets travel over the same physical wires as everything else, but they are wrapped, separated or encrypted so that only members can read and send them.
The value is not the address range itself. The value is a clear boundary: public ports for the things the world should reach, private addresses for everything else.
What are subnets, routes and gateways?
A subnet is a block of addresses written with a prefix length. 10.20.0.0/24 holds 256 addresses from 10.20.0.0 to 10.20.0.255; the /24 says the first 24 bits are fixed. Machines in the same subnet expect to reach each other directly.
A route is a rule in the kernel that says where packets for a destination should go. Show the table with:
ip route
ip -6 routeA typical fresh server prints a default via ... line, which is the gateway: the next hop for any address that no more specific route covers. When you add a WireGuard interface with 10.20.0.1/24, a new line such as 10.20.0.0/24 dev wg0 appears, telling the kernel that everything in that block goes into the tunnel instead of out through the default gateway.
Most private networking problems are route problems in disguise. If a ping to a private address leaves through eth0, the kernel simply does not know the tunnel covers that address. ip route get 10.20.0.2 answers that question in one line.
Why do people want server traffic off the public internet?
The classic case is a web server and a database on separate machines. The database must accept connections from the web server, but nobody else should ever reach port 5432 or 6379. With only public addresses, the database has to listen on its public IP, and its safety then rests on a firewall rule and a password. One mistake in either and the database is open to scanners that sweep every address many times a day.
Other reasons come up often:
- Encryption by default. Many internal protocols, from Redis to older replication setups, send data in clear text unless you configure TLS for each one. A tunnel encrypts all of them at once.
- One place to manage trust. A peer either has a valid key or it does not. Adding a server means adding one key, not editing allow lists in five daemons.
- Stable internal names. Tunnel addresses stay the same even if you move a server to another city and its public IP changes.
- Smaller attack surface. Admin panels, metrics endpoints and message queues can listen only on the private side.
Does CheapVPS have a private network option?
The console has no private network, VLAN or internal interface button. Each server gets exactly one public IPv4 address and an IPv6 /64, and that is the whole network setup at creation. This is deliberate: it keeps plans simple and lets you run the same private layout across any mix of our 15 cities, which a data centre VLAN could not do anyway.
What you do instead is build the private layer in the OS. Linux has had the tools for years, and the result behaves like a private network from the point of view of your applications. The rest of this page explains the three building blocks; the step by step setup lives in Private link with WireGuard.
How does an encrypted overlay work?
An overlay is a virtual network laid on top of the public one. Each server gets a second interface, usually wg0, with a private address such as 10.20.0.1. When an application sends a packet to 10.20.0.2, the kernel routes it to wg0; WireGuard encrypts it, wraps it in a UDP packet addressed to the other server public IP, and sends that over the internet. The receiving side checks the key, decrypts, and hands the inner packet to its own wg0.
WireGuard is the usual choice because it is part of the Linux kernel, configuration fits in a dozen lines, and it uses modern cryptography with no options to get wrong. In a mesh, every server lists every other server as a peer, so any two machines talk directly. In a hub and spoke layout, all peers connect to one central server that forwards between them; simpler to manage, but the hub becomes a bottleneck and a single point of failure.
For two to about ten servers a full mesh is easy to maintain by hand. Beyond that, people script the config generation or use a mesh manager built on WireGuard.
Why bind services to the tunnel address?
A daemon that listens on 0.0.0.0 accepts connections on every interface, including the public one. Binding it to the tunnel address means the public interface simply has nothing listening on that port. Even if the firewall were turned off by accident, the service would stay unreachable from outside.
Check what is listening and where:
ss -tlnpLines with 0.0.0.0:5432 or [::]:6379 are listening everywhere. After the change you want to see 10.20.0.1:5432 and 127.0.0.1:5432 instead. The exact settings for PostgreSQL and Redis are in the WireGuard guide.
One catch: a service that binds to 10.20.0.1 fails to start if wg0 is not up yet. Order the units with a systemd drop-in so the tunnel starts first, as shown in the guide.
What does the firewall do on the public side?
The firewall is the second wall. On each server, allow SSH, the public ports your site needs, and UDP 51820 for WireGuard, and drop everything else that arrives on the public interface. Traffic arriving on wg0 can be trusted more, but it is still worth limiting it to the ports you actually use.
ufw default deny incoming
ufw allow 22/tcp
ufw allow 51820/udp
ufw allow in on wg0 to any port 5432 proto tcp
ufw enableRestricting UDP 51820 to the public IPs of your other servers is a further step; WireGuard already ignores packets that are not signed by a known key, so the open port reveals almost nothing. Read Firewall rules explained for the concepts and Firewall setup for a quick baseline.
Does traffic between your servers count toward the monthly allowance?
Yes. Because the tunnel runs over public addresses, every packet one server sends to another is outgoing traffic for the sender, the same as a reply to a website visitor. Incoming traffic is free, so a database that receives queries pays nothing for the queries, but the result sets it sends back count against its own allowance.
WireGuard adds a small overhead per packet (about 60 bytes on IPv4 and 80 on IPv6), which is negligible for normal workloads. For a rough budget, a P4 server in Europe includes 20 TB of outgoing traffic each month, and extra transfer costs $0.72 per TB in Europe and North America. Replication of a large database or nightly copies of backups between cities are the jobs that usually move the needle; measure them with vnstat -i wg0 for a week before you size anything.
Placing chatty servers in the same city does not make the traffic free, but it does make it fast: round trips inside one data centre are far shorter than between continents.
Which layout should you start with?
For a typical two or three server stack, start like this:
- One WireGuard mesh with a
/24from10.x, one address per server, written down in a small table. - Databases, caches and queues bound to
127.0.0.1and their tunnel address only. - Public ports open only on the machines that serve the public: the web server or the reverse proxy.
- SSH open on all servers, protected with keys as in SSH hardening.
That design survives growth well. A new app server gets a key and a tunnel address, and the database allow list already covers the whole /24. If you later add a load balancer, it sits in the same mesh and talks to the app servers over their private addresses; see Load balancing explained.
Questions about this guide
Can two CheapVPS servers share a private VLAN?
No. Each server has its own public addresses only. Join them with a WireGuard tunnel, which works the same in one city or across continents, and follow the step by step guide.
Which private range should I use for the tunnel?
Pick a /24 inside 10.0.0.0/8 that does not clash with your home or office network, for example 10.20.0.0/24. Avoid 192.168.0.0/24 and 192.168.1.0/24, which many home routers already use.
Is WireGuard fast enough for database traffic?
For almost every small and medium workload, yes. Encryption runs in the kernel and the added latency is tiny compared with the network round trip itself. CPU use grows with throughput, so a very busy link benefits from a plan with more vCPUs.
Can I use IPv6 inside the tunnel?
Yes. Give each peer an address from a unique local range such as fd20::/64 next to the IPv4 one, and list both in AllowedIPs. The tunnel itself can also run over the public IPv6 addresses.
Does the tunnel protect me if a server is compromised?
Only partly. An attacker with root on one peer can use its key to reach the others. Keep per-service passwords, limit which tunnel ports each server may reach, and rotate the key of any machine you no longer trust.
Do I need the WireGuard app image?
No. The WireGuard image is set up for personal VPN use, but any Ubuntu, Debian, Rocky or Alma server can install the tools with one package command and join a mesh.
More in Networking and security
- IPv4 and IPv6 addresses
- Add IPv6 addresses
- Static network setup
- Reverse DNS (PTR)
- Networking terms
- How the VPS network works
- How DNS works
- Private link with WireGuard
- Failover and floating IPs
- Firewall rules explained
- Load balancing explained
- HAProxy load balancer
- TLS certificates explained
- SSH hardening
- Firewall setup
- Point a domain