Sign inSign up

lexlex0/unifarr

By lexlex0

โ€ขUpdated 2 days ago

ALPHA โ€” Self-hosted logs, analysis, reports and safe configuration changes for UniFi firewalls.

Image
Networking
Security
Monitoring & observability
0

1.1K

lexlex0/unifarr repository overview

โ Unifarr

Unlock the full potential of your firewall.

Logs, analysis, reports and configuration changes for UniFi gateways, with the experience of an enterprise firewall. Self-hosted, ready in minutes with Docker. The interface is available in English and French.

โš ๏ธ ALPHA SOFTWARE (version 0.1-alpha) Features and the database format may still change, and bugs are expected. Unifarr can modify your UniFi console configuration: keep a backup of the console, review staged changes before applying them, and test it on a non-critical network first.

โ Why Unifarr?

  • See everything: every allowed or blocked connection and every IPS alert, live or over twelve months.
  • Understand everything: which rules are used, which are useless or shadowed, and where attacks come from.
  • Act safely: change rules, objects, NAT and VLANs with staging, safeguards and rollback.
  • Prove it: compliance PDF reports (PCI DSS, ISO 27001, NIS2, HIPAA) and an audit log.
  • Lose nothing: encrypted snapshots of the UniFi configuration, automatic backups to a folder or a NAS.

โ Features

๐Ÿ“œ LogsSyslog UDP/TCP (iptables, CEF, Suricata IPS/IDS), live and history, FortiGate-style filters, saved and shared filters
๐Ÿ”Ž AnalysisDashboard, world map, live LAN map, flows, topology, rule usage, anomalies, WAN quality, IPFIX / NetFlow bandwidth
๐Ÿ›ก๏ธ PoliciesZone-based rules, objects, NAT, VPN, network clients, โ€œwhich rule applies?โ€ simulator
๐Ÿ› ๏ธ ChangesRules, objects, NAT, VLANs and switch ports; reordering, batch push, history, rollback
๐Ÿšซ Blocked IPsPermanent or temporary blocking, with a configuration check (rules in every zone, correctly placed)
๐Ÿ“ธ SnapshotsDaily encrypted snapshot of the UniFi configuration, comparison, immutable snapshots, adjustable retention
โœ… Best practicesFirewall policy score, findings by severity, guided fix rule by rule
๐Ÿ“Š ReportsPDF (executive summary, traffic, intrusions, compliance), scheduled reports by e-mail or ntfy
๐Ÿ”” Alertsntfy, SMTP, Microsoft 365, Gmail: IPS threats, WAN down, new or offline device, anomalies
๐Ÿ” SecurityAdmin / editor / read-only roles, OIDC, TOTP two-factor authentication, API tokens, audit log
๐Ÿ’พ BackupEncrypted backup on demand or automatic (daily / weekly) to a mountable export folder
in test๐ŸŒ Multi-consoleSeveral UniFi consoles: view one, several or all of them
๐Ÿ“ˆ IntegrationsPrometheus metrics, IP reputation (Spamhaus, FireHOL, Feodo, AbuseIPDB)

โ The image

  • Based on Python 3.13 Alpine, without pip in the final image
  • Runs as a non-root user (UID 10001)
  • Built-in health check (/healthz)
  • Requires PostgreSQL 16 + TimescaleDB (see the example below)
TagContent
latestLatest build (alpha)
<commit>Build of a specific commit, to pin a version

โ Quick start

docker-compose.yml:

services:
  db:
    image: timescale/timescaledb:2.17.2-pg16
    restart: unless-stopped
    environment:
      POSTGRES_DB: unifarr
      POSTGRES_USER: unifarr
      POSTGRES_PASSWORD: ${DB_PASSWORD:?Set DB_PASSWORD in .env}
    volumes:
      - db-data:/var/lib/postgresql/data
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U unifarr -d unifarr"]
      interval: 10s
      timeout: 5s
      retries: 10

  app:
    image: YOUR_NAMESPACE/unifarr:latest
    restart: unless-stopped
    depends_on:
      db:
        condition: service_healthy
    environment:
      DATABASE_URL: postgresql://unifarr:${DB_PASSWORD}@db:5432/unifarr
      SNAPSHOT_KEY: ${SNAPSHOT_KEY:-}
      TZ: ${TZ:-Europe/Paris}
    volumes:
      - app-data:/data
      - app-export:/etc/export
    ports:
      - "8080:8080"
      - "514:5514/udp"
      - "514:5514/tcp"
      - "2055:2055/udp"

volumes:
  db-data:
  app-data:
  app-export:

.env:

DB_PASSWORD=change-me
SNAPSHOT_KEY=
TZ=Europe/Paris

Start it with docker compose up -d, then:

  1. Open http://<server>:8080 and create the administrator account (the setup code is shown in docker compose logs app).
  2. On the UniFi console, send syslog to port 514 of the server (CyberSecure โ€บ Traffic Logging โ€บ Activity Logging, all categories), then enable Syslog Logging on the rules to log.
  3. In Unifarr โ€บ Settings โ€บ UniFi API, add a local console account to read rules and objects.
  4. Optional: send IPFIX / NetFlow to port 2055 for bandwidth charts.

If the interface is reachable from outside your local network, put it behind an HTTPS reverse proxy and set PUBLIC_URL and FORWARDED_ALLOW_IPS.

โ Ports and volumes

Container portUse
8080/tcpWeb interface and API
5514/udp, 5514/tcpSyslog (publish as 514 on the host)
2055/udpIPFIX / NetFlow v9 collector
PathContent
/dataInstance key (if SECRET_KEY is not set), GeoIP databases, cached device icons
/etc/exportAutomatic backups (backup/) and exports; can be a host folder or a NAS share writable by UID 10001

โ Environment variables

VariableDefaultDescription
DATABASE_URL(required)PostgreSQL connection string
ADMIN_USER / ADMIN_PASSWORDโ€”Administrator created on first start (otherwise created from the web page)
SECRET_KEYgenerated in /dataFernet key encrypting secrets (UniFi API, mail accounts, OIDC)
SNAPSHOT_KEYinstance keyFernet key encrypting configuration snapshots (a dedicated key is recommended)
SNAPSHOT_KEY_PREVIOUSโ€”Previous snapshot key, used once to re-encrypt snapshots after a key change
TZEurope/ParisTime zone
RETENTION_DAYS365Log retention in days (0 = unlimited)
COMPRESS_AFTER_HOURS6Lossless TimescaleDB compression after N hours
GEOIP_AUTO_DOWNLOADtrueMonthly download of the DB-IP Lite GeoIP database
ALLOWED_SENDERSallIPs / networks allowed to send syslog
PUBLIC_URL, FORWARDED_ALLOW_IPSโ€” / 127.0.0.1HTTPS reverse proxy settings
OIDC_ISSUER, OIDC_CLIENT_ID, OIDC_CLIENT_SECRET, OIDC_ADMIN_GROUP, OIDC_ALLOWED_GROUP, OIDC_LABELโ€”OIDC sign-in (Entra ID, Google, Keycloak, Authentikโ€ฆ)

Generate a key for SECRET_KEY or SNAPSHOT_KEY (use two different keys) and keep it off the server:

openssl rand -base64 32 | tr '+/' '-_'

โ Updating

docker compose pull && docker compose up -d

Database migrations are applied automatically on start. As an alpha release, back up the database before updating.

โ Licence

MIT licence. GeoIP databases remain subject to their own licences. UniFi is a trademark of Ubiquiti Inc. and FortiGate a trademark of Fortinet, Inc.; Unifarr is not affiliated with either company.

Tag summary

Content type

Image

Digest

sha256:05b3b8c9aโ€ฆ

Size

79.5 MB

Last updated

2 days ago

docker pull lexlex0/unifarr