Skip to content

Instantly share code, notes, and snippets.

@jsownz
Created March 30, 2022 16:38
Show Gist options
  • Save jsownz/1152d761d806820011b995390a921a0a to your computer and use it in GitHub Desktop.
Save jsownz/1152d761d806820011b995390a921a0a to your computer and use it in GitHub Desktop.
ufw before.rules to block specific IPs and to auto block malicious
# Block specific
-A ufw-before-input -s 106.0.38.42 -j DROP
-A ufw-before-input -s 37.187.118.21 -j DROP
-A ufw-before-input -s 54.37.9.221 -j DROP
-A ufw-before-input -s 80.19.177.242 -j DROP
-A ufw-before-input -s 154.89.5.18 -j DROP
-A ufw-before-input -s 36.72.216.107 -j DROP
-A ufw-before-input -s 36.72.217.130 -j DROP
-A ufw-before-input -s 36.72.217.22 -j DROP
-A ufw-before-input -s 36.72.218.140 -j DROP
-A ufw-before-input -s 202.188.20.123 -j DROP
#auto-block
-A ufw-before-input -p tcp --dport 80 -m state --state NEW -m recent --set
-A ufw-before-input -p tcp --dport 80 -m state --state NEW -m recent --update --seconds 100 --hitcount 100 -j DROP
-A ufw-before-input -p tcp --dport 443 -m state --state NEW -m recent --set
-A ufw-before-input -p tcp --dport 443 -m state --state NEW -m recent --update --seconds 100 --hitcount 100 -j DROP
-A ufw-before-input -p tcp --dport 22 -m state --state NEW -m recent --set
-A ufw-before-input -p tcp --dport 22 -m state --state NEW -m recent --update --seconds 100 --hitcount 100 -j DROP
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment