Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh
- # By Anthony Smith - InceptionHosting.com - 2013
- # This script bans IPs with specific Ports that are added to a .txt file
- # This script should be called every minute as a cronjob/from crontab
- # build list from user input /var/www/ban.ban-list.txt should be the one your game admis update
- # change the path and file name if required
- cat /var/www/ipban/ban-list.txt | awk '{print $1}' > /ban/banip.txt
- # loop through list and add to iptables
- # this will also add each ip you block to /ban/perm-ban.txt
- # you can run 'cp /ban/perm-ban.txt /ban/banip.txt' after a reboot and run this script
- # this will re ban any previously banned ip's if you are not saving your iptables config
- while read blist
- do
- /sbin/iptables -A INPUT -s $blist -p udp -m udp --dport 28960:28965 -j DROP && sleep 2
- echo $blist has been added to your iptables
- echo $blist >> /ban/perm-ban.txt
- done < /ban/banip.txt
- # tidy up files
- # on the next few lines update the path after touch to be the same as the first line
- # example /var/www/ban/ban-list.txt
- rm /ban/banip.txt
- rm /var/www/ipban/ban-list.txt
- touch /var/www/ipban/ban-list.txt
- chmod 777 /var/www/ipban/ban-list.txt
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement