I need to block IP traffics from a certain country. I know I can export a free IP address list from IP2Location firewall generator. The sample output file for iptables format is as below.
What should I do next to block the list of IP address using iptables? I don't want to run the command line by line.
Code:
# -------------------------------------------------------
# Free IP2Location Firewall List by Country
# Source: https://www.ip2location.com/free/visitor-blocker
# Last Generated: 20 Nov 2018 05:20:36 GMT
# [Important] Please update this list every month
# -------------------------------------------------------
iptables -A INPUT -s 217.29.232.0/21 -j DROP
iptables -A INPUT -s 194.112.14.0/24 -j DROP
iptables -A INPUT -s 194.112.13.128/25 -j DROP
iptables -A INPUT -s 194.112.13.64/26 -j DROP
Bookmarks