~/netref / VPN & IPsec
##

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.
// VPN types
Site-to-siteGateway ↔ gateway, whole networks
Remote accessSingle client → network
SSL/TLS VPNClient/browser over TLS (443)
GRETunnels any protocol — no encryption
// IPsec building blocks
ISAKMPUDP 500Framework to negotiate & manage SAs
IKEUDP 500Key agreement (asymmetric crypto)
AHProtocol 51Auth + integrity (no encryption)
ESPProtocol 50Encryption + integrity + auth
NAT-TUDP 4500IPsec through NAT
// encryption & hashing algorithms
AlgorithmTypeKey bitsStrength
DESSymmetric56Weak
3DESSymmetric168Medium
AESSymmetric128 / 192 / 256Strong
RSAAsymmetric1024+Strong
MD5Hash128Medium (legacy)
SHA-1Hash160Strong (legacy)
SHA-256Hash256Strong
// IPsec services
ConfidentialityEncryption hides the data
IntegrityHMAC ensures data is unaltered
Data-origin authAuthenticates the SA peer
Anti-replaySequence numbers drop duplicate packets
// IKE phases
Phase 1Bidirectional ISAKMP SA — secure mgmt channel (main or aggressive mode)
Phase 1.5Optional Xauth — enforce user authentication
Phase 2Two unidirectional IPsec SAs for data (quick mode)

// 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
site-to-site ipsec · cisco ios
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
verify
show crypto isakmp sa
show crypto ipsec sa
show crypto ipsec transform-set
debug crypto isakmp

// modern VPN options

// types compared
WireGuardModern, tiny, fast — UDP, ChaCha20, public-key peers
OpenVPNMature SSL/TLS VPN — TCP or UDP, very portable
IKEv2 / IPsecFast re-keying, great on mobile (MOBIKE roaming)
DMVPNCisco hub-and-spoke that builds dynamic spoke-to-spoke tunnels
GREPlain tunnel, no encryption — pair it with IPsec
SSL VPNClientless / browser access to internal apps

// 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