Files
ansible-mln/monitoring/security/FIREWALL_RULES.md
T
2026-10-26 21:01:06 +01:00

5.4 KiB

Firewall Configuration Rules

Updated: 2026-06-10

Overview

Firewall rules for monitoring stack with Wazuh, Dozzle, Beszel, and VPN infrastructure.


monitoring-uber (185.103.167.138)

Inbound Rules (INPUT)

Port Protocol Source Purpose Status
22 TCP Admin IPs SSH administration ALLOW
22 TCP 185.103.166.119 (prod) SSH — BLOCKED DROP
22 TCP 185.103.166.112 (pre-prod) SSH — BLOCKED DROP
22 TCP 80.96.58.164 (s3) SSH — BLOCKED DROP
1514 TCP 185.103.166.119 Wazuh agents (prod) ALLOW
1514 TCP 185.103.166.112 Wazuh agents (pre-prod) ALLOW
51820 UDP Any WireGuard VPN ALLOW
443 TCP 10.0.0.0/24 Wazuh Dashboard (VPN) ALLOW
8080 TCP 10.0.0.0/24 Dozzle logs (VPN) ALLOW
8090 TCP 10.0.0.0/24 Beszel dashboard (VPN only, never public) ALLOW
9000-9001 TCP 10.0.0.0/24 S3/RustFS (VPN) ALLOW
10002 TCP 176.116.0.189, 93.185.167.134, 185.139.215.125, 5.252.20.74 (k3s-prod, hors VPN) Beszel agents k3s — /api/ uniquement, voir nginx.conf ALLOW

Outbound Rules (OUTPUT)

  • Default: ACCEPT (all traffic allowed)
  • Allows DNS, updates, internet access

Forward Rules (FORWARD)

  • Default: DROP (no transit traffic)

Persistence

  • Rules saved to /etc/iptables/rules.v4
  • Auto-loaded on boot via iptables-persistent

vpn-uber (45.150.111.158)

Inbound Rules (INPUT)

Port Protocol Source Purpose Status
22 TCP Any SSH administration ALLOW
51820 UDP Any WireGuard VPN ALLOW
10001 TCP 10.0.0.0/24 Beszel agent (from VPN only) ALLOW

Outbound Rules (OUTPUT)

  • Default: ACCEPT (all traffic allowed)

Forward Rules (FORWARD)

  • Default: ACCEPT
  • Enables routing: wg0 ↔ eth0 (VPN ↔ Internet)
  • ESTABLISHED/RELATED always allowed

Network Features

  • NAT masquerade: eth0 (POSTROUTING)
  • IP forwarding: enabled (net.ipv4.ip_forward=1)
  • Allows VPN clients to reach internet through VPN server

Persistence

  • Rules saved to /etc/iptables/rules.v4
  • IP forwarding saved to /etc/sysctl.conf

Security Hardening

Principle: Least Privilege

  1. SSH restrictions: Production servers (prod, pre-prod, s3) cannot SSH into monitoring-uber

    • Prevents lateral movement if a prod server is compromised
    • Admins must SSH directly to monitoring-uber or via VPN
  2. Service isolation: All user-facing services (Wazuh, Dozzle, Beszel) accessible only via VPN

    • Not exposed to public internet
    • Network: 10.0.0.0/24 (private VPN)
  3. Port whitelist: Only required ports open

    • Wazuh agent ingest: 1514/tcp (prod/pre-prod only)
    • VPN: 51820/udp (all)
    • SSH: 22/tcp (admin access, blocked from prod servers)
    • Monitoring agents: 10001/tcp (VPN only)

Attack Surface Reduction

  • Production agents cannot access monitoring infrastructure
  • Monitoring dashboard only accessible via VPN
  • No exposed dashboards or logs to public internet
  • SSH brute-force: limited by rate (ESTABLISHED/RELATED state tracking)

Updating Rules

monitoring-uber

ssh root@185.103.167.138
./firewall-monitoring-uber.sh

vpn-uber

ssh root@45.150.111.158
./firewall-vpn-server.sh

Verify Rules Applied

# Check current rules
iptables -L INPUT -n
iptables -L FORWARD -n

# Check saved rules
cat /etc/iptables/rules.v4

Restore Rules on Boot

Rules are automatically restored via /etc/iptables/rules.v4 if iptables-persistent is installed:

apt-get install iptables-persistent

Beszel Agent Configuration

Beszel agents installed on all infrastructure servers:

Server Type Port Access
prod-uber Docker 10001 Public IP (185.103.166.119:10001)
pre-prod-uber Docker 10001 Public IP (185.103.166.112:10001)
s3-uber Docker 10001 Public IP (80.96.58.164:10001)
vpn-uber Binarie (systemd) 10001 VPN IP (10.0.0.1:10001)

Note: vpn-uber agent is accessible only from VPN due to firewall rules.

k3s cluster (reverse direction)

Unlike the servers above (Hub connects OUT to the agent), the k3s DaemonSet agents connect OUT to the Hub instead — cluster nodes aren't on the VPN mesh and there's no single stable "agent" endpoint per pod to dial into. Hub's reverse-connection port (10002, see nginx.conf) is exposed publicly but restricted to the 4 k3s-prod node IPs + /api/ path only — the dashboard itself (8090) is never touched by this and stays VPN-only.

Server Type Direction Port Access
k3s-prod (4 nodes) Kubernetes DaemonSet Agent → Hub 10002 (Hub side) Hub's public IP, restricted to the 4 node IPs (see omnex/ansible/inventory/host.ini)

Troubleshooting

Service not reachable

# Check if service is listening
ss -tlnp | grep <port>

# Check firewall allows traffic
iptables -L INPUT -n | grep <port>

# Test connectivity
nc -zv <ip> <port>

SSH access denied from prod

  • Expected behavior (security hardening)
  • Use admin SSH keys or SSH via VPN instead

Beszel agent shows offline

  • Check agent is listening: ss -tlnp | grep 10001
  • Check firewall allows Beszel dashboard to reach agent
  • Verify network routing between monitoring-uber and agent server