Free tech learning for everyone, from basics to pro

Network SecurityNetworking SecurityIntermediate

VPNs and site-to-site IPsec: types, framework and configuration

In short: A VPN gives secure private connectivity across the internet. Remote-access VPNs connect individual users; site-to-site VPNs join networks. IPsec provides encryption, integrity, authentication and secure key exchange, with tunnels built in two IKE phases.

Why use a VPN?

  • Cost savings: the internet replaces expensive private lines.
  • Security: encryption and authentication protect the traffic.
  • Scalability: new sites and users are added easily.
  • Compatibility: works over almost any internet connection.

Two types of VPN

Remote-access VPN and site-to-site VPNRemote accessSite to siteLaptopVPN clientFirewallVPN gatewayone user to the officeBranchrouterHead officerouterwhole networks joinedBoth cross the internet inside an encrypted tunnel
Figure 1. A remote-access VPN connects one device; a site-to-site VPN permanently connects two networks.
  • Site-to-site: VPN gateways (routers or firewalls) at each site build a permanent tunnel. Users don't need any VPN software; their traffic is encrypted automatically when it leaves the site.
  • Remote-access: a VPN client on a laptop or phone builds a tunnel to the organisation's VPN gateway whenever the user needs it. It uses IPsec or SSL/TLS.

The IPsec framework

IPsec is a framework: each building block can use a choice of algorithms.

FunctionChoicesRecommended
ProtocolESP (encrypts + authenticates) or AH (authenticates only)ESP
ConfidentialityDES, 3DES, AESAES-256
IntegrityMD5, SHA-1, SHA-256 and stronger (as HMAC)SHA-256 or better
AuthenticationPre-shared key (PSK) or RSA certificatesCertificates, or a long random PSK
Key exchangeDiffie-Hellman groupsGroup 14 or higher, or elliptic-curve groups 19/20

How a tunnel is built

The five steps of an IPsec VPN1. Host A sends interesting traffic2. Routers agree IKE phase 13. Routers agree IKE phase 2 (IPsec SAs)4. Data flows through the tunnel5. Tunnel ends (timeout or no traffic)
Figure 2. An IPsec tunnel is built on demand in two IKE phases, carries traffic, then closes.
  1. Interesting traffic: a host sends traffic that matches the VPN's access list, which triggers the tunnel.
  2. IKE phase 1: the two gateways authenticate each other and agree a secure management channel (the ISAKMP/IKE security association).
  3. IKE phase 2: inside that channel they agree how to protect user data, creating the IPsec security associations.
  4. Data transfer: traffic is encrypted and sent through the tunnel.
  5. Termination: the tunnel closes when its lifetime ends or traffic stops.

Configuration tasks

  1. Configure the ISAKMP policy for IKE phase 1.
  2. Configure the IPsec transform set for phase 2.
  3. Create a crypto map tying the peer, transform set and traffic list together.
  4. Apply the crypto map to the outside interface.
  5. Verify that the tunnel is working.
crypto isakmp policy 10
 encryption aes 256
 hash sha256
 authentication pre-share
 group 14
 lifetime 3600
crypto isakmp key Long-Random-PSK-2026 address 203.0.113.2
crypto ipsec transform-set FMT-TS esp-aes 256 esp-sha256-hmac
crypto ipsec security-association lifetime seconds 900
access-list 110 permit ip 192.168.1.0 0.0.0.255 192.168.2.0 0.0.0.255
crypto map FMT-MAP 10 ipsec-isakmp
 set peer 203.0.113.2
 set transform-set FMT-TS
 match address 110
interface GigabitEthernet0/1
 crypto map FMT-MAP

Verification commands are on the router commands page. For a deeper explanation, read IPsec explained.

Real-world example: a chain of twelve shops

A family-owned chain of twelve hardware shops needed its tills and stock system to talk to the head office server. Leased lines to every shop were too expensive, so each shop got an ordinary business broadband line and a small firewall. The firewalls build site-to-site IPsec tunnels to the head office, using IKEv2, AES encryption and SHA-256 integrity, so till data crosses the internet encrypted. Area managers who visit shops use a remote-access VPN client with MFA on their laptops.

When one shop's broadband failed, its firewall switched to a 4G backup link and rebuilt the tunnel automatically, and the tills kept working. The IT team monitors each tunnel's status, so they knew about the failover before the shop called.

Practice

Which VPN type lets a whole branch office reach head office without software on each PC?
Site-to-site VPN.
What is agreed in IKE phase 1 and in IKE phase 2?
Phase 1: a secure, authenticated management channel between the gateways. Phase 2: the IPsec SAs that protect user data.

Key takeaways

  • VPNs save cost and add security, scalability and compatibility.
  • Remote-access VPNs connect users; site-to-site VPNs join networks.
  • IPsec framework: ESP, AES, SHA-2 HMAC, PSK or certificates, Diffie-Hellman.
  • Tunnels are built in IKE phase 1 and phase 2, then carry traffic until they time out.
Tracks your learning on this device only. See your progress on the learning paths.

About the author

Mohamed Fayas

Founder of FM TecHub. CCNA certified, with a BTEC HND in Network Engineering, and BEng (Hons) in Computer Networking and Cloud Security. He writes practical, plain-English guides on networking, security and cloud.

More about the author

Original content written by Mohamed Fayas for FM TecHub. © 2026 FM TecHub. You're welcome to share a link to this page; please don't copy the text elsewhere without permission.

Stay up to date by email

New notes, tools and security news from FM TecHub, explained simply. Free.

We only use your email to send these updates. See our privacy policy.