How to Connect Two Raff VMs with a Private VPC Network

Aybars Altınyay
Aybars Altınyay
Platform Engineer & Technical Writer
BeginnerUpdated Nov 17, 202617 min read~30 minutes total
VPCPrivate NetworkingUbuntu 24.04NetworkingSecurityCloud Architecture
Last reviewed:
Tutorial
How to Connect Two Raff VMs with a Private VPC Network
rafftechnologies.com/learn
On this page

Prerequisites

  • Two Raff Ubuntu 24.04 VMs with SSH and sudo access, access to Raff VPC settings, a planned non-conflicting RFC 1918 CIDR, and host firewall access

Put your app and database servers on one private network.

Tested on 2 vCPU and 4 GB RAM: $17.99 a month

  1. 1Pick a Linux imageUbuntu, Debian and more, with your SSH key added.
  2. 2Choose a sizeFrom $4.99 a month. Resize when your app grows.
  3. 3Connect over SSHYour server is up in about 55 seconds.

Ubuntu, Debian and other Linux distributions with full root and SSH access, up and running in about 55 seconds.

Connecting two Raff VMs over a private VPC lets the servers communicate on private IPv4 addresses instead of exposing every service on public interfaces. A typical use case is a public application VM talking to a database, cache, worker, or internal API over the VPC while only the public edge accepts internet traffic.

This tutorial uses two Ubuntu 24.04 VMs in one Raff VPC. You will create or select a private CIDR, attach both VMs, identify the private interfaces without assuming they are named eth1, verify the Linux route that carries private traffic, allow only a temporary test flow through your firewalls, measure connectivity with iperf3, and then apply the same pattern to an application-to-database connection.

Raff VPC provides private networking between attached resources. Check Raff VPC for the current network features, CIDR support, traffic policy, and performance specifications rather than treating a tutorial as the source of truth for commercial or infrastructure limits. Actual throughput also depends on the VM, guest networking, protocol, CPU, and test method. Private-network isolation also does not mean application traffic is cryptographically encrypted, so continue using TLS or another secure protocol when your threat model requires encryption in transit.

Prerequisites:

  • Two Raff VMs running Ubuntu 24.04 with SSH access
  • A non-root sudo user on both VMs
  • Access to Raff VPC/networking settings in the dashboard
  • A planned RFC 1918 CIDR that does not conflict with networks you may later connect through VPN or peering
  • UFW or another host firewall configured deliberately on both VMs

The examples use 10.20.0.10 for VM-A and 10.20.0.11 for VM-B. Replace them with the private addresses assigned to your VMs.

Step 1 — Choose a private CIDR before creating the VPC

Raff VPC currently accepts private IPv4 CIDRs from /16 through /28 and can suggest a /24 automatically. Use an RFC 1918 range and consider future networks before choosing it.

Common private address space includes:

Text
10.0.0.0/8 172.16.0.0/12 192.168.0.0/16

For this tutorial, use an example network such as:

Text
10.20.0.0/24

Do not automatically reuse the same CIDR as your office LAN, client VPN pool, another cloud VPC, or a network you expect to peer later. Overlap can make future routing and VPN design harder.

Verify: Record the CIDR you will use and confirm it does not overlap with any network that must later route to this VPC.

Step 2 — Create the Raff VPC

Open the VPC/networking section of the Raff dashboard and create a new VPC. Give it a descriptive name such as:

Text
prod-app-vpc

Choose the CIDR from Step 1 or accept an appropriate auto-suggested range. Raff's current VPC model includes the managed gateway, DNS, and DHCP with the VPC, so attached VM interfaces can receive private addressing from the network.

The exact dashboard labels can evolve, but the workflow is the same: create a VPC, choose or accept the CIDR, then wait until the VPC reports that it is ready before attaching workloads.

Verify: The Raff dashboard should show the VPC as ready and display the expected CIDR, for example 10.20.0.0/24.

Step 3 — Attach VM-A and VM-B to the same VPC

Attach both VMs to the VPC from the Raff dashboard. The two VMs must belong to the same private network for the direct private-IP test in this tutorial.

Record the assigned private addresses. For example:

