Coder Social home page Coder Social logo

virtualzone / usg-blacklist Goto Github PK

View Code? Open in Web Editor NEW
9.0 1.0 1.0 27 KB

Docker Image for remote dynamic IP blacklisting on UniFi USG.

License: GNU General Public License v3.0

Dockerfile 13.30% Shell 86.70%
unifi unifi-controller usg firewall blacklisted-ips blacklist ips intrusion-prevention

usg-blacklist's Introduction

Dynamic IP Blacklisting for UniFi USG

This Docker Image remotely sets up a dynamic IP blacklist on your UniFi Security Gateway (USG).

This is kind of a lightweight Intrusion Prevention System (IPS) only based on known blacklisted IP addresses. It retains USG's hardware offloading feature.

The following sources are used:

  • Spamhaus.org
  • EmergingThreats.net
  • TOR Exit Nodes

Based on and inspired by the great script at: https://github.com/brontide/usg-blacklist

Preparing the USG

  1. Create an IPv4 firewall group named "Dynamic Threat List".
  2. Create firewall rules in WAN_LOCAL, WAN_OUT, WAN_IN to drop traffic from/to this group.
  3. Optional: Create an IPv6 firewall group named "Dynamic Threat List IPv6".
  4. Optional: Create firewall rules in WAN_LOCAL, WAN_OUT, WAN_IN to drop traffic from/to this group.
  5. Create an SSH key using ssh-keygen and install the public key in your UniFi SDN Controller under: Settings > Site > Device Authentication

Updating the firewall rules

The rules are updates only once per day. If you run the container more than once per day, the update operation is skipped. This is useful to reinstall the rules after rebooting the USG, as existing rules are reset on reboot.

I recommend running this regularly (i.e. via a cronjob).

docker run --rm \
    -e "MODE=update" \
    -e "IPV6=true" \
    -e "HOST=10.10.1.1" \
    -e "USER=unifi-ssh-user" \
    -v ${PWD}/ssh-key:/root/ssh-key:ro \
    virtualzone/usg-blacklist

Viewing the stats

docker run --rm \
    -e "MODE=stats" \
    -e "IPV6=true" \
    -e "HOST=10.10.1.1" \
    -e "USER=unifi-ssh-user" \
    -v ${PWD}/ssh-key:/root/ssh-key:ro \
    virtualzone/usg-blacklist

Disclaimer

Tested on a UniFi USG3 with firmware 4.4.44. Use at your own risk.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.