I would like to restrict visibility of my server from outside my country. I am connecting to my personal server always from one or two countries. Is there a way to block all the IPs coming from all the other countries?I am running Debian with iptables.I have found the following database of IPs associated to countries, however it's not very accurate. Any other idea?ftp://ftp.arin.net/pub/stats/arin/delegated-arin-extended-latest (North America)ftp://ftp.ripe.net/ripe/stats/delegated-ripencc-latest  (Europe)ftp://ftp.afrinic.net/pub/stats/afrinic/delegated-afrinic-latest (Africa)ftp://ftp.apnic.net/pub/stats/apnic/delegated-apnic-latest (Asia + Pacific)ftp://ftp.lacnic.net/pub/stats/lacnic/delegated-lacnic-latest (South America)
Block countries based on IP in firewall
debian;iptables;firewall
You can use xtable addons geoip match feature. On debian install the xtable-addons-common package and then use use the geoip target e.g. to allow ssh from Netherlands NL:iptables -A INPUT -p tcp --dport 22 -m geoip --src-cc NL -j ACCEPTMake sure xt_geoip module is loaded and geoip database is downloaded. You can read xtable documentation for more information on this at http://xtables-addons.sourceforge.net/geoip.php