[ad_1]
I didn’t make it. https://lifestream.kr/90 (Original address)
I want to block a specific country ip.
Except for my country. Also, I want to block ip except for router ip Google dns.
China, Russia and North Korea. These three countries.
The old one works well.
But it doesn’t work after swapping files.
GeoIPCountryWhois.csv
=The file is old. Updates are no longer supported. a chargeable conversion
.
GeoIPCountryWhois.csv
=original file(old) , IP2LOCATION-LITE-DB1.CSV
=A new file I want to put in.
https://dev.maxmind.com/geoip/docs/databases/city-and-country?lang=en#csv-databases
It became a paid service.=GeoIPCountryWhois.csv
https://download.ip2location.com/lite/ This is a free service.=IP2LOCATION-LITE-DB1.CSV
GeoIPCountryWhois.csv
=The file works fine.
IP2LOCATION-LITE-DB1.CSV
=But… this file doesn’t work.
.
The files are different.
original file GeoIPCountryWhois.csv
"1.0.0.0","1.0.0.255","16777216","16777471","AU","Australia"
"1.0.1.0","1.0.3.255","16777472","16778239","CN","China"
"1.0.4.0","1.0.7.255","16778240","16779263","AU","Australia"
"1.0.8.0","1.0.15.255","16779264","16781311","CN","China"
.
Free version file IP2LOCATION-LITE-DB1.CSV
"0","16777215","-","-"
"16777216","16777471","US","United States of America"
"16777472","16778239","CN","China"
"16778240","16779263","AU","Australia"
"16779264","16781311","CN","China"
"16781312","16785407","JP","Japan"
So I can’t apply the new file
.\test.ps1
#############Config#################
$countryCode="CN", "RU", "KP" #차단할 나라의 CountryCode
#$geoIPcvsPath="d:\IP2LOCATION-LITE-DB1.CSV"
$geoIPcvsPath="\IP2LOCATION-LITE-DB1.CSV"
$ruleName="blockCountry"
#############Config#################
$geoData=Import-Csv $geoIPcvsPath -header sIP, eIP, start, end, cc, cn | where-object {$_.cc –in $countryCode}
$geoDataTotal=$geoData.Count
$remoteIP=""
###### 룰이 있는 지 체크 ########
function ruleExistsChk ($ruleName)
{
$fw=New-object -comObject HNetCfg.FwPolicy2; # http://blogs.technet.com/b/jamesone/archive/2009/02/18/how-to-manage-the-windows-firewall-settings-with-powershell.aspx
$RuleCHK=$fw.rules | where-object {$_.name –eq $ruleName}
if(!$RuleCHK){
#$deny_rule_name + " 룰이 생성되어 있지 않습니다."; exit;
netsh advfirewall firewall add rule name="$ruleName" localip=any dir=in action=block profile="any" interfacetype="any"
}
}
###### 룰이 있는 지 체크 ########
$count=1
foreach ($geoIP in $geoData)
{
#$remoteIP+=@($geoIP.sIP+"-"+$geoIP.eIP+",") #배열로 저장.
$remoteIP+=$geoIP.sIP+"-"+$geoIP.eIP+","
#remoteAddr가 한개의 룰에 약 300개 이상이면 등록이 안됨. 안전하게 200으로 설정.
if(($count%200) -eq 0)
{
$makeRuleName=$ruleName+$countryCode+$count
ruleExistsChk($makeRuleName)
netsh advfirewall firewall set rule name=$makeRuleName new remoteip="$remoteIP"
$remoteIP=""
}elseif($geoDataTotal -eq $count){
$makeRuleName=$ruleName+$countryCode+$count
ruleExistsChk($makeRuleName)
netsh advfirewall firewall set rule name=$makeRuleName new remoteip="$remoteIP"
$remoteIP=""
}
$count++
}
If you run it, nothing happens.
The command I ordered to register is not generated, but only the computer cursor appears.
findstr /blv "# 0.0.0. 192.168.0.0/16 224.0.0.0/16 172.30. 192.168. 224.0. 168.126. 210.220. 219.250. 61.41. 1.214. 164.124. 203.248. 180.182. 94.140. 208.67. 1.1. 1.0. 8.8. 9.9. 149.112. 194.242. 185.222. 45.11. 10.0. 172.162"
I’d like to exclude some ip.
https://mirror.dk.team.blue/firehol/ip2location_country/ip2location_country_kr.netset
And I want to exclude Korean IP from the above ip. Because I am Korean in Seoul.. Because I can’t use the internet if similar ip Korea is blocked.
There are three questions.
Thank you.
[ad_2]