Skip to content

Site-to-site VPN: security best practices for corporate environments

A VPN connects networks, but poorly segmented it becomes a corridor for lateral movement. See how to connect them safely.

Reading time
10 min
Published

A site-to-site VPN connects entire networks, such as a data center to a VPC or two offices to each other. The risk many teams ignore is that, once established, the VPN often becomes an open tunnel between the networks, and a compromise on one side spreads to the other. The encrypted tunnel is only the beginning, because VPN security also depends on segmentation, restricted routes and visibility.

The best practices below are for configuring and operating a site-to-site VPN defensively: adequate encryption, control over what can cross the tunnel, key management, logs and availability. The goal is to connect the networks without creating an easy path for lateral movement.

Encryption and key management

Use current encryption parameters in IPsec and stay away from algorithms and groups considered weak. Prefer modern suites and disable legacy ones. If you use pre-shared keys, they must be strong, stored securely and rotated, because a weak or leaked key compromises the entire tunnel.

Document the parameters agreed between the two sides and keep both in sync. Mismatched configurations cause instability and sometimes lead the team to relax the parameters just to get the tunnel up, which weakens security.

The two IKE phases and forward secrecy

An IPsec VPN negotiates in two phases. In the first, the two sides authenticate each other and set up a secure management channel; in the second, they negotiate the keys that actually encrypt the traffic. In each phase you choose the cipher algorithm, the integrity algorithm and the key exchange group. The sensitive point is perfect forward secrecy (PFS). With it enabled, each renegotiation generates new, independent key material, and the compromise of one key exposes neither past nor future traffic. Prefer strong key exchange groups and keep PFS enabled. The profile below sums up what to agree on with the other side.

Parameter profile to agree on between the two sides (reference)
# Prefer modern suites and keep both gateways alignedPhase 1 (IKE):   cipher AES-GCM or AES-CBC 256                 integrity SHA-2 (256 or higher)                 strong key exchange group (avoid legacy groups)Phase 2 (IPsec): ESP with AES-GCM or AES-CBC 256                 PFS enabled (new key on every renegotiation)                 SA lifetime short enough for regular rotationAuthentication:  strong, unique pre-shared key, or certificates

Treat the pre-shared key as a high-value secret: generate a long, random key, store it in a secrets vault and do not reuse the same key across different tunnels. When scale justifies it, certificate-based authentication avoids the problem of static shared keys and makes it easier to revoke one side without touching the others.

Segmentation and restricted routes

The most important control, and also the most forgotten, is restricting what can cross the tunnel. Instead of routing entire networks from one side to the other, define routes and rules that allow only the flows that are really needed (a specific set of hosts and ports, for example). That way, even if one side is compromised, access to the other side stays limited.

  • Allow only the necessary flows through the tunnel
  • Avoid routing entire networks when only a few hosts need to talk
  • Apply firewalls on both sides instead of trusting the VPN alone
  • Segment to contain lateral movement between the networks
  • Periodically review what the tunnel actually allows

Think of the VPN as a connection between different trust zones. It is not a transparent extension of the internal network, which is why the firewalls on both sides are still needed.

From full network access to the smallest possible flow

An overly open VPN gets closed down in stages, from the broad connection to the restricted one. First, find out which applications really need to talk between the two sides; many connections carry the whole network just because it was faster to configure that way. Then write firewall rules that allow only those hosts and ports and close everything else by default. A deny rule as the baseline, with explicit and justified exceptions, takes more work at the start, but it is the opposite of routing everything and hoping nothing goes wrong.

Logs and high availability

Enable logs for the tunnel and for the traffic that passes through it, for detection and investigation. Without that visibility, malicious lateral access through the VPN goes unnoticed. For critical services, plan high availability with redundant tunnels, so that losing one path does not bring down the whole connection.

Monitor tunnel health and raise alerts for drops and abnormal renegotiations. They can indicate either an operational problem or suspicious activity.

Redundancy without a single point of failure

Real high availability requires paths that do not share the same weak point. Two tunnels that leave through the same device, the same internet link or with the same key configuration inherit the same failure. For critical services, spread the paths across different gateways and links and test failover on purpose: take one side down in a controlled window and confirm that traffic moves over as expected. A redundant tunnel that was never exercised tends to fail exactly when it is called on.

Detecting abuse through the tunnel

The VPN encrypts the traffic, but it does not tell you whether what passes through it is legitimate. An attacker who compromises one side uses the tunnel just as an administrator would, so detection has to look at behavior, not just at whether the connection exists. Log the flows that cross the tunnel and compare them with what is expected. A host that suddenly talks to services it never accessed before, a port scan of the other side or an unusual data volume are signs that deserve an alert.

  • Connections to hosts or ports outside the authorized set
  • Network scans from one side toward the other
  • Transfer volume far above the historical pattern
  • Tunnel renegotiations at unusual times or frequencies
  • Repeated denied access attempts at the edge firewall

