I have a VERY old kernel version which for dumb "boss who thinks he knows everything" reasons i can not update. I need to either fire my boss or make a bash script that can add an iptable rule everytime it reads a different ip with dmesg. How can i make this. For the moment i have this which works good but it keeps duplicating the IP for obvious reasons on how iptable works there. I need to find a way to, before appending the IP, i want to make sure the ip is NOT in the iptable list already:
for BADIP in $(dmesg | grep 'Treason uncloaked!' | cut -d' ' -f6 | cut -d':' -f1 | sort --unique)
do
iptables -A INPUT -s $BADIP -j DROP
done