Skip to content

Private networking between PaaS environments — VPN, peering, internal DNS

Three patterns for connecting PaaS environments privately — site-to-site VPN, network peering, internal DNS — and which one fits which traffic shape.

You have a production PaaS environment in Montreal and a separate staging environment for a different product line in the same region. Marketing sets up a microservice in staging that needs to query a read-replica in production for a one-off report. The expedient answer — expose the replica to the public internet behind a password — is the kind of decision your auditor circles in red. The right answer is private connectivity between the two environments, and on PaaS that means one of three patterns.

What’s happening

On Jelastic-class PaaS, every environment lives in its own isolated network namespace. Containers in environment A and containers in environment B see different 10.x.x.x ranges and cannot reach each other by default — that’s the platform isolation guarantee. Connecting them privately means deliberately punching a controlled hole, and you have three options:

1. Site-to-site VPN (IPsec or WireGuard). A VPN node in each environment establishes an encrypted tunnel to the other. Traffic between the two environments traverses the tunnel; everything else stays in its own namespace. Operationally similar to connecting two on-prem sites. Latency adds 1–3 ms (encryption overhead, not distance). Best for one-off connections, cross-region links, or connecting a PaaS environment to an on-prem network.

2. Network peering at the PaaS layer. Some PaaS providers (Jelastic via Virtuozzo, the major hyperscalers) expose a “shared private network” or “VPC peering” primitive — two environments are wired into the same internal subnet at the platform level, no encryption overhead, latency identical to within-environment traffic. Best for tightly coupled multi-environment topologies inside the same region. Not always available — depends on the PaaS edition and the provider’s network design.

3. Public endpoints with mTLS and IP allow-listing. Not strictly “private networking” but the operationally-equivalent fallback when neither VPN nor peering is available. Traffic still hits the public internet but is gated by mutual TLS and source-IP rules. Sufficient when the data is encrypted in transit, both ends have stable IPs, and your threat model accepts a public packet path. Cheaper to set up. Harder to audit.

The internal DNS question is orthogonal but always paired with the above. Once you have private connectivity, you don’t want to hard-code 10.20.x.x IPs across environments — they change. You want db-replica.prod.internal to resolve to the right address from inside the staging environment. That means either pointing both environments at a shared internal resolver, or running stub DNS zones on each side.

How to verify

Three quick checks tell you what you currently have.

Are the two environments reachable today?

# From a container in env-staging
ping 10.20.0.11   # production container IP
# 100% packet loss == environments are isolated (expected default)

If you’ve set up VPN, does the tunnel come up?

# WireGuard
sudo wg show
# interface: wg0
#   public key: ...
#   listening port: 51820
# peer: <prod peer pubkey>
#   endpoint: prod-vpn.example.com:51820
#   allowed ips: 10.20.0.0/16
#   latest handshake: 23 seconds ago
#   transfer: 1.2 MiB received, 800 KiB sent

# IPsec
sudo ipsec status
sudo ipsec statusall | grep -E "ESTABLISHED|INSTALLED"

Does internal DNS resolve from the staging side?

# From inside env-staging container
dig +short db-replica.prod.internal @10.40.0.2
# 10.20.0.50  ← expected
# nothing ← resolver not configured or zone not delegated

If any of those fail, you don’t have private networking yet — you have a public endpoint or a dead tunnel.

The fix

Pick by traffic shape and frequency:

  • One-time, one-direction, low-volume report job? Public mTLS with IP allow-list is fine. Don’t build a VPN for a quarterly script.
  • Steady internal traffic between two environments you own, same region? Ask the PaaS provider about VPC peering / shared private network. If available, it’s the cleanest answer — no extra hops, no extra crypto, no extra nodes to operate.
  • Cross-region, or one side is on-prem, or peering isn’t offered? Site-to-site VPN. WireGuard is simpler to operate than IPsec for two endpoints; IPsec is the standard when you’re talking to a third party who insists on it.

A minimal WireGuard between two PaaS environments. On each environment, deploy a small Linux node (Almalinux 9 works fine) with a public IP:

# === Production VPN node (203.0.113.10) ===
dnf -y install epel-release
dnf -y install wireguard-tools
wg genkey | tee /etc/wireguard/private.key | wg pubkey > /etc/wireguard/public.key
chmod 600 /etc/wireguard/private.key

cat > /etc/wireguard/wg0.conf <<'CFG'
[Interface]
Address = 10.99.0.1/24
ListenPort = 51820
PrivateKey = <contents of /etc/wireguard/private.key>
PostUp = iptables -A FORWARD -i wg0 -j ACCEPT; iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
PostDown = iptables -D FORWARD -i wg0 -j ACCEPT; iptables -t nat -D POSTROUTING -o eth0 -j MASQUERADE

[Peer]
# staging side
PublicKey = <staging pub key>
AllowedIPs = 10.99.0.2/32, 10.40.0.0/16
CFG

sysctl -w net.ipv4.ip_forward=1
echo 'net.ipv4.ip_forward = 1' > /etc/sysctl.d/99-wg.conf
systemctl enable --now wg-quick@wg0

# Open UDP 51820 to the staging public IP only
iptables -A INPUT -p udp --dport 51820 -s <staging-public-ip>/32 -j ACCEPT
iptables -A INPUT -p udp --dport 51820 -j DROP
# === Staging VPN node (203.0.113.20) ===
dnf -y install epel-release wireguard-tools
wg genkey | tee /etc/wireguard/private.key | wg pubkey > /etc/wireguard/public.key
chmod 600 /etc/wireguard/private.key

cat > /etc/wireguard/wg0.conf <<'CFG'
[Interface]
Address = 10.99.0.2/24
ListenPort = 51820
PrivateKey = <contents of /etc/wireguard/private.key>
PostUp = iptables -A FORWARD -i wg0 -j ACCEPT; iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
PostDown = iptables -D FORWARD -i wg0 -j ACCEPT; iptables -t nat -D POSTROUTING -o eth0 -j MASQUERADE

[Peer]
PublicKey = <production pub key>
Endpoint = 203.0.113.10:51820
AllowedIPs = 10.99.0.1/32, 10.20.0.0/16
PersistentKeepalive = 25
CFG

sysctl -w net.ipv4.ip_forward=1
systemctl enable --now wg-quick@wg0

Confirm with wg show that you see a recent handshake on both sides, then add a route on every container in staging that needs to reach production:

# Inside staging containers
ip route add 10.20.0.0/16 via 10.40.0.99   # 10.40.0.99 = staging VPN node's env-internal IP

Or push it via the PaaS network configuration so all containers in the environment inherit it.

For internal DNS, two patterns:

# Pattern A — single shared resolver (CoreDNS) running in one environment,
# reachable from both via the VPN. Each environment's containers use it as
# their resolver via /etc/resolv.conf or dnsmasq stub.

cat > /etc/coredns/Corefile <<'COREFILE'
. {
  forward . 1.1.1.1 1.0.0.1
  log
  errors
}

prod.internal {
  file /etc/coredns/zones/prod.internal.zone
  log
}

staging.internal {
  file /etc/coredns/zones/staging.internal.zone
  log
}
COREFILE
# Pattern B — stub zones. Each environment runs its own resolver but knows
# to forward queries for the other environment's zone to the peer resolver.
# In dnsmasq:

server=/prod.internal/10.20.0.2
server=/staging.internal/10.40.0.2

Pattern A is simpler when you control both sides. Pattern B is what you reach for when staging and production are operated by different teams who insist on owning their own DNS.

Run the verification from “How to verify” after every change. A VPN that’s up but routes traffic out the public interface is no better than no VPN at all.

We design and operate private connectivity between PaaS environments — VPN tunnels, peering arrangements with the provider, internal DNS — as part of our managed PaaS practice; start a conversation if you’d like us to map the right topology for your environments.