summaryrefslogtreecommitdiff
path: root/block
blob: bb20faccfd5976f639ea2752fd72f37dc22e9768 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#!/bin/bash
#
# script to block IPs
host_IP="<host IP address>"
incoming_table="INPUT"
outgoing_table="OUTPUT"
target="DROP"

echo "Checking $incoming_table for: $1"
iptables -C $incoming_table -s "$1" -d $host_IP -p all -j $target
if [ $? == 0 ]; then
        echo "$1 already in blocked"
        exit 1
fi
echo "Blocking: $1"
iptables -I "$incoming_table" -s "$1" -d "$host_IP" -p all -j "$tagret"
iptables -I "$outgoing_table" -d "$1" -s "$host_IP" -p all -j "$target"