VPN (Virtual Private Network) is a critical network security technology that enables remote workers to access company resources, protects connections on public WiFi, and links branch offices together. This article explains how VPN works under the hood, compares WireGuard with OpenVPN, and provides a practical WireGuard configuration guide.
2019Trusted since
B2BData solutions
Data·AIExpertise
Need data solutions for your business?
AlgoData has helped businesses with data engineering, analytics & AI since 2019.
A VPN (Virtual Private Network) creates an encrypted tunnel between your device and a VPN server. Instead of your traffic traveling directly to the internet and exposing your real IP address, all data is encrypted and only decrypted at the VPN server end.
How it works:
Your device establishes an encrypted connection to the VPN server
All traffic is encapsulated and encrypted inside the tunnel
The VPN server decrypts the traffic and forwards the request to the real destination
The response travels back through the same tunnel
The destination website sees only the VPN server's IP address
Why do you need a VPN?
Remote work: Employees working remotely need access to internal resources (file servers, databases, internal tools)
Public WiFi: Coffee shops, airports — unencrypted WiFi is easy to eavesdrop on
Privacy: Hide your real IP from websites and your ISP
Site-to-site: Connect branch offices to each other or to a data center
VPN Protocols
WireGuard (Recommended)
The most modern protocol, designed from the ground up for performance and security:
~4,000 lines of code (easy to audit, small attack surface)
Uses UDP — faster than TCP, slightly less reliable but fine for VPN usage
Integrated into the Linux kernel since version 5.6 (2020)
Extremely fast reconnect when switching networks (roaming)
OpenVPN
The oldest and most mature VPN protocol:
~100,000 lines of code — more complex, more feature-rich
Supports both TCP and UDP
Can run on port 443 (same as HTTPS) to bypass strict firewalls
Supported on virtually all platforms
Widely used in enterprise environments
IPsec/IKEv2
Industry standard, built into iOS/Android/Windows natively
IKEv2 is especially suited for mobile: fast reconnect when switching networks (WiFi to 4G)
Common in corporate VPN solutions (Cisco AnyConnect, Juniper)
L2TP/PPTP (Legacy)
PPTP: Do not use — broken since 1999, not secure
L2TP/IPsec: Still functional but WireGuard is significantly better
Practical WireGuard Configuration
Installing WireGuard on Ubuntu:
Bash
1# Install WireGuard2apt update && apt install wireguard
34# Generate key pair (server)5wg genkey | tee /etc/wireguard/server_private.key | wg pubkey > /etc/wireguard/server_public.key
67# Generate key pair (client)8wg genkey | tee client_private.key | wg pubkey > client_public.key
Server config — /etc/wireguard/wg0.conf:
ini
1[Interface] 2Address=10.0.0.1/24 3PrivateKey=<server-private-key> 4ListenPort=51820 5 6# Enable NAT so clients have internet access 7PostUp=iptables -A FORWARD -i wg0 -j ACCEPT; iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE 8PostDown=iptables -D FORWARD -i wg0 -j ACCEPT; iptables -t nat -D POSTROUTING -o eth0 -j MASQUERADE 910[Peer]11# Client 112PublicKey=<client-public-key>13AllowedIPs=10.0.0.2/32
Client config:
ini
1[Interface] 2Address=10.0.0.2/24 3PrivateKey=<client-private-key> 4DNS=1.1.1.1 5 6[Peer] 7PublicKey=<server-public-key> 8Endpoint=203.0.113.1:51820 9AllowedIPs=0.0.0.0/0 # Route all traffic through VPN10PersistentKeepalive=25 # Keep connection alive through NAT
Starting WireGuard:
Bash
1# Bring up the WireGuard interface 2wg-quick up wg0
3 4# Check status 5wg show
6 7# Enable auto-start on boot 8systemctl enable wg-quick@wg0
910# View traffic statistics11wg show wg0 transfer
Verifying the tunnel is active:
Bash
1# Check your public IP — should show VPN server IP2curl ifconfig.me
34# Confirm the WireGuard interface is up5ip addr show wg0
67# Test DNS resolution through the tunnel8nslookup google.com 1.1.1.1
Site-to-Site vs Remote Access VPN
Site-to-site VPN — connects two fixed networks:
No VPN client needed on individual employee machines
The routers/firewalls at both offices establish the tunnel between them
Employees at office A can access resources at office B as if they were on the same network
Remote access VPN — employees connect from anywhere:
Each employee installs a VPN client (WireGuard, OpenVPN, Cisco AnyConnect, etc.)
Connects to the company's VPN gateway
Once connected, can access all internal resources
Which type should you choose?
Fixed office ↔ data center: Site-to-site
Work from home, remote teams: Remote access
A combination of both: common in large enterprises
Common use cases:
Startup with cloud infra + WFH team: WireGuard remote access VPN on a small VPS
Multi-office company: IPsec site-to-site between branch routers
Enterprise with compliance requirements: Cisco AnyConnect with certificate-based auth
VPN vs Proxy
Criteria
VPN
Proxy
Encryption
Always
Depends (HTTP proxy = none)
Scope
Entire OS
Single application
DNS
Through VPN (leak protection)
App decides
Speed
Slightly slower
Faster
Setup
OS-level
Per-app config
Use case
Remote work, full privacy
Web dev, bypass, debugging
When to use a VPN:
You need to encrypt all traffic from your device
Remote employees need access to internal company resources
Connecting two offices or networks together
Privacy from your ISP on untrusted networks
When a proxy is enough:
You only need to route a single application's traffic
Web scraping or testing geo-restricted content in a browser
Development proxy (like Charles Proxy) to inspect HTTP traffic
A VPN (Virtual Private Network) creates an encrypted tunnel between your device and a VPN server. All your traffic passes through this tunnel, hiding your real IP address and encrypting your data. Websites and destination servers only see the VPN server's IP address, not your real one.
QHow does WireGuard differ from OpenVPN?
WireGuard has only ~4,000 lines of code, uses UDP, and has been integrated directly into the Linux kernel since version 5.6. It is extremely fast, easy to audit, and simple to configure. OpenVPN has a longer history (2001), ~100,000 lines of code, supports more options (TCP/UDP, port 443 to bypass firewalls), but is more complex and slower. WireGuard is the default choice for new deployments.
QDoes a VPN completely hide your identity?
Not completely. Your VPN provider can still see all your traffic — choose a reputable provider. Additionally: (1) DNS leaks — if DNS queries do not go through the VPN, your ISP can still see what you access; (2) WebRTC leaks — browsers may expose your real IP via WebRTC even when using a VPN; (3) Device fingerprinting — websites can identify you through browser fingerprints without needing your IP. Use a kill switch and DNS-over-VPN to reduce risk.
QWhat is split tunneling?
Split tunneling is a feature that routes only a portion of traffic through the VPN while the rest goes directly to the internet. For example: traffic to internal company servers goes through the VPN (to access internal resources), while Netflix/YouTube goes directly to the internet (to avoid VPN overhead). Most enterprise VPN clients support split tunneling.
QHow does site-to-site VPN differ from remote access VPN?
Site-to-site VPN connects two fixed networks together — for example, an office in one city connected to another office: both LANs connect as if they were a single network, without needing configuration on each employee's machine. Remote access VPN allows individual employees to connect remotely to the company network from anywhere — a VPN client is required on each personal device.
QDoes a VPN slow down internet speed?
Yes, because every packet must be encrypted/decrypted and routed through an intermediate server. In practice, WireGuard is about 40% faster than OpenVPN in real-world benchmarks. Speed also depends on the distance to the VPN server (a nearby server is faster than one in another country), the provider's bandwidth, and the current server load. Under normal conditions with a nearby server, the difference is usually less than 20%.