OPNSense Security Configuration Guide
This comprehensive guide will help you securely configure your OPNSense firewall following industry best practices and security standards.
1. Initial Setup and Access Control
Change Default Admin Credentials
The default admin credentials should be changed immediately:
- Navigate to System → Access → Users
- Click on the
rootuser - Change the password to a strong passphrase
- Consider creating a separate admin account and disabling root web access
Enable HTTPS and Configure Certificate
Ensure the web interface uses HTTPS with a valid certificate:
- Navigate to System → Settings → Administration
- Ensure Protocol is set to
HTTPS - Generate or import a valid SSL/TLS certificate at System → Trust → Certificates
- Select the certificate in the administration settings
Restrict Management Access
Limit web interface access to specific networks:
- Go to System → Settings → Administration
- Set "Listen Interfaces" to only management interfaces
- Configure allowed IP addresses or networks
- Disable web GUI access from WAN
- Consider using a dedicated management VLAN
2. Firewall Rules Best Practices
Principle of Least Privilege
Apply the principle of least privilege to all firewall rules:
- Only allow necessary traffic
- Deny by default, allow by exception
- Use specific source and destination addresses
- Avoid "any to any" rules
Enable Logging
Enable logging on important rules for security monitoring:
- Log all deny rules for security analysis
- Log critical allow rules
- Review logs regularly using Firewall → Log Files → Live View
- Configure remote syslog for centralized logging
Rule Organization
Organize rules for optimal performance and security:
- Place more specific rules at the top
- Group related rules together
- Use aliases for IP addresses and ports
- Review and clean up unused rules regularly
3. Network Security Configuration
Configure VLANs
Segment your network using VLANs:
- Create separate VLANs for different security zones (DMZ, Guest, Internal, Management)
- Configure inter-VLAN firewall rules at Firewall → Rules
- Isolate untrusted networks from sensitive systems
- Navigate to Interfaces → Other Types → VLAN
Enable IDS/IPS with Suricata
OPNSense includes Suricata for intrusion detection and prevention:
- Navigate to Services → Intrusion Detection
- Enable IDS mode or IPS mode (blocking)
- Select interfaces to protect (WAN and critical interfaces)
- Enable appropriate rule sets (ET Open, Abuse.ch)
- Configure update frequency for rule sets
- Review and tune alerts to minimize false positives
NAT and Port Forwarding
Secure NAT and port forwarding:
- Navigate to Firewall → NAT → Port Forward
- Limit port forwards to specific source IPs when possible
- Use non-standard ports where appropriate
- Enable logging on NAT rules
- Regularly audit port forwards for necessity
4. Service Hardening
SSH Access
If SSH is required, secure it properly:
- Navigate to System → Settings → Administration
- Enable "Secure Shell" only if necessary
- Change the SSH port from default (22)
- Enable "Login Group" to restrict access
- Configure "Permit Root Login" to "No"
- Use key-based authentication when possible
- Restrict SSH access via firewall rules
DNS Configuration
Configure DNS securely with Unbound:
- Navigate to Services → Unbound DNS → General
- Enable Unbound DNS resolver
- Enable DNSSEC validation
- Configure DNS over TLS for upstream queries
- Use reputable DNS servers (Cloudflare 1.1.1.1, Quad9 9.9.9.9)
- Enable query logging for security monitoring
NTP Configuration
Ensure accurate time synchronization:
- Go to System → Settings → General
- Configure multiple reliable NTP time servers
- Set correct timezone
- Enable "Prefer IPv4"
5. VPN Security
OpenVPN Configuration
Secure OpenVPN setup:
- Use certificate-based authentication
- Enable TLS authentication
- Use strong encryption (AES-256-GCM)
- Set appropriate DH parameters (2048-bit minimum)
- Configure client-specific overrides when needed
- Disable LZO compression (security risk)
- Navigate to VPN → OpenVPN
IPsec Configuration
For IPsec VPN tunnels:
- Use IKEv2 instead of IKEv1
- Use strong encryption (AES-256-GCM)
- Enable Perfect Forward Secrecy (PFS)
- Use certificate-based authentication when possible
- Set appropriate key lifetimes
- Navigate to VPN → IPsec
WireGuard (Modern Alternative)
OPNSense supports WireGuard for modern VPN deployments:
- Navigate to VPN → WireGuard
- Create server instance with generated keys
- Configure client instances
- WireGuard uses modern cryptography by default
- Lighter weight and faster than OpenVPN
6. Monitoring and Maintenance
Regular Updates
Keep your system updated:
- Check for updates at System → Firmware → Updates
- Enable automatic update checks
- Subscribe to OPNSense security announcements
- Test updates in a non-production environment first
- Maintain configuration backups before updates
Backup Configuration
Regular backups are essential:
- Navigate to System → Configuration → Backups
- Download configuration regularly
- Store backups securely offline
- Encrypt backup files
- Test restore procedures periodically
- Consider automated backups to remote storage
Log Monitoring
Monitor logs for security events:
- Review firewall logs daily at Firewall → Log Files → Live View
- Monitor system logs for errors
- Check authentication logs for failed attempts
- Configure remote syslog at System → Settings → Logging
- Use log analysis tools for pattern detection
7. Additional Security Measures
Install Security Plugins
Consider these additional security plugins:
- os-acme-client - Let's Encrypt certificate automation
- os-maltrail - Malicious traffic detection
- os-nginx - Reverse proxy with WAF capabilities
- os-crowdsec - Collaborative security intelligence
- Navigate to System → Firmware → Plugins
Disable Unused Services
Reduce attack surface by disabling unnecessary services:
- Disable unused network interfaces
- Remove unnecessary plugins
- Disable unused protocols (RIP, OSPF if not needed)
- Turn off UPnP unless absolutely required
Enable Two-Factor Authentication
Add an extra layer of security:
- Navigate to System → Access → Servers
- Configure TOTP authentication server
- Assign OTP server to users
- Use Google Authenticator or similar app