Skip to content

Nuface Blog

隨意隨手記 Casual Notes

Menu
  • Home
  • About
  • Services
  • Blog
  • Contact
  • Privacy Policy
  • Login
Menu

Building a Secure OpenVPN Server on OPNsense — Step-by-Step Practical Guide

Posted on 2025-11-062025-11-11 by Rico

Author: Rico Wu
Environment: OPNsense 25.x
Use case: Remote work, branch office connectivity, employee VPN


1️⃣ Why OPNsense + OpenVPN?

OpenVPN is an open-source, SSL-based VPN protocol that’s secure, cross-platform, and reliable.
OPNsense provides a built-in GUI for managing OpenVPN — allowing administrators to quickly deploy:

  • ✅ Remote Access VPN for employees
  • ✅ Site-to-Site VPN between offices
  • ✅ User-based certificate authentication
  • ✅ One-click .ovpn configuration export

This makes OPNsense a strong, cost-free VPN gateway for modern hybrid work.


2️⃣ Create the OpenVPN Server

Step 1 — Create a Certificate Authority (CA)

System → Trust → Authorities → +Add

Descriptive name: VPN_CA
Method: Create an internal Certificate Authority
Key length: 4096
Digest algorithm: SHA256
Lifetime: 3650

Step 2 — Create the Server Certificate

System → Trust → Certificates → +Add

Descriptive name: VPN_Server
Method: Create an internal Certificate
Certificate Authority: VPN_CA
Type: Server Certificate
Lifetime: 1095

Step 3 — Configure the OpenVPN Server

VPN → OpenVPN → Servers → +Add

Recommended settings:

FieldValue
Server ModeRemote Access (SSL/TLS + User Auth)
ProtocolUDP
InterfaceWAN
Tunnel Network10.8.0.0/24
Local Network192.168.1.0/24
EncryptionAES-256-GCM
Auth DigestSHA256
TLS AuthenticationEnabled
Redirect Gateway✅

Save and Apply.


3️⃣ Create Users and Certificates

System → Access → Users → +Add

Username: rico
Password: *****

Click “Create Certificate” → choose VPN_CA → type: User Certificate.


4️⃣ Export Client Configuration

VPN → OpenVPN → Client Export

Select your VPN server and user, then choose:

  • “File Only” → .ovpn file
  • or “Windows Installer” for prepackaged setup

5️⃣ Client-Side Setup

🪟 Windows

  1. Install OpenVPN Connect
  2. Import .ovpn
  3. Click Connect

🐧 Linux

sudo apt install openvpn
sudo openvpn --config rico.ovpn

🍏 macOS / iOS / Android

Use OpenVPN Connect App, import file, and connect.


6️⃣ Allow Access to Multiple Internal Networks

If your internal network has multiple subnets:

LAN1: 192.168.1.0/24
LAN2: 192.168.2.0/24

In VPN → OpenVPN → Servers → Routing → Local Network:

192.168.1.0/24,192.168.2.0/24

Then add a firewall rule:

Firewall → Rules → OpenVPN

Action: Pass
Source: 10.8.0.0/24
Destination: any

7️⃣ Firewall and NAT Configuration

WAN Rule

Action: Pass
Protocol: UDP
Port: 1194

Outbound NAT (Hybrid Mode)

Source: 10.8.0.0/24
Translation: Interface Address (WAN)

8️⃣ Troubleshooting Checklist

ProblemSolution
Cannot connectEnsure UDP/1194 is open
Connected but no InternetEnable “Redirect Gateway” or adjust NAT
Certificate errorCheck CA relationships
Multi-subnet access failsAdd routes or update Local Network
Gateway offlineVerify upstream connectivity

9️⃣ Network Topology Example

[ Internet ]
     |
  (WAN)
[ OPNsense VPN Server ]
     |      \
     |       [192.168.1.0/24]
     |       [192.168.2.0/24]
     |
[ Remote Client 10.8.0.x ]

✅ Conclusion

With OPNsense’s integrated OpenVPN management, building a secure enterprise VPN is straightforward.
You can easily control users, manage certificates, and support multiple internal networks — all from a clean web GUI.

This combination delivers secure, stable, and scalable remote access for distributed teams and branch offices.

Recent Posts

  • Postfix + Let’s Encrypt + BIND9 + DANE Fully Automated TLSA Update Guide
  • Postfix + Let’s Encrypt + BIND9 + DANE TLSA 指紋自動更新完整教學
  • Deploying DANE in Postfix
  • 如何在 Postfix 中部署 DANE
  • DANE: DNSSEC-Based TLS Protection

Recent Comments

  1. Building a Complete Enterprise-Grade Mail System (Overview) - Nuface Blog on High Availability Architecture, Failover, GeoDNS, Monitoring, and Email Abuse Automation (SOAR)
  2. Building a Complete Enterprise-Grade Mail System (Overview) - Nuface Blog on MariaDB + PostfixAdmin: The Core of Virtual Domain & Mailbox Management
  3. Building a Complete Enterprise-Grade Mail System (Overview) - Nuface Blog on Daily Operations, Monitoring, and Performance Tuning for an Enterprise Mail System
  4. Building a Complete Enterprise-Grade Mail System (Overview) - Nuface Blog on Final Chapter: Complete Troubleshooting Guide & Frequently Asked Questions (FAQ)
  5. Building a Complete Enterprise-Grade Mail System (Overview) - Nuface Blog on Network Architecture, DNS Configuration, TLS Design, and Postfix/Dovecot SNI Explained

Archives

  • December 2025
  • November 2025
  • October 2025

Categories

  • AI
  • Apache
  • Cybersecurity
  • Database
  • DNS
  • Docker
  • Fail2Ban
  • FileSystem
  • Firewall
  • Linux
  • LLM
  • Mail
  • N8N
  • OpenLdap
  • OPNsense
  • PHP
  • QoS
  • Samba
  • Switch
  • Virtualization
  • VPN
  • WordPress
© 2025 Nuface Blog | Powered by Superbs Personal Blog theme