Deploy local server's ipset rules to other remote servers automatically.
- Clone repository
git clone git@github.com:alexbiship/python-ipset.git- Copy RSA(SSH) key for
rootuser for remote access, change name toid_rsa.keyand copy to the root path of the project directory
chmod 400 id_rsa.key- All installation and running commands on remote servers are required
rootuser permission. Allowrootuser login on remote servers if it's disabled. See here for more info Login asrootPython v3.6+ is required and tested on Ubuntu 18.04
add-apt-repository ppa:deadsnakes/ppa
apt update
apt -y install python3
apt -y install python3-pip
pip3 install virtualenv- Create virtual env and install dependencies
cd $YOUR_PROJECT_DIRECTORY
virtualenv .venv
source .venv/bin/activate
pip3 install -r requirements.txt- Check all available CLI commands
python3 main.py- Firstly, run
add-servercommand and register servers.(you have to add local server that monitors MySQL database change. Use localhost or 127.0.0.1)
python3 main.py add-server- Run
initcommand and install and config, basic settings automatically for all servers.
python3 main.py init-
Run
reset-ipsetcommand to clean up local server's ipset rules(Not for other servers) -
Run
reset-serverscommand to clean up all ipsets and iptable rules in all servers(factory mode :) -
Add two cron jobs. One is for syncing mysql db and set proper ipset, other one is to deploy ipset rules to all servers
crontab -e
# setup cron job
* * * * * cd /path/to/the/project/folder && .venv/bin/python3 main.py sync
* * * * * cd /path/to/the/project/folder && .venv/bin/python3 main.py deploy