Skip to content

Nuface Blog

隨意隨手記 Casual Notes

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

OPNsense Firewall Rules: Functions & Usage

Posted on 2025-11-112025-11-11 by Rico

🧭 1. What Are Firewall Rules?

Firewall rules in OPNsense define the core behavior of network traffic.
They determine which packets are allowed, blocked, or rejected when traversing the firewall.

Rules are evaluated at the packet filter layer, inspecting parameters such as source, destination, protocol, and port before applying the defined action.


⚙️ 2. Actions

ActionDescription
PassAllow the packet through.
BlockDrop silently without notifying the sender.
RejectBlock and send a reject message (TCP RST or ICMP).

💡 Tip:
Use Block on WAN for stealth; use Reject on LAN to simplify troubleshooting.


🧩 3. Rule Evaluation Order

According to the official documentation, rule processing follows this order:

1️⃣ Floating Rules – Applied first; can affect multiple interfaces.
2️⃣ Interface Groups – Rules for grouped interfaces.
3️⃣ Interface Rules – Specific to individual interfaces (LAN, WAN, DMZ).

⚡ By default, each rule is Quick, meaning once a rule matches, evaluation stops immediately.


🔧 4. Rule Parameters

ParameterDescription
DirectionUsually “In,” defines packet flow direction.
InterfaceThe network interface the rule applies to.
ProtocolTCP, UDP, ICMP, or any.
Source / DestinationIP addresses or aliases.
Port(s)TCP/UDP port(s) for service control.
ScheduleOptional time schedule for rule activation.
Category / DescriptionMetadata for organization and management.

🧰 5. Common Use Cases

✅ Allow LAN to Internet

  • Interface: LAN
  • Source: LAN subnet
  • Destination: any
  • Action: Pass
    → Grants outbound Internet access for internal users.

🔒 Block External Access to Internal Server

  • Interface: WAN
  • Source: any
  • Destination: 192.168.1.10:22
  • Action: Block
    → Protects internal SSH from public exposure.

🕐 Scheduled Access

  • Schedule: Mon–Fri 09:00–18:00
  • Action: Pass
    → Allows access only during work hours.

⚡ 6. Advanced Tips & Best Practices

TopicRecommendation
Rule OrderRules are evaluated top-down; first match wins.
NAT OrderNAT executes before firewall filtering—ensure matching pass rules exist.
Floating RulesUse for multi-interface policies or QoS tagging.
Default Policy“Block by default, allow explicitly.”
Admin SafetyAvoid locking yourself out when modifying management rules.

✅ 7. Summary

AspectDescription
Core FunctionPacket filtering and flow control
Evaluation OrderFloating → Group → Interface
Default StrategyDeny by default, allow specific traffic
Real-World UseInternet access, inbound blocking, time-based rules

Firewall rules are the foundation of security in OPNsense.
Proper planning and ordering ensure a secure and stable network environment.

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