Bash script to block an IP address in linux

In order to block an IP or a class of IPs on your Linux server you need to use iptables tools (administration tool for IPv4 packet filtering and NAT) and netfilter firewall. First you need to log into shell as root user.

To block an IP address you need to type the command as follows:
./drop IP

You can also unblock an IP by suppling -r parameter:
./drop -r IP

Here’s the code for the script:

Lasă un răspuns

Adresa ta de email nu va fi publicată. Câmpurile obligatorii sunt marcate cu *