Text
VM-A: 10.20.0.10 VM-B: 10.20.0.11

Do not assume the private Linux interface will be named eth1. Modern Ubuntu guests may use predictable names such as ens4, ens7, or another device name depending on how the NIC is presented.

If the dashboard exposes security groups for the VM or VPC, do not create a broad allow any from the entire VPC rule just for convenience. In later steps, permit only the temporary test flow or the actual service flow you need.

Verify: Both VM detail views should show attachment to the same VPC and a private IPv4 address from the VPC CIDR.

Step 4 — Identify the private interface and address on Ubuntu

SSH to VM-A and list interfaces in compact form:

Bash
ip -br addr

Then list IPv4 routes:

Bash
ip -4 route

Repeat on VM-B.

You are looking for the interface that owns each VM's VPC address. Example output might resemble:

Text
ens3 UP 203.0.113.10/24 ens7 UP 10.20.0.10/24

On VM-B, the private interface may similarly own 10.20.0.11/24.

Do not create a Netplan file simply because an old tutorial expected eth1. First verify the actual device, dashboard attachment, DHCP state, and existing Netplan configuration. Writing a guessed interface name or route into Netplan can break remote networking.

Useful diagnostics are:

Bash
networkctl list sudo netplan status --all

Verify: Each VM should show one interface with its expected private VPC address, regardless of the interface's device name.

Step 5 — Verify that Linux routes peer traffic through the private NIC

From VM-A, ask the kernel how it would reach VM-B:

Bash
ip route get 10.20.0.11

Expected structure:

Text
10.20.0.11 dev <private-interface> src 10.20.0.10

From VM-B, check the reverse path:

Bash
ip route get 10.20.0.10

This test is more useful than assuming that any successful request used the VPC. It tells you which interface and source IP Linux selected for that destination.

You can also inspect the neighbor table after traffic has been attempted:

Bash
ip neigh show

Verify: ip route get on each VM should select the private interface and the VM's private source IP for the peer's private address.

Step 6 — Allow only the temporary private-network test flow

For a deterministic connectivity test, use iperf3 on TCP port 5201. Install it on both VMs:

Bash
sudo apt update sudo apt install -y iperf3

On VM-B, allow only VM-A's private IP to reach the test port through UFW:

Bash
sudo ufw allow from 10.20.0.10 to any port 5201 proto tcp

If a Raff security group also filters private traffic, add an equivalent temporary inbound rule for TCP 5201 from 10.20.0.10/32 to VM-B. Keep the source specific rather than opening the port to the internet or the entire VPC without a reason.

Check the host rule:

Bash
sudo ufw status numbered

If UFW is currently inactive, do not enable it blindly on a remote server. Follow the Ubuntu 24.04 UFW tutorial so SSH access is allowed before the firewall is enabled.

Verify: VM-B should have a rule allowing TCP 5201 only from VM-A's private IP, and any Raff security-group rule should match the same intended source and destination.

Step 7 — Test private connectivity with ping and iperf3

A ping can provide a quick reachability signal when ICMP is allowed:

Bash
ping -c 4 10.20.0.11

Do not treat a failed ping as proof that the VPC is broken; ICMP may be blocked while TCP traffic is allowed.

For the application-layer test, start iperf3 on VM-B and bind it specifically to the private address:

Bash
iperf3 -s -B 10.20.0.11

From VM-A, connect to VM-B's private address:

Bash
iperf3 -c 10.20.0.11

The output reports measured throughput for this specific test. Do not compare it with a fixed expected number from an old benchmark. A result is affected by VM CPU, guest networking, TCP behavior, concurrent load, and the test duration.

While the test is active, you can confirm the connection endpoints on VM-B:

Bash
ss -tnp | grep ':5201'

Stop the iperf3 server with Ctrl+C when finished.

Verify: iperf3 should complete over 10.20.0.11, and the connection should use the private source/destination addresses rather than the VMs' public IPs.

Step 8 — Replace broad VPC access with service-specific rules

The production goal is not “all private VMs trust each other.” The goal is to allow the exact application relationship you need.

For example, if VM-A is an application server and VM-B runs PostgreSQL, allow only VM-A's private address to reach PostgreSQL on VM-B:

Bash
sudo ufw allow from 10.20.0.10 to any port 5432 proto tcp

If MySQL is the backend instead:

Bash
sudo ufw allow from 10.20.0.10 to any port 3306 proto tcp

Mirror that least-privilege rule in the Raff security group when a security group protects the VM.

Then configure the application to use the database's private address, for example:

Dotenv
DB_HOST=10.20.0.11 DB_PORT=5432

The database service itself should also bind only to the interfaces it actually needs. Do not make a database publicly reachable merely because its firewall currently blocks the port.

For PostgreSQL configuration and authentication, follow Install PostgreSQL on Ubuntu 24.04 rather than copying database settings from a networking tutorial.

Verify: The application VM should be able to reach the required service port over VM-B's private IP, while unrelated VPC sources should not gain access simply because they share the subnet.

Step 9 — Keep private-network isolation separate from encryption

Raff's current VPC documentation describes per-VPC layer-2 isolation and private addressing that is separated from other tenants and the public internet. That is a network isolation boundary.

It is not a replacement for protocol-level security. Private IP traffic is not automatically equivalent to a WireGuard tunnel or TLS session. For credentials, database sessions, administration, or sensitive service-to-service traffic, use the encryption and authentication controls appropriate to the protocol and threat model.

Examples include:

  • PostgreSQL or MySQL TLS for database connections;
  • HTTPS or mTLS for internal APIs where required;
  • SSH for administrative access;
  • WireGuard/IPsec when you need an encrypted tunnel between networks or endpoints.

For client-to-server private access, see Set Up WireGuard VPN on Ubuntu 24.04.

Verify: Document which private flows rely only on VPC isolation and which also require application-layer or tunnel encryption.

Step 10 — Run the final end-to-end VPC verification

On VM-A, verify the route and private connection again:

Bash
ip route get 10.20.0.11

If your production service is PostgreSQL, test the private TCP port without authenticating to the database:

Bash
nc -vz 10.20.0.11 5432

Install netcat-openbsd first if nc is unavailable:

Bash
sudo apt install -y netcat-openbsd

On VM-B, inspect listening sockets and confirm the service is not unintentionally bound to every public interface:

Bash
sudo ss -lntp

Then review both firewall layers:

Bash
sudo ufw status numbered

In the Raff dashboard, review the security group attached to VM-B and confirm it contains only the private flows you intend.

The final architecture should resemble:

Text
Internet | v VM-A public edge 10.20.0.10 | | private VPC v VM-B database/internal service 10.20.0.11

Verify: The peer route should use the private NIC, the required service should work over the private IP, port 5201 should no longer be needed after testing, and public exposure should be limited to intentionally public services.

Step 11 — Troubleshoot private VPC connectivity systematically

The private IP does not appear in Ubuntu

Check the dashboard attachment first, then inspect the guest:

Bash
ip -br addr networkctl list sudo netplan status --all

Do not assume the NIC is eth1, and do not write a new Netplan file until you understand the existing network configuration. If the VPC attachment is present in Raff but the guest never receives DHCP configuration, gather these outputs before changing networking or contacting support.

ip route get chooses the public interface

Confirm both private IPs belong to the same VPC CIDR and inspect the full route table:

Bash
ip -4 route

A conflicting or more-specific route from VPN software, custom Netplan, or another NIC can override the expected path.

Ping fails but the route is correct

ICMP may be filtered. Test the actual allowed TCP service instead:

Bash
nc -vz 10.20.0.11 5201

or run the iperf3 test from Step 7.

iperf3 reports connection refused

On VM-B, confirm the server is listening on the private address:

Bash
ss -lntp | grep ':5201'

Then review UFW and the Raff security group:

Bash
sudo ufw status numbered

The service works on the public IP but not the private IP

The application may be bound only to its public address or localhost. Inspect listeners with:

Bash
sudo ss -lntp

Configure that service to bind to the intended private address according to its own documentation, then restart and verify it.

