TLS, IPsec, and VPN: Network Traffic Encryption
How TLS, IPsec, and VPNs protect data in transit: TLS handshake, tunnels, when to use what, and common homelab mistakes.
Encryption protects the contents of data as it travels across the network. Three names appear most often: TLS (for applications such as the web), IPsec (for networks), and VPN (as a service that leverages the technologies above). This article explains how each works and when to use them.
TLS: The Key to the Modern Web
TLS (Transport Layer Security) secures application communication, best known as HTTPS. It has three goals, exactly the same as the CIA Triad:
- Confidentiality: the contents of the conversation cannot be read by an eavesdropper.
- Integrity: data modified in transit is detected.
- Authentication: you are sure you are communicating with the correct server (verified via certificate).
How it works in brief:
Client -> Server: "hello, I want a secure connection, these are the ciphers I support"
Server -> Client: "use this cipher. Here is my certificate."
Client: verifies the certificate (CA signature) and creates a session key
Client -> Server: "the session key has been sent, let's start encrypted communication"
Once the session key is established, the contents of the communication are encrypted, and that key is renegotiated periodically. The TLS 1.3 handshake is faster (one round trip) than older versions.
IPsec: Security at the Network Layer
IPsec (IP Security) is a protocol framework for securing IP traffic between devices or between networks. Its two main modes:
- Transport mode: only the packet payload is protected, the original header remains. Suitable for device-to-device communication.
- Tunnel mode: the entire packet is wrapped in a new packet. This is what is commonly used for site-to-site VPNs between offices.
IPsec consists of two core protocols:
| Protocol | Function |
|---|---|
| AH | Integrity and authentication (does not encrypt the payload) |
| ESP | Confidentiality (encryption) + integrity + authentication |
IPsec also needs a key exchange mechanism, usually IKE, which establishes the session and the keys used by ESP/AH.
VPN: A Bridge Between Two Networks
VPN (Virtual Private Network) is a product term and a technique, not a single protocol. It creates a secure connection from one point to another over a public network, as if the two were connected directly on a private network.
Examples of VPN use:
- Remote access: an employee at home “enters” the office network over the internet.
- Site-to-site: two offices in different cities are connected as if they were one network.
- Privacy / personal tunneling: (depending on the provider’s policy; if used to bypass restrictions, pay attention to each country’s rules).
A common misconception: a VPN does not make you “anonymous.” A VPN protects the contents and destination address from the ISP and local network, but the VPN provider itself can still see your traffic. Choose a provider that does not keep logs, or better yet, self-host for full control.
Modern VPN: WireGuard
Amid older technologies (OpenVPN, IPsec with lots of configuration), WireGuard has emerged as a modern VPN that is far simpler and faster. It uses state-of-the-art cryptography and a minimal design, making its security audits easier.
# On the server: generate keypair
wg genkey | tee privatekey | wg pubkey > publickey
# Basic WireGuard peer configuration on the server
# [Interface] Address = 10.0.0.1/24, ListenPort = 51820
# [Peer] PublicKey = <publickey-peer>, AllowedIPs = 10.0.0.2/32
WireGuard is well suited to a homelab because setup is brief and performance is good. Even so, first learn WireGuard’s crypto concepts (curve25519, ChaCha20, Poly1305) from the official documentation before adopting it for important purposes.
When to Use What?
- Website / API: TLS (HTTPS).
- Remote access to a single server: SSH (already encrypted by default).
- Access to the office network from outside: remote-access VPN (WireGuard / OpenVPN / IPsec).
- Connecting two offices: site-to-site VPN (IPsec or WireGuard tunnel).
- Traffic isolation within the same network: TLS between services.
Do not stack them. You do not need a VPN on top of HTTPS, and you do not need TLS twice. Each layer adds complexity, which also adds points of misconfiguration.
Common Homelab Traps
- Placing full trust in a VPN without restricting access. A VPN grants network access; still configure a firewall at the destination.
- Using self-signed certificates for public HTTPS.
- Opening a VPN port to the internet without rate limiting and monitoring. Use features such as fail2ban.
- Not updating old, already vulnerable protocols (for example TLS 1.0/1.1, which should be disabled).
Next in the curriculum: encryption also applies to wireless access, read WiFi security: WPA2, WPA3, 802.1X, and Rogue AP.
References
- RFC 8446, The Transport Layer Security (TLS) Protocol Version 1.3, rfc-editor.org/rfc/rfc8446.
- RFC 4301, Security Architecture for the Internet Protocol, rfc-editor.org/rfc/rfc4301 (IPsec architecture).
- RFC 7296, Internet Key Exchange Protocol Version 2 (IKEv2), rfc-editor.org/rfc/rfc7296.
- Jason A. Donenfeld, WireGuard: Next Generation Kernel Network Tunnel, wireguard.com/papers/wireguard.pdf (WireGuard design).
- RFC 7525, Recommendations for Secure Use of TLS, rfc-editor.org/rfc/rfc7525 (TLS best practices for implementers).
Related Articles
WiFi Security: WPA2, WPA3, 802.1X, and Rogue AP
Secure wireless networks: strengths and weaknesses of WPA2 through WPA3, enterprise 802.1X, how to detect rogue access points, and safe home WiFi practices.
NetworkingJump Host and ProxyJump: Multi-Server SSH Infrastructure
Manage many servers through one entry point: bastion concepts, ProxyJump, chained keywords, and secure patterns across networks from lab to production.
NetworkingNetworking Certification Paths for Your Career: Cisco, Juniper, MikroTik
A complete guide to networking certification paths: Cisco's CCST/CCNA/CCNP/CCIE, Juniper's JNCIA/JNCIS/JNCIP/JNCIE, and MikroTik's MTCNA/MTCRE, plus network engineer career prospects in Indonesia.
Your ideas deserve to be read by thousands of people.
ByteNesia is built for everyone. If you have experience, tutorials, or opinions about technology, write and share them here. Your name will be credited as a contributor.
Write anything: tool reviews, homelab tutorials, security tips, or your tech stories.