##
VPN & IPsec
VPNs build encrypted tunnels over untrusted networks. IPsec is the workhorse suite for site-to-site links.
// site-to-site IPsec tunnel
Site A
10.1.0.0/24
R1
IPsec ESP
encrypted over Internet
R2
Site B
10.2.0.0/24
The two private LANs reach each other as if local — traffic is encrypted by ESP across the untrusted public path.
// facts
- Phase 1 (IKE/ISAKMP) builds the secure channel; Phase 2 protects data
- Transport mode = host-to-host; Tunnel mode = network-to-network (new IP header)
- Diffie-Hellman derives a shared key over an insecure path
- HMAC = hash of data + secret key → message authenticity
- Split tunnel sends only corporate traffic over the VPN
crypto isakmp policy 10
encryption aes 256
hash sha
authentication pre-share
group 2
lifetime 3600
!
crypto isakmp key S3cretKey address 10.0.0.2
!
crypto ipsec transform-set MyTS esp-aes 256 esp-sha-hmac
mode tunnel
!
crypto ipsec profile MyProfile
set transform-set MyTS
!
interface Tunnel0
ip address 172.16.0.1 255.255.255.252
tunnel source 10.0.0.1
tunnel destination 10.0.0.2
tunnel mode ipsec ipv4
tunnel protection ipsec profile MyProfile show crypto isakmp sa
show crypto ipsec sa
show crypto ipsec transform-set
debug crypto isakmp // modern VPN options
// WireGuard
- Peers are identified by public keys, not certificates or logins
- AllowedIPs sets routing and access in a single line
- Connectionless — roams across networks seamlessly
- Far less code than IPsec/OpenVPN, so a smaller attack surface