Skip to main content

Lesson 4 of 10

VPNs & Secure Remote Access

VPNs (Virtual Private Networks) create encrypted tunnels for secure remote access to internal resources. In the era of remote work, proper VPN implementation is critical for protecting corporate resources.

50 minBy Priygop Editorial TeamUpdated 2026Peer Reviewed & Verified

VPN Types for Different Use Cases

  • Site-to-site VPN: Connects two office networks via encrypted tunnel - all traffic between offices flows through the VPN automatically. Implemented on router/firewall hardware. IPSec is the standard protocol
  • Remote access VPN (client VPN): Individual users connect to the corporate network from any location. Options: OpenVPN (software), WireGuard (modern, fast), Cisco AnyConnect, GlobalProtect (PAN-OS)
  • Split tunneling: Only corporate traffic goes through VPN; internet traffic goes direct. Faster but internet activity bypasses corporate security controls (web filtering, DLP). Full tunnel: ALL traffic routes through VPN - enforces security controls but slower
  • SSL VPN: Browser-based VPN via HTTPS - no client software required. Good for partner/contractor access. Less secure than full VPN client - limited to web-based resources
  • Zero Trust Network Access (ZTNA): Modern VPN replacement - provides application-level access (not network-level) based on identity and device posture. Vendor examples: Cloudflare Access, Zscaler ZPA

WireGuard Server Configuration

WireGuard Server Configuration
# WireGuard - Modern, high-performance VPN (Linux kernel 5.6+)
# Minimal configuration, excellent performance, strong cryptography

# Install
apt install wireguard

# Generate server key pair
wg genkey | tee /etc/wireguard/server_private.key | wg pubkey > /etc/wireguard/server_public.key
chmod 600 /etc/wireguard/server_private.key

# /etc/wireguard/wg0.conf - Server configuration
[Interface]
PrivateKey = <SERVER_PRIVATE_KEY>
Address = 10.0.0.1/24          # VPN subnet - server is .1
ListenPort = 51820              # UDP port (open in firewall)
PostUp = iptables -A FORWARD -i %i -j ACCEPT; iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
PostDown = iptables -D FORWARD -i %i -j ACCEPT; iptables -t nat -D POSTROUTING -o eth0 -j MASQUERADE

# Client 1 (Alice's laptop)
[Peer]
PublicKey = <ALICE_PUBLIC_KEY>
AllowedIPs = 10.0.0.2/32        # Only Alice's VPN IP

# Client 2 (Bob's workstation)
[Peer]
PublicKey = <BOB_PUBLIC_KEY>
AllowedIPs = 10.0.0.3/32

# Enable IP forwarding and start WireGuard
echo 'net.ipv4.ip_forward=1' >> /etc/sysctl.conf && sysctl -p
wg-quick up wg0
systemctl enable wg-quick@wg0

# Client-side configuration
# [Interface]
# PrivateKey = <ALICE_PRIVATE_KEY>
# Address = 10.0.0.2/24
# DNS = 10.0.0.1             # Use corporate DNS over VPN
#
# [Peer]
# PublicKey = <SERVER_PUBLIC_KEY>
# Endpoint = vpn.company.com:51820
# AllowedIPs = 0.0.0.0/0    # Full tunnel - all traffic through VPN

Common Mistakes

  • Using PPTP - PPTP uses MS-CHAPv2 which is completely broken; a captured PPTP exchange can be cracked in hours. Use WireGuard or OpenVPN
  • Not requiring MFA on VPN - if VPN credentials are compromised, MFA prevents unauthorized access. Require TOTP or hardware key in addition to password
  • Split tunnel without DNS controls - users on split tunnel bypass corporate DNS filtering; malware on user devices can use C2 over non-corporate DNS channels

Tip

Tip

Practice VPNs Secure Remote Access in small, isolated examples before integrating into larger projects. Breaking concepts into small experiments builds genuine understanding faster than reading alone.

Diagram
Loading diagram…

The foundational security model: Confidentiality (privacy), Integrity (trust), and Availability (uptime).

Practice Task

Note

Practice Task - (1) Write a working example of VPNs Secure Remote Access from scratch without looking at notes. (2) Modify it to handle an edge case (empty input, null value, or error state). (3) Share your solution in the Priygop community for feedback.

Quick Quiz

Common Mistake

Warning

A common mistake with VPNs Secure Remote Access is skipping edge case testing - empty inputs, null values, and unexpected data types. Always validate boundary conditions to write robust, production-ready cybersecurity code.

Key Takeaways

  • VPNs (Virtual Private Networks) create encrypted tunnels for secure remote access to internal resources.
  • Site-to-site VPN: Connects two office networks via encrypted tunnel - all traffic between offices flows through the VPN automatically. Implemented on router/firewall hardware. IPSec is the standard protocol
  • Remote access VPN (client VPN): Individual users connect to the corporate network from any location. Options: OpenVPN (software), WireGuard (modern, fast), Cisco AnyConnect, GlobalProtect (PAN-OS)
  • Split tunneling: Only corporate traffic goes through VPN; internet traffic goes direct. Faster but internet activity bypasses corporate security controls (web filtering, DLP). Full tunnel: ALL traffic routes through VPN - enforces security controls but slower

Hands-on Practice Tools for this Course

Test what you learn using these free in-browser developer utilities (no signup required).

All 40+ Tools

Topics in This Module

0/10 done