for i in $(netstat -pant | awk '/apache/ {print $5}' | awk -F: '{print $1}' | sort | uniq | sort); do echo; echo $i; curl -s http://ip-api.com/csv/$i | awk 'BEGIN { FS = "," } ; { print $2, $5 }'; done
#!/bin/bash for i in $(netstat -pant | awk '/apache/ {print $5}' | awk -F: '{print $1}' | sort | uniq | sort); do if curl -s http://ip-api.com/csv/$i | awk 'BEGIN { FS = "," } ; { print $2, $5 }' | grep China; then echo $i ufw insert 1 deny from $i comment "china IP ddos block" sleep 1 # prevent rate limiting for the ip-api fi done