VPNs and Tunneling — IPSec, SSL, WireGuard

How VPNs protect traffic with encryption, authentication, and tunnel encapsulation.

Est. 20–28 min Updated Suggest a fix
Chapter 1

A Private Path Through a Public Network

When a developer in Hyderabad opens an internal dashboard from home, the packets cross an untrusted ISP network. A virtual private network (VPN) creates a protected logical path across that shared infrastructure. The VPN does not make the internet private; it authenticates peers, encrypts selected traffic, and wraps the original packet in an outer packet that can cross the public network.

Keep three goals distinct: confidentiality hides payloads from observers, integrity detects modification, and authentication verifies the peer. Encryption without correct peer verification can securely deliver data to the wrong endpoint. A VPN also does not automatically make a device safe from malware or prevent an authorised user from accessing data.

Prerequisites: IP addressing, routing, TCP/UDP, and the difference between a packet's source and destination. Imagine an envelope inside another envelope: the inner address is the protected destination; the outer address routes the tunnel between VPN peers.

Chapter 2

Tunnels, Modes, and Protocol Families

Tunneling encapsulates one network-layer packet inside another. In IPsec transport mode, the original IP header remains for host-to-host communication while the payload is protected. In tunnel mode, an entire original IP packet is protected and receives a new outer IP header; this is common for gateway-to-gateway VPNs. The outer header is routable on the underlay; the inner packet follows the private overlay's routes.

IPsec combines the Encapsulating Security Payload (ESP) data plane with Internet Key Exchange (IKE) negotiation. IKE authenticates peers and agrees on algorithms and keys; ESP protects packets. TLS-based remote-access VPNs use a TLS connection and often integrate with browser or endpoint identity. WireGuard is a compact, key-based Layer 3 tunnel protocol. Product names differ, but the useful questions stay the same: who is the peer, what traffic is included, how are keys rotated, and where does routing send packets?

# Inspect the route selected for an internal destination (Linux)
ip route get 10.20.4.15

# Inspect a tunnel interface and its addresses
ip -brief address
ip route show

# Show WireGuard peer/interface status; do not share private keys
sudo wg show
These commands inspect a system you administer. A route through a tunnel proves only that the local routing table selected that interface; it does not prove that the far end is healthy or that application traffic is authorised.

Chapter 3

Follow One Packet Through the VPN

Suppose a company laptop at 10.8.0.24 accesses an internal service at 10.20.4.15. The operating system first chooses the most specific matching route. It gives the inner packet to the VPN interface. The tunnel encrypts and authenticates it, then sends an outer packet from the laptop's current network address to the VPN gateway's public address. The gateway verifies and decrypts it, applies its access policy, and routes the inner packet to the service. Return traffic follows an allowed route back through the tunnel.

Encryption protects content between tunnel endpoints, not necessarily every hop after the gateway. If a gateway decrypts traffic before forwarding it into a data centre, controls inside that network still matter. DNS requests may also follow a different path than application traffic, which can create privacy leaks or failures if policy and routing disagree.

# Example routing decision output (illustrative)
10.20.4.15 dev wg0 src 10.8.0.24

# A public destination may still use the ordinary default route
203.0.113.20 via 192.168.1.1 dev wlan0 src 192.168.1.40

Chapter 4

Full Tunnel, Split Tunnel, and DNS

A full tunnel directs all eligible device traffic through the VPN. It simplifies central egress inspection, but increases gateway bandwidth needs and can add latency. A split tunnel sends only selected corporate prefixes through the VPN and uses the local network for other destinations. Split tunneling can improve performance, but the endpoint is simultaneously attached to two trust domains; policy must prevent unintended forwarding between them.

DNS is part of the routing design. If internal names are resolved by corporate DNS but the query travels outside the tunnel, the lookup may fail or reveal internal names. Define which resolver handles each namespace, confirm routes to it, and test both internal and public lookups. Also consider IPv6: a VPN that captures IPv4 only may leave IPv6 traffic on the local network.

# Checklist for a client route and DNS review
ip route get 10.20.4.15
ip route get 1.1.1.1
resolvectl status

# Verify an internal name against the intended resolver
getent hosts app.internal.example

Chapter 5

Operational Design and Failure Modes

Use managed identity or device certificates where possible; protect private keys in the operating system's credential store; revoke access promptly when a device is lost or a person leaves. Keep tunnel software and gateways patched, limit routes to business need, and require multi-factor authentication for interactive access. Prefer current, maintained cryptographic configurations rather than copying old cipher lists from a blog.

Plan for failure: redundant gateways, a tested revocation path, capacity headroom, configuration backups, and clear alerts for tunnel establishment, packet loss, and certificate expiry. A VPN concentrator is a high-value boundary and potential bottleneck. Monitor what it decrypts and forwards, and do not treat tunnel membership as a substitute for application authorisation.

Do not send real credentials, private keys, or sensitive packet captures in support tickets. Collect only the diagnostics needed, redact identifiers, and use your organisation's approved secure channel.

Chapter 6

Mistakes, Practice, and Review

Common mistakes: assuming the VPN hides traffic after it leaves the gateway; confusing a tunnel interface with an encrypted session; sending all DNS outside the tunnel; and granting broad network routes when an application-specific access path would suffice. Diagnose by comparing route selection, name resolution, tunnel state, and gateway policy instead of repeatedly reconnecting the client.

Practice: (1) Draw the outer and inner packet addresses for a remote user opening an internal site. (2) Compare full and split tunnel trade-offs for a video-call-heavy team. (3) On a lab machine you administer, inspect routes before and after connecting a VPN and record which destinations change interface. (4) Write a checklist for lost-device key revocation. (5) Explain why a working tunnel does not guarantee application access.

🎯 Key Takeaways

  • ✓A VPN combines peer authentication, integrity, encryption, and routing policy; none of those guarantees are interchangeable.
  • ✓Tunneling adds an outer packet around an inner packet; IPsec transport and tunnel modes protect different portions of the original packet.
  • ✓Full tunnel centralises egress but costs capacity and latency; split tunnel requires careful route, DNS, and endpoint controls.
  • ✓The VPN gateway is a security boundary: traffic may be decrypted there and must still be protected downstream.
  • ✓Inspect route choice, DNS, and tunnel state independently when troubleshooting.
  • ✓Use managed identities/keys, least-privilege routes, patching, revocation, and monitoring in production.

Next: Lesson 37 · Wireless Security →

HELP US IMPROVE

How was this lesson?

Your note is shared with the Chaduvuko team for review. Please don’t include personal or sensitive information.

Choose your feedback

Spotted a mistake or something unclear? Suggest a fix on GitHub or email us. Select the text first and it is quoted for you.

Share

Discussion

0

Have a better approach? Found something outdated? Share it — your knowledge helps everyone learning here.

Continue with GitHub
Loading...