Are you running a cluster of servers spread across AWS, DigitalOcean, or connecting your office to a datacenter? The first challenge is always getting those machines to communicate securely over a private network without hitting a bottleneck.
The most frustrating network issue I ever had to debug was intermittent packet loss that only showed up during peak hours. Back then, our team used a centralized VPN gateway to connect six servers together. Everything ran smoothly during the day. But every evening, database replication and log shipping traffic spiked to several hundred Mbps, overloading the gateway and making the entire cluster unstable.
The problem wasn’t the network bandwidth of individual servers—it was the architecture forcing all traffic through a single choke point. Ditching the centralized model for a Mesh VPN lets servers talk directly to one another, and Tinc VPN handles this cleanly.
Three Approaches to Building a Multi-Server Linux VPN
Before running any commands, let’s look at the three most common architectures today:
- Traditional Hub-and-Spoke (e.g., standard OpenVPN): Every client and server (Spoke) connects to a central server (Hub). Traffic from machine A to machine B must pass through the Hub.
- Manual Mesh (e.g., plain WireGuard): Each node must manually declare the full list of all other nodes (peers). You also have to manage allowed IP ranges (
AllowedIPs) and routing tables yourself. - Auto-Routing Mesh (Tinc VPN): Each node only needs the public address of one or a few bootstrap nodes. The Tinc daemon automatically exchanges the network topology, establishes direct peer-to-peer connections, and finds alternative routes around NAT or firewall restrictions.
Comparing Pros and Cons of Each Model
Choosing the wrong architecture from the start can easily force a complete rebuild once your infrastructure grows.
1. Hub-and-Spoke
- Pros: Easy to understand and simple to enforce firewall rules at a single point. Adding a new machine just means issuing a certificate and pointing it to the Hub.
- Cons: It creates both a bandwidth bottleneck and a Single Point of Failure. If the Hub goes down, your entire internal network goes with it. On top of that, latency can be absurd: two servers sitting next to each other in Singapore (with ~1–2 ms local ping) might have to route traffic through a Hub in the US (adding 180–200 ms).
2. Manual Mesh with WireGuard
- Pros: Runs in Linux kernel space for blazing-fast performance, easily hitting 10 Gbps+ on modern hardware. Configuration files are also very concise.
- Cons: The number of peer pairs you have to configure manually grows quadratically at
N(N-1)/2. With 5 servers, you configure 10 pairs; at 20 servers, that jumps to 190 pairs. Plain WireGuard also lacks dynamic routing: if the direct link from A to C drops, traffic won’t automatically reroute through B without setting up BGP or OSPF.
3. Auto-Routing Mesh with Tinc VPN
- Pros: Automatically discovers the entire network (full mesh). As long as two nodes connect to a shared intermediate node, Tinc will automatically punch through NAT for a direct connection—or relay packets through the intermediate node when facing symmetric NAT. It supports both Layer 3 (
router) and Layer 2 switch emulation (switch) for broadcast/multicast traffic. - Cons: Tinc runs in userspace over a TUN/TAP interface, so single-stream throughput typically tops out at a few hundred Mbps up to around 1–2 Gbps depending on your CPU. Splitting configuration across multiple small files in a directory structure can also feel unfamiliar to newcomers.
When Should You Choose Tinc VPN?
If you only have 2–3 servers with static public IPs and need to push tens of Gbps continuously, WireGuard wins hands down. On the other hand, choose Tinc VPN in the following scenarios:
- You have 4 or more nodes distributed across multiple locations, or machines sitting behind internal NATs where you can’t open public ports.
- You need high availability: when a direct link fails, the network must automatically reroute through another node without manual intervention.
- You want fast scaling: adding a new node only requires copying its host file to one running node, and the rest of the network syncs automatically.
Deploying Tinc VPN on Ubuntu/Debian
The example below builds a Mesh network named myvpn connecting two Ubuntu/Debian servers (CentOS/RHEL works the same way, just swap the package manager):
- node1: Public IP
203.0.113.10— VPN IP:10.10.0.1/24 - node2: Public IP
203.0.113.20— VPN IP:10.10.0.2/24
Don’t forget to open the default port 655 (both TCP and UDP) on the firewall of any machine with a public IP. Tinc uses TCP 655 for control plane metadata and UDP 655 for actual data transmission.
Step 1: Install the Tinc Package
Run the following commands on both node1 and node2 to install Tinc:
sudo apt update
sudo apt install -y tinc
Step 2: Create Directories and tinc.conf
Each VPN network in Tinc lives in its own directory under /etc/tinc/. Create the directory structure for myvpn on both machines:
sudo mkdir -p /etc/tinc/myvpn/hosts
Next, create the main configuration file /etc/tinc/myvpn/tinc.conf on node1:
sudo tee /etc/tinc/myvpn/tinc.conf <<EOF
Name = node1
AddressFamily = ipv4
Interface = tun0
Mode = router
ConnectTo = node2
EOF
Do the same on node2, making sure to swap Name and ConnectTo:
sudo tee /etc/tinc/myvpn/tinc.conf <<EOF
Name = node2
AddressFamily = ipv4
Interface = tun0
Mode = router
ConnectTo = node1
EOF
Setting Mode = router runs Tinc at Layer 3, which is the lightest option with the lowest overhead for server-to-server connections. Later, when you add node3, you only need to point ConnectTo at node1 or node2 and it will automatically join the entire mesh.
Step 3: Create Host Files and Generate RSA Keys
Tinc authenticates nodes using asymmetric key pairs stored in the hosts/ directory. On node1, create /etc/tinc/myvpn/hosts/node1:
sudo tee /etc/tinc/myvpn/hosts/node1 <<EOF
Address = 203.0.113.10
Subnet = 10.10.0.1/32
EOF
Generate a 4096-bit RSA key pair for node1 with the command below, pressing Enter twice to accept the default file paths:
sudo tincd -n myvpn -K4096
The private key is saved to /etc/tinc/myvpn/rsa_key.priv, while the public key is automatically appended to the end of /etc/tinc/myvpn/hosts/node1.
Repeat this process on node2:
sudo tee /etc/tinc/myvpn/hosts/node2 <<EOF
Address = 203.0.113.20
Subnet = 10.10.0.2/32
EOF
sudo tincd -n myvpn -K4096
Quick tip: For nodes behind NAT without a public IP, simply omit the Address = ... line from their host file and set them to ConnectTo a node that has a public IP.
Step 4: Write the tinc-up and tinc-down Scripts
Tinc itself only creates the virtual network interface—it doesn’t assign IP addresses. Configuring the IP and adding routes is handled by the tinc-up and tinc-down scripts.
Create both scripts on node1 and make them executable:
sudo tee /etc/tinc/myvpn/tinc-up <<'EOF'
#!/bin/sh
ip link set $INTERFACE up
ip addr add 10.10.0.1/32 dev $INTERFACE
ip route add 10.10.0.0/24 dev $INTERFACE
EOF
sudo tee /etc/tinc/myvpn/tinc-down <<'EOF'
#!/bin/sh
ip route del 10.10.0.0/24 dev $INTERFACE
ip addr del 10.10.0.1/32 dev $INTERFACE
ip link set $INTERFACE down
EOF
sudo chmod +x /etc/tinc/myvpn/tinc-up /etc/tinc/myvpn/tinc-down
Do the exact same thing on node2, replacing 10.10.0.1/32 with 10.10.0.2/32.
Step 5: Exchange Host Files Between Nodes
Both machines need each other’s host file containing the public key to trust the connection. Never copy rsa_key.priv off its original machine.
# Send the host file from node1 to node2 (or copy/paste manually)
scp /etc/tinc/myvpn/hosts/node1 [email protected]:/tmp/node1
# On node2, move the file into the hosts directory
sudo mv /tmp/node1 /etc/tinc/myvpn/hosts/node1
Do the reverse to copy /etc/tinc/myvpn/hosts/node2 into /etc/tinc/myvpn/hosts/ on node1.
Step 6: Start the Service and Verify Connectivity
Enable and start the tinc@myvpn service via systemd on both machines:
sudo systemctl enable --now tinc@myvpn
Check that the service is running and the virtual interface tun0 has its IP assigned:
sudo systemctl status tinc@myvpn
ip addr show tun0
From node1, try pinging the internal VPN IP of node2:
ping -c 4 10.10.0.2
If packets come back steadily, your tunnel is up. To inspect the list of online nodes or check whether Tinc is routing directly or relaying, send a USR2 signal to the process and read the logs:
sudo systemctl kill -s USR2 tinc@myvpn
sudo journalctl -u tinc@myvpn -n 30 --no-pager
In the logs, the Nodes and Edges sections list all connected nodes along with their reachability status. From here on, your server cluster has an auto-routing private network that no longer depends on any central gateway.
