Last active
May 18, 2020 01:37
-
-
Save MarkZhangTW/8fd7bf22f2c8187d96d32997c4b2bf61 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#sudo lastb -ai | head -n-2 | awk '{print$NF}' | awk '/[0-9]+[.][0-9]+[.][0-9]+[.][0-9]+/{print}' | sort -t. -k1,1n -k2,2n -k3,3n -k4,4n | uniq --count | awk '$1>9{print$2}' > failed.ip.9 | |
sudo lastb -ai | head -n-2 | awk '{print$NF}' | awk '/[0-9]+[.][0-9]+[.][0-9]+[.][0-9]+/{print}' | sort | uniq --count | awk '$1>9{print$2}' > failed.ip.9 | |
for ip in $(cat failed.ip.9); do | |
sudo firewall-cmd --permanent --zone=public --add-rich-rule="rule family='ipv4' source address='$ip' reject" | |
done | |
sudo firewall-cmd --reload |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://gist.github.com/HuaiShaoChang/47d81765bc520d6271a948ad3eb1518d