Git Product home page Git Product logo

filter-chain's Introduction

Filter-Chain

Dynamic iptables filter chain
If you need to block subnets from some countries for partially eliminate L7 DDOS, bots or port scan. RIPE used as subnet datasource.
To solve these problems, there are more powerful (and paid) services and I recommend to use them in the next.

Requirements

  • Any modern Linux distro with iptables and ipset support.

Installation

Use the ansible (deploy/filter-chain-role) for install iptables, ipset and filter-chain.

Configuration

Example config:

# default []
allowNetworkList:
  - "172.16.0.0/12"

# default []
countryAllowList:
  - "NL"
  - "US"

# default []
countryDenyList:
  - "CN"

# Refresh interval for update data from RIPE
# Valid time units are "ns", "us" (or "µs"), "ms", "s", "m", "h".
# default 12h
refreshInterval: 23h59m

Also you need add iptables rule with jump into ipset-filter chain.
Minimal manual configuration for iptables:

iptables -I INPUT 1 -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
iptables -N ipset-filter
iptables -I INPUT 2 -m conntrack --ctstate NEW -j ipset-filter
... # Any other rules
iptables -A INPUT -i eth0 -j DROP
# Then save rules
iptables-save > /etc/iptables/rules.v4

Note that it is recommended to save only an empty ipset-filter chain. In any case, rules relating to ipsets that do not yet exist will not be applied at startup.
In turn, the filter-chain will create ipsets at startup and add rules to the chain.

TODO

  • Ansible role and install docs
  • Automatic creation a jump rule

filter-chain's People

Contributors

hornwind avatar

Stargazers

 avatar

Watchers

 avatar

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.