{"id":65,"date":"2016-02-28T17:28:35","date_gmt":"2016-02-29T01:28:35","guid":{"rendered":"http:\/\/www.gregsitservices.com\/blog\/?p=65"},"modified":"2017-03-23T00:11:06","modified_gmt":"2017-03-23T07:11:06","slug":"blocking-unwanted-countries-with-windows-firewall","status":"publish","type":"post","link":"https:\/\/www.gregsitservices.com\/blog\/2016\/02\/blocking-unwanted-countries-with-windows-firewall\/","title":{"rendered":"Blocking Unwanted Countries with Windows Firewall"},"content":{"rendered":"<p style=\"text-align: justify;\">I get a lot of clients asking me what they can buy for protecting themselves from countries they don&#8217;t want connecting to their office or home network since they have no business with these countries and the threat they pose in hacking.<\/p>\n<p style=\"text-align: justify;\">A simple and &#8220;zero cost&#8221; solution already exists with their <strong>Windows<\/strong> system. <strong>Windows Firewall<\/strong> can be used to solve this situation in a very easy manner using distributed country <strong>IP Tables<\/strong> and <strong>PowerShell<\/strong>.<\/p>\n<p>Below is a tutorial I wrote explaining the process:<\/p>\n<h3><span style=\"color: #066899;\"><strong>How to Block County IP&#8217;s in Windows Firewall with PowerShell<\/strong><\/span><\/h3>\n<p><span style=\"color: #066899;\"><strong>Step 1<\/strong><\/span>: Create a directory for working with PowerShell and PowerShell Scripts. Example: C:\\ip-security<\/p>\n<p><span style=\"color: #066899;\"><strong>Step 2<\/strong><\/span>: Download the PowerShell script Import-Firewall-Blocklist.ps1 from <a href=\"http:\/\/www.gregsitservices.com\/ip-security\/ip-security-package.zip\">http:\/\/www.gregsitservices.com\/ip-security\/ip-security-package.zip<\/a> and extract the PowerShell script Import-Firewall-Blocklist.ps1 to your C:\\ip-security folder.<\/p>\n<p><span style=\"color: #066899;\"><strong>Step 3<\/strong><\/span>: Go to <a href=\"http:\/\/www.ipdeny.com\/ipblocks\/\">http:\/\/www.ipdeny.com\/ipblocks\/<\/a> and download the IP Tables in CIDR Format\u00a0of the countries that you do not want accessing your windows system at all. To the Right of each list grab the &#8220;aggregated zone file&#8221; for each country. Click them on them and you will see a list of IP&#8217;s. Right click and save that file to your C:\\ip-security directory using a basic format, <span style=\"color: #ff0000;\">THIS IS IMPORTANT<\/span>.<\/p>\n<p>Example: Save China as china.zone.txt so that if you update the zone file it will remove any Old Rules that are created. Optionally you can grab the larger lists (on the left) but, the aggregated zones are based on activity.<\/p>\n<p>I recommend the following Zones:<\/p>\n<ol>\n<li>CHINA (CN) (save as china.zone.txt)<\/li>\n<li>KOREA, DEMOCRATIC PEOPLE&#8217;S REPUBLIC OF (KP) (save as northkorea.zone.txt)<\/li>\n<li>RUSSIAN FEDERATION (RU) (save as russia.zone.txt)<\/li>\n<\/ol>\n<p><span style=\"color: #066899;\"><strong>Step4<\/strong><\/span>: Run PowerShell\u00a0as Administrator (right click PowerShell and select Run as Administrator).<\/p>\n<p><span style=\"color: #066899;\"><strong>Step 5<\/strong><\/span>: Type without quotes &#8220;PowerShell.exe -ExecutionPolicy Bypass&#8221; &#8211; This will set the scripts Policy of PowerShell to run so that it can make the Windows Firewall Rules.<\/p>\n<p><span style=\"color: #066899;\"><strong>Step 6<\/strong><\/span>: Begin entering the Zones into your Windows Firewall. <em>Option 1<\/em> is for Older Versions of PowerShell. If <em>Option 1<\/em> does not execute then use <em>Option 2<\/em>.<\/p>\n<p style=\"padding-left: 30px;\"><em>Option 1<\/em>: Import-Firewall-Blocklist.ps1 -inputfile china.zone.txt<\/p>\n<p style=\"padding-left: 30px;\"><em>Option 2<\/em>: .\\Import-Firewall-Blocklist.ps1 -inputfile china.zone.txt<\/p>\n<p>Do this for each of your Zones.<\/p>\n<p><span style=\"color: #066899;\"><strong>Step 7<\/strong><\/span>: Just for precaution let&#8217;s now set PowerShell back to Restricted Access on Scripts. Type without quotes &#8220;PowerShell.exe -ExecutionPolicy Restricted&#8221;.<\/p>\n<p style=\"text-align: justify;\">That&#8217;s it we are done&#8230; I suggest you keep your zone files so that you can update them easy by overwriting them. I would update them about Once a Month if you are experiencing attacks. Below is how the rules will look inside Windows Firewall.<\/p>\n<p style=\"text-align: justify;\"><span style=\"color: #ff0000;\">Note<\/span>: Notice the rule names are china.zone-#001 etc.. This is why it&#8217;s important to be consistent with the file name (china.zone.txt) for future updates to overwrite and remove rules automatically to save time and effort.<\/p>\n<figure id=\"attachment_84\" aria-describedby=\"caption-attachment-84\" style=\"width: 640px\" class=\"wp-caption alignnone\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-84 size-large\" title=\"Windows Firewall\" src=\"http:\/\/www.gregsitservices.com\/blog\/wp-content\/uploads\/2016\/02\/windows-firewall-1024x715.png\" alt=\"Windows Firewall\" width=\"640\" height=\"447\" srcset=\"https:\/\/www.gregsitservices.com\/blog\/wp-content\/uploads\/2016\/02\/windows-firewall-1024x715.png 1024w, https:\/\/www.gregsitservices.com\/blog\/wp-content\/uploads\/2016\/02\/windows-firewall-300x209.png 300w, https:\/\/www.gregsitservices.com\/blog\/wp-content\/uploads\/2016\/02\/windows-firewall-768x536.png 768w, https:\/\/www.gregsitservices.com\/blog\/wp-content\/uploads\/2016\/02\/windows-firewall.png 1047w\" sizes=\"(max-width: 640px) 100vw, 640px\" \/><figcaption id=\"caption-attachment-84\" class=\"wp-caption-text\">Windows Firewall Zone Rules<\/figcaption><\/figure>\n<h3><span style=\"color: #066899;\"><strong>How to Remove\u00a0Zones in Windows Firewall with PowerShell<\/strong><\/span><\/h3>\n<p>Below is how you can remove the entries using the scripts and zone files.<\/p>\n<p style=\"padding-left: 30px;\"><em>Option 1<\/em>: Import-Firewall-Blocklist.ps1 -inputfile china.zone.txt -deleteonly<\/p>\n<p style=\"padding-left: 30px;\"><em>Option 2<\/em>: .\\Import-Firewall-Blocklist.ps1 -inputfile china.zone.txt -deleteonly<\/p>\n<p>Another\u00a0Country IP Table Resources:<\/p>\n<ul>\n<li><a href=\"http:\/\/lite.ip2location.com\/\">http:\/\/lite.ip2location.com\/<\/a> I personally use this one\u00a0for many formats to choose from for different applications and\/or operating systems.<\/li>\n<\/ul>\n<p>ENJOY<span style=\"color: #2072d6;\">!<\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>I get a lot of clients asking me what they can buy for protecting themselves from countries they don&rsquo;t want connecting to their office or home network since they have no business with these countries and the threat they pose in hacking. A simple and &ldquo;zero cost&rdquo; solution already exists with their Windows system. Windows &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.gregsitservices.com\/blog\/2016\/02\/blocking-unwanted-countries-with-windows-firewall\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Blocking Unwanted Countries with Windows Firewall&#8221;<\/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":[7],"tags":[16,13,15,12,14,11,17],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.gregsitservices.com\/blog\/wp-json\/wp\/v2\/posts\/65"}],"collection":[{"href":"https:\/\/www.gregsitservices.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.gregsitservices.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.gregsitservices.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.gregsitservices.com\/blog\/wp-json\/wp\/v2\/comments?post=65"}],"version-history":[{"count":37,"href":"https:\/\/www.gregsitservices.com\/blog\/wp-json\/wp\/v2\/posts\/65\/revisions"}],"predecessor-version":[{"id":127,"href":"https:\/\/www.gregsitservices.com\/blog\/wp-json\/wp\/v2\/posts\/65\/revisions\/127"}],"wp:attachment":[{"href":"https:\/\/www.gregsitservices.com\/blog\/wp-json\/wp\/v2\/media?parent=65"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.gregsitservices.com\/blog\/wp-json\/wp\/v2\/categories?post=65"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.gregsitservices.com\/blog\/wp-json\/wp\/v2\/tags?post=65"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}