Ctrl K
ring2all.com

Firewall Rules Module Documentation

Table of Contents

  1. Module Overview (Technical)
  2. Module Overview (Commercial/Business)
  3. Module Overview (End User/Administrator)
  4. Configuration Sections
  5. Settings Reference
  6. Common Scenarios & Examples
  7. Limitations & Important Notes
  8. Troubleshooting Tips
  9. Glossary

---

1. Module Overview (Technical)

What Are Firewall Rules?

Firewall Rules is a traffic control module that creates nftables rules for accepting, dropping, or rejecting network traffic. Rules reference Firewall Services and are evaluated in priority order.

Architecture

Plaintext
┌─────────────────────────────────────────────────────────────────┐
│              Firewall Rules Architecture                       │
├─────────────────────────────────────────────────────────────────┤
│                                                                 │
│  Rule Definitions                                               │
│  ┌──────────────────────────────────────────────────────────┐   │
│  │                                                          │   │
│  │  Priority: 10                    Priority: 20            │   │
│  │  ┌────────────────────┐         ┌────────────────────┐   │   │
│  │  │ Allow Admin SSH    │         │ Allow HTTP         │   │   │
│  │  │ Action: Accept     │         │ Action: Accept     │   │   │
│  │  │ Direction: Input   │         │ Direction: Input   │   │   │
│  │  │ Service: SSH       │         │ Service: HTTP      │   │   │
│  │  │ Source: 10.0.0.5   │         │ Source: any        │   │   │
│  │  └────────────────────┘         └────────────────────┘   │   │
│  │                                                          │   │
│  │  Priority: 100                   Priority: 200           │   │
│  │  ┌────────────────────┐         ┌────────────────────┐   │   │
│  │  │ Allow SIP LAN      │         │ Block SSH External │   │   │
│  │  │ Action: Accept     │         │ Action: Drop       │   │   │
│  │  │ Direction: Input   │         │ Direction: Input   │   │   │
│  │  │ Service: SIP       │         │ Service: SSH       │   │   │
│  │  │ Source: 192.168.x  │         │ Source: any        │   │   │
│  │  └────────────────────┘         └────────────────────┘   │   │
│  │                                                          │   │
│  └──────────────────────────────────────────────────────────┘   │
│       │                                                         │
│       ▼ [Apply Rules]                                          │
│  ┌──────────────────────────────────────────────────────────┐   │
│  │        nftables Configuration                            │   │
│  │                                                          │   │
│  │  table inet filter {                                    │   │
│  │    chain input {                                        │   │
│  │      # Priority 10: Allow Admin SSH                     │   │
│  │      ip saddr 10.0.0.5 tcp dport 22 accept              │   │
│  │      # Priority 20: Allow HTTP                          │   │
│  │      tcp dport 80 accept                                │   │
│  │      # Priority 100: Allow SIP LAN                      │   │
│  │      ip saddr 192.168.0.0/16 udp dport 5060 accept      │   │
│  │      # Priority 200: Block SSH External                 │   │
│  │      tcp dport 22 drop                                  │   │
│  │    }                                                     │   │
│  │  }                                                       │   │
│  │                                                          │   │
│  └──────────────────────────────────────────────────────────┘   │
│                                                                 │
└─────────────────────────────────────────────────────────────────┘

Key Tables

TablePurpose
public.firewall_rulesRule definitions

Key Files

FileDescription
modules/firewallRules/Frontend module
/etc/nftables.confApplied rules
---

2. Module Overview (Commercial/Business)

Business Value

Firewall Rules provides network traffic control:

Without RulesWith Rules
Open accessControlled traffic
No priorityOrdered evaluation
Manual nftablesWeb interface
Complex syntaxSimple forms

Use Cases

  1. Allow Services
- Web traffic (HTTP/HTTPS)

- SIP/RTP for telephony

  1. Block Attacks
- Drop external SSH

- Reject scanners

  1. LAN Access Only
- SIP from internal only

- Admin from VPN only

  1. Priority Control
- Allow before block

- Specific before general

Feature Highlights

FeatureBenefit
Accept/Drop/RejectFlexible actions
Priority OrderControlled evaluation
Service ReferenceReusable definitions
Source/Dest FilterIP-based access
Interface BindingPer-interface rules
Apply ButtonControlled deployment
---

3. Module Overview (End User/Administrator)

What Can You Do?

  • Create traffic rules
  • Allow or block traffic
  • Set priority order
  • Filter by IP address
  • Bind to interfaces
  • Apply rules to nftables
  • Enable/disable rules

