Untitled

From Anonymous, 3 Years ago, written in Plain Text, viewed 47 times.
URL https://paste.bugabuse.net/view/17955846 Embed
Download Paste or View Raw
  1. #!/bin/bash
  2. blockediplist='/tmp/block.list'
  3.  
  4. tail -f "$blockediplist" | while read LINE; do
  5.         IP=$(echo "${LINE}" | grep '\.' | awk '{print $1}')
  6.         LC=$(iptables -L -n | grep "${IP}" | wc -l)
  7.                 if [ "$LC" -eq 0 ]; then
  8.                         echo "$(date) firewalling $IP"
  9.                         iptables -A INPUT -s $1 "${IP}" -j DROP
  10.                 else
  11.                         echo "Not banning ${IP} due to already being banned."
  12.                 fi
  13. done
  14.  

Reply to "Untitled"

Here you can reply to the paste above