{"id":897,"date":"2016-12-15T15:47:57","date_gmt":"2016-12-15T15:47:57","guid":{"rendered":"http:\/\/www.haxed.me.uk\/?p=897"},"modified":"2016-12-15T15:47:57","modified_gmt":"2016-12-15T15:47:57","slug":"block-ips-country","status":"publish","type":"post","link":"https:\/\/haxed.me.uk\/index.php\/2016\/12\/15\/block-ips-country\/","title":{"rendered":"Block all the IP&#8217;s from country"},"content":{"rendered":"<p>So, I wrote a nice little one liner for one of our customers that wanted to blanket ban Russia (even though I said it wasn&#8217;t a good idea, or marginally effective to stop attacks). Might help with spam or other stuff though, and anyway, the customer is always &#8216;wrong&#8217;, it&#8217;s up to us to make sure that they do it wrongly right. ;-D<\/p>\n<pre>\r\ncurl http:\/\/www.ipdeny.com\/ipblocks\/data\/countries\/ru.zone -o russia_ips_all.txt; cat russia_ips_all.txt | xargs -i echo \/sbin\/iptables -I INPUT -s {} -j DROP\r\n<\/pre>\n<p>Here is how I achieved it above. This bans all the IP&#8217;s from russia. But, if you aren&#8217;t very equal opportunities :(, you can ban all kinds of countries:<\/p>\n<p><a href=\"http:\/\/www.ipdeny.com\/ipblocks\/\">http:\/\/www.ipdeny.com\/ipblocks\/<\/a><\/p>\n<p>Just take a look at this, and change the url, as such. It doesn&#8217;t matter what the variables say (even if they say russia, just change the url directly after curl). For instance<\/p>\n<pre>\r\nhttp:\/\/www.ipdeny.com\/ipblocks\/data\/countries\/pl.zone -o ips_all.txt; cat ips_all.txt | xargs -i echo \/sbin\/iptables -I INPUT -s {} -j DROP\r\n<\/pre>\n<p>I was really quite happy with this little oneliner. \ud83d\ude00<\/p>\n<p>Cheers &#038;<br \/>\nBest wishes,<br \/>\nAdam<\/p>\n","protected":false},"excerpt":{"rendered":"<p>So, I wrote a nice little one liner for one of our customers that wanted to blanket ban Russia (even though I said it wasn&#8217;t a good idea, or marginally effective to stop attacks). Might help with spam or other &hellip; <a href=\"https:\/\/haxed.me.uk\/index.php\/2016\/12\/15\/block-ips-country\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[31,9,4,61,3],"tags":[],"class_list":["post-897","post","type-post","status-publish","format-standard","hentry","category-iptables","category-linux","category-networking","category-rackspace","category-security"],"_links":{"self":[{"href":"https:\/\/haxed.me.uk\/index.php\/wp-json\/wp\/v2\/posts\/897","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/haxed.me.uk\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/haxed.me.uk\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/haxed.me.uk\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/haxed.me.uk\/index.php\/wp-json\/wp\/v2\/comments?post=897"}],"version-history":[{"count":1,"href":"https:\/\/haxed.me.uk\/index.php\/wp-json\/wp\/v2\/posts\/897\/revisions"}],"predecessor-version":[{"id":898,"href":"https:\/\/haxed.me.uk\/index.php\/wp-json\/wp\/v2\/posts\/897\/revisions\/898"}],"wp:attachment":[{"href":"https:\/\/haxed.me.uk\/index.php\/wp-json\/wp\/v2\/media?parent=897"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/haxed.me.uk\/index.php\/wp-json\/wp\/v2\/categories?post=897"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/haxed.me.uk\/index.php\/wp-json\/wp\/v2\/tags?post=897"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}