Firewall Rules Interface

Plaintext
┌─────────────────────────────────────────────────────────────────┐
│              Firewall Rules                                     │
├─────────────────────────────────────────────────────────────────┤
│                                                                 │
│  Manage firewall rules for nftables (Debian 13)                │
│                                                                 │
│  [+ Add Rule]  [Apply Rules]                                    │
│                                                                 │
│  [🔍 Search rules...]                                           │
│                                                                 │
│  ┌───────────────────────────────────────────────────────────┐  │
│  │ Name          │ Action│ Direction│ Service│ Priority│ St │  │
│  ├───────────────┼───────┼──────────┼────────┼─────────┼────┤  │
│  │ Allow Admin   │ Accept│ Input    │ SSH    │ 10      │ ●  │  │
│  │ Allow HTTP    │ Accept│ Input    │ HTTP   │ 20      │ ●  │  │
│  │ Allow HTTPS   │ Accept│ Input    │ HTTPS  │ 30      │ ●  │  │
│  │ Allow SIP LAN │ Accept│ Input    │ SIP    │ 100     │ ●  │  │
│  │ Allow RTP     │ Accept│ Input    │ RTP    │ 110     │ ●  │  │
│  │ Block SSH Ext │ Drop  │ Input    │ SSH    │ 200     │ ●  │  │
│  │ Block All     │ Drop  │ Input    │ -      │ 9999    │ ○  │  │
│  └───────────────────────────────────────────────────────────┘  │
│                                                                 │
│  ⚠️ Click "Apply Rules" after changes                          │
│                                                                 │
└─────────────────────────────────────────────────────────────────┘

Add/Edit Rule

Plaintext
┌─────────────────────────────────────────────────────────────────┐
│              Add Firewall Rule                                  │
├─────────────────────────────────────────────────────────────────┤
│                                                                 │
│  Rule Name: [Allow SIP from LAN              ]                 │
│    Descriptive name for the rule (must be unique)              │
│                                                                 │
│  Action: [Accept ▼]                                            │
│    Accept (allow) | Drop (silent block) | Reject (block+respond)│
│                                                                 │
│  Direction: [Input ▼]                                          │
│    Input (to server) | Output (from server) | Forward (routed) │
│                                                                 │
│  Service: [SIP ▼]                                              │
│    Associated firewall service (required)                       │
│    The rule will use the selected service's protocol and port  │
│                                                                 │
│  Priority: [100           ]                                    │
│    Rule priority (0-9999). Lower numbers are evaluated first   │
│                                                                 │
│  ──────────────────────────────────────────────────────────────│
│                                                                 │
│  Source Address: [192.168.1.0/24             ]                 │
│    Optional: Source IP address or CIDR network                 │
│                                                                 │
│  Destination Address: [                      ]                 │
│    Optional: Destination IP address or CIDR network            │
│                                                                 │
│  Interface: [eth0                            ]                 │
│    Optional: Network interface (e.g., eth0, ens33)             │
│                                                                 │
│  ──────────────────────────────────────────────────────────────│
│                                                                 │
│  Enabled: ✓                                                    │
│    Disabled rules will not be applied to nftables              │
│                                                                 │
│  [Save] [Cancel]                                                │
│                                                                 │
└─────────────────────────────────────────────────────────────────┘

Quick Tips

TIP
Priority: Lower numbers execute first. Allow admin access at low priority!
TIP
Apply Rules: Always click after making changes.
CAUTION
Don't Block Yourself: Create allow rule for your IP before blocking!

---

4. Configuration Sections

Rule Fields

FieldDescription
Rule NameUnique identifier
ActionAccept, Drop, Reject
DirectionInput, Output, Forward
ServiceService reference (required)
PriorityOrder (0-9999)
Source AddressSource IP/CIDR (optional)
Destination AddressDest IP/CIDR (optional)
InterfaceNetwork interface (optional)
EnabledActive/Inactive
---

5. Settings Reference

Actions

ActionBehaviorResponseUse Case
AcceptAllow traffic-Permitted traffic
DropBlock silentlyNoneStealth blocking
RejectBlock with responseICMP errorInform sender

Directions

DirectionDescriptionExample
InputTraffic TO serverWeb requests
OutputTraffic FROM serverAPI calls
ForwardRouted trafficNAT/routing

Priority Guidelines

Priority RangeUse
1-50Critical allows (admin access)
51-100Standard allows (web, API)
101-200Service allows (SIP, RTP)
201-500Specific blocks
501-9999Broad blocks, catch-all

Priority Examples

