Blocking Countries & Exploited IPs
Written by:
Will Kruss
on
27 May 2016 07:18 PM
|
|
Learn to block a specific country known exploited IPs. Step by step tutorial will help you learn fast and apply. If you want to block a specific country known exploited IPs you can do so quite easily by running the below script on a daily basis in a cron job. 1. First you need to SSH into your server 2. You need to install dos2unix a. On Ubuntu/Debian type: apt-get install dos2unix b. On CentOS/Fedora type: yum install dos2unix 3. Create a file and paste the below text into it, type: pico /root/blockips
4. You can modify that file so that it blocks any countries you would like. To do that you would add a new bl_name and bl_url entry and increase the number (from 6 to 7 for example), then you need to change the "for i in {0..6}; do" line to read "for i in {0..7}; do". To get the URLs for country and other blacklists please visit https://www.iblocklist.com/lists.php select the free p2p file format in a gz archive and copy the update url. 5. Press Ctrl O to Save 6. Press Ctrl X to Quit 7. Type: chmod 755 /root/blockips 8. To make this update daily, type: crontab -e 9. If requested choose nano or pico as your editor 10. At the bottom of the file paste the following
11. Press Ctrl O to Save 12. Press Ctrl X to Quit 13. You can also run the script now by typing: /root/blockips 14. Once the script is complete you can view iptables entries by typing: iptables -L * Note the first time you run it you may see the below errors. This is normal and can be safely ignored (it occurs when it tries to delete existing entries for each blacklist specified and none exist). iptables v1.4.12: Couldn't load target `nigeria':No such file or directory Try `iptables -h' or 'iptables --help' for more information. | |
|