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
- 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.
| Function | Choices | Recommended |
|---|---|---|
| Protocol | ESP (encrypts + authenticates) or AH (authenticates only) | ESP |
| Confidentiality | DES, 3DES, AES | AES-256 |
| Integrity | MD5, SHA-1, SHA-256 and stronger (as HMAC) | SHA-256 or better |
| Authentication | Pre-shared key (PSK) or RSA certificates | Certificates, or a long random PSK |
| Key exchange | Diffie-Hellman groups | Group 14 or higher, or elliptic-curve groups 19/20 |
How a tunnel is built
- Interesting traffic: a host sends traffic that matches the VPN's access list, which triggers the tunnel.
- IKE phase 1: the two gateways authenticate each other and agree a secure management channel (the ISAKMP/IKE security association).
- IKE phase 2: inside that channel they agree how to protect user data, creating the IPsec security associations.
- Data transfer: traffic is encrypted and sent through the tunnel.
- Termination: the tunnel closes when its lifetime ends or traffic stops.
Configuration tasks
- Configure the ISAKMP policy for IKE phase 1.
- Configure the IPsec transform set for phase 2.
- Create a crypto map tying the peer, transform set and traffic list together.
- Apply the crypto map to the outside interface.
- 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?
What is agreed in IKE phase 1 and in IKE phase 2?
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.
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.