Sub topic 14
What a VPN does and does not protect
This chapter assumes you know how routing tables, default routes and DNS resolution work. It also assumes you have met the main VPN types (IPsec, TLS-based VPNs, WireGuard and SSH tunnels) in earlier chapters. Here the question is what a VPN actually buys you. The answer depends on the threat you are worried about.
A VPN protects one segment of the path
A VPN protects packets only between the two tunnel endpoints. Before the first endpoint and after the second, the traffic travels as it normally would.
Consider a laptop on café Wi-Fi that uses a full tunnel to a VPN server. The laptop visits https://shop.example.net.
- The laptop encrypts the packet for the VPN server. The café network sees only encrypted packets going to the VPN server's address.
- The VPN server decrypts the packet and forwards it to the internet. It usually uses NAT, so the website sees the server's address.
- The website replies to the VPN server, which encrypts the reply and sends it back through the tunnel.
The segment from the VPN server to the website is not covered by the tunnel. If the application uses HTTPS, that segment is still encrypted, but by TLS and not by the VPN. If it uses plain HTTP, anyone on that segment can read it.
Threats a VPN addresses
A VPN addresses these threats well:
- Eavesdropping on the local network. On shared Wi-Fi, other users or the operator can capture traffic. Inside the tunnel, they see ciphertext and the endpoint address only.
- Tampering on the local path. Integrity protection means a modified packet fails verification and is dropped. A local attacker cannot inject content into your tunnelled sessions without the keys.
- Local network traffic filtering and profiling. A network that blocks sites by IP address or inspects DNS queries cannot do so for traffic inside the tunnel. It can still block the tunnel itself.
- Exposure of internal services. A remote-access or site-to-site VPN lets you keep internal services off the public internet. Only the VPN endpoint is exposed, and authentication happens there.
- Source address as an access control. A service can accept connections only from the VPN's address range. The VPN is then one layer of access control.
- Hiding your real address from the destination. With a full tunnel, the website sees the VPN server's address and not your own. The exposure moves to the VPN operator.
Threats a VPN leaves untouched
Many threats operate above or beside the tunnel. A VPN does nothing about them.
| Threat | Why the VPN does not help |
|---|---|
| Malware on your device | The malware runs inside the endpoint, so it sees traffic before encryption. |
| Phishing | The tunnel carries a fake login page as faithfully as a real one. |
| A compromised website or service | The VPN delivers whatever the server sends. |
| Account tracking | Cookies, logins and browser fingerprints identify you regardless of your IP address. |
| A malicious or logging VPN operator | The operator sees all traffic that is not otherwise encrypted, and sees the destinations. |
| Traffic analysis | Packet sizes and timing remain visible and can reveal activity. |
| Compromised endpoint credentials | A stolen key or password lets an attacker join the tunnel as you. |
| Lateral movement inside a flat VPN network | Once connected, a compromised client may reach every internal host. |
Trust moves, it does not disappear
Without a VPN, you trust the local network operator and your ISP with your metadata. With a commercial VPN, you trust the VPN provider instead. The provider sees your source address and every destination address, and sees DNS queries if you use its resolver. Statements about "no logs" are claims you cannot verify from the client side.
With a corporate VPN, the employer's network sees your tunnelled traffic. This is often the intent: it lets the employer apply security monitoring. It also means that personal browsing over the corporate tunnel is visible to the employer.
Leaks: when traffic bypasses the tunnel
A tunnel protects only traffic that enters it. Routing policy decides what enters. Several common situations send traffic around the tunnel.
- Split tunnelling. Only listed subnets use the tunnel. Everything else goes out the local interface, unprotected by the VPN. This is correct by design, but you must not expect it to protect general browsing.
- DNS leaks. The traffic goes through the tunnel, but DNS queries go to the local network's resolver. The local network then sees every hostname you visit. Check which resolver the system uses after connecting.
- IPv6 leaks. A client may have working IPv6 while the VPN only configures IPv4 routes. IPv6 traffic then goes out directly. A full-tunnel configuration should cover both families. In WireGuard that means
AllowedIPs = 0.0.0.0/0, ::/0, as in the earlier full-tunnel example. - Connection drops. If the tunnel fails and the default route falls back to the physical interface, applications continue over the open network. A kill switch prevents this by blocking non-tunnel traffic with firewall rules.
- Startup race. Traffic can leave before the tunnel is up, for example during boot or resume from sleep.
- Local network access. Many clients keep the local subnet reachable so printers keep working. That traffic is outside the tunnel by design.
A basic kill switch on Linux
This nftables ruleset drops outbound traffic that does not use the tunnel interface wg0. It permits the loopback interface, the handshake to the VPN server's public address and its UDP port, and DNS only through the tunnel. Adapt the addresses and port to your setup.
sudo nft -f - <<'EOF'
table inet killswitch {
chain output {
type filter hook output priority 0; policy drop;
oifname "lo" accept
oifname "wg0" accept
ip daddr 203.0.113.10 udp dport 51820 accept
}
}
EOFRemove it with sudo nft delete table inet killswitch. Run this over a local console, not over a remote session, because a mistake can lock you out.
Checking what a VPN really does
Do not assume the configuration works. Test it.
- Record your routes before and after connecting, with
ip routeandip -6 route. - Check which address the outside world sees. Query a service that echoes your address, once with IPv4 and once with IPv6.
- Check which DNS server answers. On systemd-resolved systems,
resolvectl statuslists the servers per interface. - Disconnect the tunnel on purpose and watch whether traffic stops (kill switch) or continues (leak).
ip route show default
ip -6 route show default
resolvectl status | grep -E "Link|DNS Servers"
curl -4 https://ifconfig.me; echo
curl -6 https://ifconfig.me; echoIf the IPv6 command prints your home or café address while IPv4 prints the VPN server's address, you have an IPv6 leak.
Privacy and anonymity are different goals
A VPN gives privacy from the local network. It does not give anonymity. Anonymity means the destination and the intermediaries cannot link activity to you. A single VPN operator can link your account, payment details and traffic. Tools such as Tor split trust across several relays so that no single party sees both who you are and where you go. They are slower and have their own limits. Chaining two VPNs from different providers also splits trust, but only as long as the providers do not cooperate.
Corporate access: a VPN is not a security boundary by itself
A traditional remote-access VPN puts the client on the internal network and treats that network as trusted. The weaknesses are known:
- A compromised laptop gets broad internal reach.
- Long-lived credentials or shared keys give the same access to anyone who holds them.
- A vulnerability in the VPN gateway exposes the whole internal network, and gateways are exposed to the internet by necessity.
Mitigations are standard practice. Use per-user or per-device keys and revoke them when people leave. Require multi-factor authentication where the protocol supports it. Segment the internal network so VPN clients reach only what they need, using firewall rules on the VPN interface. Keep the gateway patched. Many organisations go further with zero-trust designs, which authenticate each request to each service instead of relying on network location.
Choosing a VPN by threat
| Your concern | Is a VPN the right tool? |
|---|---|
| Untrusted public Wi-Fi | Yes, with full tunnel and no leaks. HTTPS already covers content. |
| Hiding browsing from your ISP | Partly. The VPN provider sees what the ISP would have seen. |
| Reaching a private network remotely | Yes. This is the original purpose. |
| Avoiding advertising trackers | No. Use browser protections and blockers. |
| Anonymity from a determined adversary | No. A single VPN is not designed for this. |
| Protecting a single internal web service | Possibly an SSH tunnel is enough and exposes less. |
Exercise
A user on hotel Wi-Fi connects to a WireGuard VPN with AllowedIPs = 0.0.0.0/0. Their laptop also has working IPv6 on the hotel network. Name the likely leak, say who can observe the leaked traffic, and give the configuration change that fixes it.
Show answer
IPv6 traffic is not covered by the IPv4-only default route, so it leaves through the hotel network directly and is outside the tunnel. The hotel network operator and anyone else on that network can observe it, including the destinations. Changing AllowedIPs to 0.0.0.0/0, ::/0 (and giving the interface an IPv6 address on the VPN side) routes IPv6 through the tunnel too. Disabling IPv6 on the client is an alternative.
Exercise
Your company uses a remote-access VPN that places every client on the full internal network. Give two ways to limit the damage if one employee's laptop is compromised.
Show answer
Segment access with firewall rules on the VPN interface so each client reaches only the services it needs. Use per-user keys or multi-factor authentication so access can be revoked individually, and monitor or time-limit sessions. Moving to per-service authentication (a zero-trust approach) also removes the assumption that VPN clients are trusted.
Exercise
A commercial VPN advertises "complete anonymity". Give two reasons why a single VPN does not provide that.
Show answer
The VPN operator sees your real source address and all destinations, so trust is concentrated in one party. Websites can still identify you through logins, cookies and browser fingerprints, which the tunnel does not hide. Packet size and timing can also be analysed.