#!/usr/bin/sudo /bin/bash
## safety instructions: ##
## chown root:root ##
## chmod 0755 ##
errMsgWholeNet='Sorry! It is to dangerous to block the whole net. This is also not allowed. This is really an error.';
if [ -z "$1" ]; then
echo 'Kein Parameter angegeben.';
exit 1;
else
ip=$(echo -n "${1}" | tr -cd '0123456789./');
network=$(echo "${ip}" | cut -s -d '/' -f2);
if [ -n "${network}" ]; then
if [ '0.0.0.0' = "${network}" ]; then
echo "${errMsgWholeNet}";
exit 4;
fi
network=$((${network}));
if [ 0 -eq ${network} ]; then
echo "${errMsgWholeNet}";
exit 4;
fi
fi
if iptables -A INPUT -s "${ip}" -j DROP; then
fwlist | tee /tmp/fwlist.txt | grep "${ip}";
exit 0;
else
exit 2;
fi
fi