Advertisement
Guest User

ipblockscriptipv6.sh

a guest
Feb 7th, 2016
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. #!/bin/bash
  2. # Modify script as per your setup
  3. # Usage: Sample firewall script
  4. # ---------------------------
  5. _input=/root/ipb/ipv6/mh.zone
  6. _pub_if="eth0 inet6"
  7. IPT=/sbin/iptables
  8.  
  9. # Die if file not found
  10. [ ! -f "$_input" ] && { echo "$0: File $_input not found."; exit 1; }
  11.  
  12. ### Setup our black list ###
  13. # Create a new chain
  14. $IPT -N droplistv6
  15.  
  16. # Filter out comments and blank lines
  17. # store each ip or subnet in $ip
  18. egrep -v "^#|^$" x | while IFS= read -r ip
  19. do
  20. # Append everything to droplistv6
  21. $IPT -A droplistv6 -i ${_pub_if} -s $ip -j LOG --log-prefix " Drop Bad IP List "
  22. $IPT -A droplistv6 -i ${_pub_if} -s $ip -j DROP
  23. done <"${_input}"
  24.  
  25. # Finally, insert or append our black list
  26. $IPT -I INPUT -j droplistv6
  27.  
  28. $IPT -I OUTPUT -j droplistv6
  29. $IPT -I FORWARD -j droplistv6
  30.  
  31. # drop and log everything else
  32. $IPT -A INPUT -m limit --limit 5/m --limit-burst 7 -j LOG
  33. $IPT -A INPUT -j DROP
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement