Sub topic 3
VPNs and Tunnelling Explained: Encapsulation, Encryption and Routing
Assume basic IP addressing, default routes, DNS, TCP, UDP, and Linux command-line use. This chapter focuses on service-specific tunnels and the routing decisions around them.
SSH tunnels for single services
SSH port forwarding carries a TCP connection through an authenticated SSH session. Local forwarding exposes an internal service on your computer:
ssh -L 8080:intranet.example.com:80 [email protected]A browser connecting to localhost:8080 sends traffic through the bastion. The bastion then connects to intranet.example.com:80. The internal server sees the bastion as the client.
SSH forwarding protects traffic between the SSH endpoints. It does not automatically route every application, expose UDP services, or make the laptop part of the remote network. Use -N when no remote shell is needed, and -f only when background operation is appropriate.
Split tunnelling, full tunnelling and DNS
A split tunnel sends only selected networks through the tunnel. A full tunnel sends the default routes through it.
| Policy | Tunnel routes | Typical effect |
|---|---|---|
| Split tunnel | `10.20.0.0/16` | Internal services use the tunnel; internet uses the normal link |
| Full tunnel | `0.0.0.0/0, ::/0` | Internet traffic also uses the VPN |
DNS must match the policy. A split tunnel may need internal DNS servers for names such as git.corp.example; otherwise the route can work while name resolution fails. A full tunnel commonly sends DNS through the VPN to avoid leaking queries to the local network.
> callout note > Routing decides where packets go. DNS decides which address a name becomes. A working tunnel requires both decisions to agree.
What a VPN does and does not protect
A VPN can authenticate peers, encrypt traffic across an untrusted path, and provide integrity checks that detect modification. It does not make an untrusted endpoint safe. Malware, compromised servers, browser tracking, application-layer attacks, and traffic visible at the VPN endpoint remain possible. A VPN also does not fix incorrect permissions or missing routes.
Troubleshooting a tunnel that will not pass traffic
Check the failure from the inside out:
- Confirm the SSH or VPN session is established and authenticated.
- Test the destination by IP address before testing its DNS name.
- Check routes with
ip routeand verify the destination uses the tunnel. - Check firewall rules and whether the remote service is listening.
- Test MTU problems when small packets work but larger transfers stall:
ping -M do -s 1372 10.8.0.1NAT can also prevent inbound connections. A peer behind NAT may need a reachable endpoint or periodic keepalives. For SSH, verify that the bastion itself can resolve and reach the forwarded destination.
Exercise
In ssh -L 8080:server:80 bastion, which machine connects to server:80?
Show answer
The bastion connects to server:80; the local machine connects only to its own localhost:8080 port.