Plaintext
Priority 10:  Allow Admin SSH (source: admin IP)
Priority 20:  Allow HTTP (any source)
Priority 100: Allow SIP LAN (source: 192.168.x)
Priority 200: Block SSH External (any source)
Priority 9999: Block All (catch-all)

---

6. Common Scenarios & Examples

Scenario 1: Allow HTTP/HTTPS

  1. Add Rule
  2. Name = "Allow HTTP"
  3. Action = Accept
  4. Direction = Input
  5. Service = HTTP
  6. Priority = 20
  7. Save
  8. Repeat for HTTPS (Priority 30)
  9. Apply Rules

Scenario 2: Allow SIP from LAN Only

  1. Add Rule
  2. Name = "Allow SIP LAN"
  3. Action = Accept
  4. Direction = Input
  5. Service = SIP
  6. Priority = 100
  7. Source = 192.168.1.0/24
  8. Save
  9. Apply Rules

Scenario 3: Block External SSH

  1. First: Create "Allow Admin SSH" (Priority 10, Source: your IP)
  2. Add Rule
  3. Name = "Block SSH External"
  4. Action = Drop
  5. Direction = Input
  6. Service = SSH
  7. Priority = 200
  8. (No source = all sources)
  9. Save
  10. Apply Rules

Scenario 4: Complete PBX Ruleset

Plaintext
Priority 10:  Allow Admin SSH     (Source: admin IP)
Priority 20:  Allow HTTP          (Any - redirect to HTTPS)
Priority 30:  Allow HTTPS         (Any - includes WebRTC WSS proxy)
Priority 100: Allow SIP UDP       (Source: LAN + Trunks)
Priority 110: Allow SIP TLS       (Source: LAN + Trunks)
Priority 120: Allow RTP           (Any)
Priority 130: Allow STUN          (Any - NAT traversal)
Priority 131: Allow TURN TLS      (Any - NAT traversal)
Priority 200: Block SSH External  (Any)
Priority 300: Block SIP External  (Any)

---

7. Limitations & Important Notes

Technical Notes

NOTE
Apply Required: Rules don't take effect until applied.
NOTE
Priority Order: Lower numbers are processed first.
CAUTION
Lock-Out Risk: Always allow admin access before blocking!

Best Practices

  1. Admin First: Always create allow rule for admin access first
  2. Specific Before General: Narrow rules before broad blocks
  3. Meaningful Names: Clear, descriptive rule names
  4. Document Purpose: Use consistent naming convention
  5. Test Changes: Verify access after applying
  6. Backup Access: Have console/IPMI access available

Rule Evaluation Order

Plaintext
1. Enabled rules only
2. Sorted by priority (ascending)
3. First matching rule wins
4. If no match, default policy applies

Common Mistakes

MistakeResultPrevention
Block before allowLocked outLower priority for blocks
No admin allowCan't accessPriority 1-10 admin rules
Forgot ApplyRules inactiveAlways click Apply
Wrong directionNot matchingVerify Input vs Output
---

8. Troubleshooting Tips

Common Issues

SymptomPossible CauseSolution
Rule not workingNot appliedClick Apply Rules
Blocked trafficPriority wrongCheck priority order
Can't connectLocked outConsole access
Service not in listDisabled serviceEnable in Services

Check Rules

Sql
SELECT 
  name,
  action,
  direction,
  priority,
  source_address,
  is_enabled
FROM public.firewall_rules
ORDER BY priority;

nftables Commands

Bash
# View current rules
nft list ruleset

# View input chain
nft list chain inet filter input

# Flush rules (emergency)
nft flush ruleset

Emergency Recovery

Bash
# If locked out via SSH:
# 1. Access server console (IPMI, KVM, physical)
# 2. Disable firewall temporarily
systemctl stop nftables

# 3. Fix rules via admin panel
# 4. Re-enable firewall
systemctl start nftables

---

9. Glossary

TermDefinition
RuleTraffic control statement
ActionWhat to do (accept/drop/reject)
DirectionTraffic flow direction
PriorityRule evaluation order
nftablesLinux firewall framework
ChainRule processing group
---

Lua Script Status ℹ️

Security Module

ComponentStatus
Firewall Rulesℹ️ Traffic rules - no Lua handler required
Firewall Rules is a security configuration module. It creates nftables rules for traffic control. No Lua handlers are used - rules are applied to the Linux firewall by the backend service.

---

Documentation last updated: January 2026
AI Assistant

👋 Hello! I'm your Ring2All documentation assistant. I can help you find information about configuring and using the Ring2All PBX platform.

How can I help you today?