Site-to-Site VPN

Connect two networks over the public internet with encrypted IPsec or WireGuard tunnels.

3 min read 4 lesson sections
  • #ipsec
  • #wireguard
  • #tunnel
  • #bgp
Site-to-Site VPN: Connect two networks over the public internet with encrypted IPsec or WireGuard tunnels.
Concept map

A site-to-site virtual private network (VPN) connects two private networks through an encrypted tunnel across an untrusted network such as the public internet. A gateway at each site encrypts traffic before it leaves that network and decrypts it at the other end. Hosts can then communicate using private addresses, subject to the routes and firewall policies at both sites.

Picture it: Think of two offices connected by a guarded bridge. The tunnel protects the trip; routes decide who may cross, and firewalls decide which doors are open at each end.

The pieces of a tunnel

Each endpoint needs a reachable gateway, a peer identity, compatible encryption settings, and a shared understanding of which traffic should use the tunnel. IPsec is widely supported by network appliances and cloud gateways. WireGuard is a simpler modern option supported by many platforms. They differ in how they establish peers and manage keys, so endpoints must use compatible configurations.

The tunnel does not replace routing. Each side needs routes for the remote network, and those address ranges must not conflict with local networks. Firewalls must permit the intended traffic, while denying access that the connection does not require. For dynamic environments, BGP can exchange routes and support failover; smaller designs may use carefully maintained static routes.

Interactive diagram

Office A · 192.0.2.0/24Office B · 198.51.100.0/24lan-a ↔ site-aEncrypted tunnelEncrypted tunnelEncrypted tunnelEncrypted tunnelsite-b ↔ lan-bOffice A gateway192.0.2.1Office A gateway — 192.0.2.1Office A LAN192.0.2.0/24Office A LAN — 192.0.2.0/24Untrusted transitUntrusted transitOffice B gateway198.51.100.1Office B gateway — 198.51.100.1Office B LAN198.51.100.0/24Office B LAN — 198.51.100.0/24
Legend

Current step

Gateways establish a peer tunnel

Each gateway authenticates the other and protects selected traffic across the transit network.

The tunnel endpoints authenticate each other and protect traffic in transit. A VPN does not by itself decide which applications or hosts should be reachable.

Documentation example: addresses use the RFC 5737 ranges and ASNs use the reserved private range. Nothing here connects to a real network.

Plan before deployment

  1. List the networks. Record local and remote address ranges, gateways, and the services that need to communicate. Resolve overlapping address ranges before building the connection.
  2. Choose the tunnel endpoints. Decide whether the VPN terminates on firewalls, dedicated gateways, or cloud network services, and confirm the endpoints can reach each other.
  3. Agree on policy. Select supported cryptographic settings, peer authentication, key rotation, and the allowed traffic in both directions. Use each platform’s current security guidance rather than copying old defaults.
  4. Configure routing and filtering. Add only the necessary remote routes and firewall rules. A tunnel being up does not mean every host should be able to reach every other host.
  5. Test and monitor. Verify gateway status, route selection, name resolution, and application connectivity from both sites. Monitor tunnel health, logs, and traffic; test a planned failover before relying on it.

Reliability and security

Redundant tunnels and gateways can reduce outages, but they require tested route priorities and failover behavior. Monitor both tunnel establishment and the applications that depend on the tunnel. Keep gateway software updated, protect private keys, review access rules regularly, and remove unused peers and routes.

Site-to-site VPNs are a common way to connect an office network to a cloud virtual network. They provide protected transport between gateways; application authentication, endpoint security, and least-privilege network policy are still needed at each end.

Interactive diagram

Test flowTest flowPolicy decisionPolicy decisionTest client192.0.2.10Test client — 192.0.2.10Policy enginePolicy engineDocumentation service203.0.113.20Documentation service — 203.0.113.20
Legend

Current step

Firewall policy lab

Edit a small local rule set and see which first matching rule handles a documentation-only test flow.

Try the policy

Disable the HTTPS allow rule or change its port, then observe the default-deny result.

Reveal diagnosis

A least-privilege policy permits only the intended source, destination, protocol and port; unmatched traffic reaches the default-deny rule.

Firewall policy simulator

Local-only simulation. Fields match exactly (case-insensitive); use "any" as a wildcard. Nothing changes on a real device.

Test traffic
  1. Rule 1
  2. Rule 2

Result: allowed Matched rule: allow-web

This is a deterministic browser-only teaching simulation. It does not send packets, connect to a network, or modify any device.

Documentation example: addresses use the RFC 5737 ranges and ASNs use the reserved private range. Nothing here connects to a real network.

Interactive diagram

Restricted service segmentmanaged-user ↔ identityRequestRequestNarrowly allowedNarrowly allowedDecision logDecision logManaged user device192.0.2.15Managed user device — 192.0.2.15Identity providerIdentity providerPolicy enforcementPolicy enforcementMonitoringMonitoringIsolated application203.0.113.40Isolated application — 203.0.113.40
Legend

Current step

Verify identity and device state

The request is associated with an authenticated identity and a managed device before access is considered.

Review the boundary

Which component should enforce the service-specific decision, and what should be recorded?

Reveal diagnosis

The policy enforcement point grants only the approved application request; monitoring records identity, resource and outcome.

Trust is evaluated for the requested resource, not granted to an entire network because a device is inside it. Monitoring records the decision for later review.

Documentation example: addresses use the RFC 5737 ranges and ASNs use the reserved private range. Nothing here connects to a real network.

Trusted references