GithubHelp home page GithubHelp logo

groundcat / block-gfw-active-detection Goto Github PK

View Code? Open in Web Editor NEW
4.0 2.0 0.0 4 KB

Protect proxy servers from GFW active detection with automated domain resolving and iptables updating 自动化更新iptables规则屏蔽GFW主动探测代理服务器端口

Python 80.06% Shell 19.94%
censorship censorship-resistance gfw great-firewall greatfirewall iptables iptables-persistent

block-gfw-active-detection's Introduction

Block-GFW-Active-Detection

This is a script that generates an iptables rule set to limit the IP addresses that are allowed to connect to your server.

The default configuration to be used to protect the OutlineVPN Shadowsocks server against China's Great Firewall (GFW). GFW identifies servers running Shadowsocks proxy/VPN by active detection. This has been verified through experiments, and we have provided a simple and effective countermeasure: setting up a whitelist firewall on the server side. Our strategy proved to be effective in prolonging the survival time of the server without affecting the user experience. Nevertheless, it is highly recommended to set up your Shadowsocks servers with OutlineVPN or follow the best practices: How to Deploy a Censorship Resistant Shadowsocks-libev Server.

Features

✅ Generates an iptables rule set to limit the IP addresses that are allowed to connect to your server via TCP/UDP.

✅ Supports multiple IP addresses and ports.

✅ Updates the rule set automatically every hour based on the IP addresses resolved from your DDNS domains.

✅ Protects your SSH service (disabled by default, enable in config.ini).

Prerequisites

  • A DDNS domain set up at your home computer or router.
  • A remote server running Shadowsocks or VPN that requires protection. This server is where this script will be installed. Root access is required.
  • Install iptables-persistent with apt install -y iptables-persistent. During installation, it will ask you if you want to keep current rules–decline.
  • Run setup.sh described below to install the remaining dependencies.

Configure

Create a config.ini file to your liking. Use config.example.ini as a template.

cp config.example.ini config.ini
vi config.ini

Make sure SSH_PORT is the same port number you set in sshd_config and SSH_ALLOWED_HOST is properly configured, otherwise you might be blocked from accessing SSH by the firewall.

Install

This setup script works for Ubuntu and Debian based Linux distributions.

The setup script will

  • install dependencies and required Python packages
  • install cronjob to run the script update.sh every hour
  • disable IPv6 given that the script does not support IPv6 yet

You only need to run this script once, however you may run it for multiple times if necessary.

chmod -x ./setup.sh
/bin/bash ./setup.sh

Update iptables rules manually

The update script will

  • query the domains or DDNS domains with DNS-over-HTTPS to resolve IP addresses
  • update the iptables rule set to allow the IP addresses to connect to your server
  • if any one of the domains fails to be successfully resolved, the script will exit to avoid blocking the existing IP addresses
chmod -x ./update.sh
/bin/bash ./update.sh

block-gfw-active-detection's People

Contributors

groundcat avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  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.