Send these events somewhere the team actually watches, such as a SIEM or a channel with an owner and a response deadline. And decide in advance what to do when the alert fires. A compromised tunnel usually requires taking the connection down, rotating the keys and investigating the source side before restoring it, because reconnecting in a hurry hands the path back to whoever was abusing it.

Practical checklist

  • Use current IPsec encryption parameters and disable legacy ones
  • Keep PFS enabled to renew key material on every renegotiation
  • Use strong keys, unique per tunnel, stored in a vault and rotated
  • Consider certificate authentication where scale justifies it
  • Document and match parameters between the two sides
  • Allow only the necessary flows through the tunnel
  • Adopt default deny on the firewall, with justified exceptions
  • Avoid routing entire networks without need
  • Apply firewalls on both sides of the VPN
  • Segment to contain lateral movement
  • Enable logs for the tunnel and the flows that cross it
  • Alert on access to hosts or ports outside the authorized set
  • Plan high availability with independent paths
  • Test failover on purpose in a controlled window
  • Monitor tunnel health, drops and renegotiations
  • Have a response procedure for a compromised tunnel

Best practices

  • Treat the VPN as a connection between separate zones, not as a single network
  • Restrict the tunnel to the strictly necessary flows
  • Keep firewalls active on both sides, with default deny
  • Prefer modern suites and keep PFS enabled
  • Rotate and protect the tunnel keys, without reusing them across connections
  • Get visibility with flow logs and behavior alerts
  • Plan redundancy over independent paths and test failover

Common mistakes

Routing entire networks from one side to the other
It creates a wide corridor for lateral movement between the networks.
Relaxing encryption to get the tunnel up
It weakens the protection of traffic between the sites.
Disabling PFS for convenience
The compromise of one key now exposes other sessions' traffic.
A weak, reused or never-rotated pre-shared key
One compromised key exposes the whole tunnel, and sometimes more than one.
Trusting the VPN alone, with no firewalls on either side
A compromised side reaches the other with no additional barrier.
Redundancy through the same device or link
The tunnels inherit the same failure and go down together when it happens.
A tunnel without flow logs
Malicious lateral access through the VPN goes by without anyone noticing.

Authorship and review

Cesar Gargiulo

CEO and founder of GUARDIASEC. Technical and editorial lead for the content published in this library.

Published on . Found a technical error? Write to [email protected] and we will correct it and keep a record of the change.

Frequently asked questions

If the VPN already encrypts everything, isn't it secure?
Encryption protects traffic in transit between the sites, but it does not control what can cross the tunnel. If the VPN routes entire networks, an attacker who compromises one side reaches the other without obstacles. VPN security depends on encryption and, to the same degree, on segmentation and flow control.
Should I route the whole network through the tunnel?
In general, no. The recommendation is to allow only the flows that are really needed, such as specific hosts and ports, instead of connecting entire networks. If one side is then compromised, lateral movement stays limited and the risk surface of the connection drops considerably.
Do I need a firewall if I already have the VPN?
Yes. The VPN connects different trust zones and does not replace the firewall. With firewalls on both sides, only the expected traffic crosses the tunnel, and a compromised side does not gain unrestricted access to the other. VPN and firewall are layers that complement each other.
How do I detect abuse through the VPN?
With logs for the tunnel and the flows that pass through it, plus alerts for out-of-pattern behavior. Since the VPN encrypts the traffic, detection focuses on what crosses the tunnel: connections to hosts or ports outside the authorized set, scans from one side toward the other, atypical data volume and renegotiations at unusual times. Without these logs, someone can use the connection between the sites maliciously without anyone noticing.
What is perfect forward secrecy and why keep it enabled?
Perfect forward secrecy (PFS) makes the VPN generate new, independent key material on every renegotiation. In practice, an attacker who obtains one key cannot decrypt the traffic of earlier or later sessions, because each session used its own keys. Without PFS, one exposed key can open up even traffic that has already passed. So keep PFS enabled and use strong key exchange groups on both sides.
Pre-shared key or certificates: which should I use?
A pre-shared key works well for a few tunnels, as long as it is long, random, unique per connection and stored in a secrets vault. As the number of tunnels grows, managing static keys becomes risky and laborious. Certificate authentication scales better, avoids repeated shared secrets and lets you revoke one side without touching the others. The choice depends on how many connections you have and how well the team already handles certificate management.
How do I make a site-to-site VPN truly redundant?
In real redundancy, the paths do not share the same point of failure. Tunnels that leave through the same device, the same link or with the same configuration go down together when the problem appears. Spread the paths across different gateways and links and test failover on purpose: take one side down in a controlled window and confirm that the traffic moves over. A backup tunnel that was never exercised tends to fail exactly when it is called on.

When to bring in specialist help

Connecting networks with proper segmentation and visibility is network security architecture work. GUARDIASEC supports this work through its security consulting and AWS security services, where it assesses segmentation, exposure and flow control between environments.