Verify: After fixing the identified layer, rerun ip route get, then the actual TCP test. Do not consider the issue solved based only on the presence of a private IP.

Step 12 — Remove temporary test access and tools

After iperf3 testing, remove the temporary UFW rule from VM-B. First find its rule number:

Bash
sudo ufw status numbered

Then delete only the TCP 5201 rule that you created for VM-A:

Bash
sudo ufw delete <RULE_NUMBER>

Remove the equivalent temporary Raff security-group rule if you created one.

If iperf3 was installed only for this test and is no longer needed:

Bash
sudo apt remove -y iperf3

Do not detach a production VPC or delete its CIDR merely to clean up the tutorial. Detaching the private NIC can break database, cache, internal API, monitoring, backup, or administrative paths that now depend on the private address.

Only when this was a disposable lab and no dependencies remain should you detach the VMs and remove the VPC from the Raff dashboard.

Verify: TCP 5201 should no longer be allowed or listening, while the production service-specific private rules you intentionally created should remain in place.

Conclusion

You connected two Raff VMs through a private VPC, identified their actual Ubuntu network interfaces, verified the kernel route that carries private traffic, tested TCP connectivity without exposing a test port publicly, and replaced broad subnet trust with service-specific firewall rules.

The important production pattern is simple: use the VPC for private reachability, security groups and host firewalls for least-privilege access, and protocol-level encryption where the data requires it. Do not infer network performance from an old iperf3 screenshot or treat a private IP as a substitute for authentication and TLS.

For broader architecture decisions, continue with VPC Architecture for Multi-VM Applications and Public vs Private Networking. Current VPC network limits, traffic policies, and feature details are maintained on the product page linked in the introduction.

Explore Raff VPC to connect two Ubuntu VMs over private IPs. Use least-privilege firewall rules and application-level encryption where required; VPC isolation alone does not encrypt application traffic.

Was this article helpful?
Aybars Altınyay
Aybars Altınyay
Platform Engineer & Technical Writer

Aybars is a Platform Engineer & Technical Writer at Raff Technologies. He works on Linux VM templates, self-hosted application workflows, and security-focused deployment validation, turning tested infrastructure procedures into clear, practical tutorials for developers and teams.

Put your app and database servers on one private network.

Tested on 2 vCPU and 4 GB RAM: $17.99 a month

Ubuntu, Debian and other Linux distributions with full root and SSH access, up and running in about 55 seconds.

14-day money-back guarantee

Frequently asked questions

How do I connect two cloud VMs on a private network?
Attach both VMs to the same VPC, confirm each receives a private IP, use `ip route get <peer-private-ip>` to verify the private route, and allow only the required source/port through security groups and the host firewall.
What is a private VPC network?
A VPC is an isolated private network inside a cloud environment. Resources communicate with private IP addresses while routing, security groups, firewalls, and gateways control which traffic is allowed.
Does Raff VPC private traffic count toward bandwidth usage?
Check the current [Raff VPC](/products/vpc) product page for the active private-traffic and bandwidth policy. Product limits and network specifications can change independently of this tutorial.
Is traffic inside a private VPC encrypted?
Private-network isolation and encryption are different controls. A VPC keeps traffic off the public internet and isolates the network, but applications should still use TLS, SSH, WireGuard, IPsec, or another encryption method when the threat model requires encrypted traffic.
Do private network interfaces always use eth1 on Ubuntu?
No. Interface names vary. Use `ip -br addr`, `ip -4 route`, and `ip route get <peer-private-ip>` to identify the device and route instead of hard-coding `eth1`.
Should every VM in a VPC be allowed to talk to every other VM?
No. VPC membership provides reachability, not a reason for blanket trust. Use security groups and host firewalls to allow only required source-to-destination service flows.
How can I test throughput between two VMs without exposing iperf3 publicly?
Bind `iperf3` on the receiving VM to its private IP and allow TCP 5201 only from the sending VM's private /32 address. Remove the temporary rule after the test.
Why can ping fail even when the private network works?
ICMP may be filtered even when TCP service traffic is allowed. Verify the route with `ip route get` and test the actual permitted TCP port instead of using ping as the only health check.

Related Articles

View all →