Skip to content

andrey-savov/ip-blocked-nets

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Network blocking based on ipset/iptables

Overview

This is a set of scripts that help blocking certain subnets accessing an Ubuntu 18+ system. Based on iptables/ipset combination, it requires both of those installed. One can install them by simply running the following bash commands:

sudo su
apt install ipset
apt install iptables

Description

blocked.sh is an idempotent shell script which creates/recreates the blocked ipset and registers it with iptables firewall.

One can make the script executable with:

chmod 777 blocked.sh

and then simply execute it:

./blocked.sh

Service

The file ip-blocked.service contains a systemd service descriptor. To install the service as boot time one-shot service:

cp ip-blocked.service /etc/systemd/system/
systemctl start ip-blocked
systemctl enable ip-blocked

Of course you would need to edit the location of the file blocked.sh in the ip-blocked.service.

Logs

Simple dmesg will show any IP traffic being blocked.

About

iptables/ipset based networks blocked for Ubuntu 18+

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages