UniFi

Total Time Required

20 minutes

Difficulty

Easy

Required Knowledge

Crowdsec, UniFi

Drawing

Prerequisites

This stack monitors...

... And changes

  • UniFi firewall

UniFi changes

Service account

You will need to generate a service account for the UniFi bouncer to log into and use

  1. Untick "Admin Permissions"

  2. Create a new user and fill out the below

    First name

    Crowdsec

    Last name

    Bouncer

    Admin

    True

    Restrict to local access

    True

    Username

    <randomly generated>

    Password

    <randomly generated>

    Use a predifined role

    False

    Unifi

    Full managemen

    OTHER ROLES

    None

  3. Save your username and password to your text editor

  4. Click on Create

circle-exclamation

Forward Logs

  1. Set Syslog to SIEM server or external

  2. Set the server address to the IP of the machine that will run this stack

  3. Click on Apply Changes

Enable Firewall zones

  1. Enable Firewall zones

circle-exclamation

Deploy Compose stack

Fill out the below env file and deploy your stack

https://github.com/trentnbauer/HomelabPublic/blob/main/docker-compose/crowdsec-unifi.yml

Confirm the bouncer has logged into the account

  1. Review the list and find Crowdsec Bouncer - the last activity should state "now"

If not, review the bouncer and engine container logs

Host Firewall

Allow your syslog port through the firewall (by default 514)

Enroll the engine

  1. Locate the UniFi in the enrollment list

  2. Enrol the engine

  3. Wait 5 minutes

Check UniFi firewall rules exit

  1. You will have a stack of "cs-unifi-bouncer" rules

Known Issues

UniFi network appliance crashing

This will show as

  • Slowness accessing UniFi network software

  • Alerts for router being offline

  • Router showing as offline in at

There is a known bug where too many blocked IPs crashes the UniFi network applicationarrow-up-right

You will first need to remove the firewall rules and lists

This is a bit of a nightmare as the network application will crash often while you are doing this.

  1. Click on Manage, and tick all of the CS- rules

  2. Click on Delete and then proceed

  3. Click on Manage, and tick all of the CS- rules

  4. Click on Delete and then proceed

Or follow this: https://github.com/wolffcatskyy/crowdsec-blocklist-import?tab=readme-ov-file#recovery-network-app-crasharrow-up-right

Adjust the blocklist limit

  1. Update the compose env file variable MAX_DECISION

  2. Restart the stack and see how you go

circle-info

This setting defaults to 8000 - I would suggest halving this and seeing how it goes. You can slowly increase it once its happy.

Last updated