banner
Lifestream
  • 전체 카테고리 (104)
    • Digital Life (41)
      • Picture (20)
      • Video (21)
    • Daily Life (20)
    • Game Life (5)
    • Code Life (18)
    • Information Life (18)
profile
Home Category Guestboook Notice
Manage Write
  • 전체 카테고리 (104)
    • Digital Life (41)
      • Picture (20)
      • Video (21)
    • Daily Life (20)
    • Game Life (5)
    • Code Life (18)
    • Information Life (18)
GTK_LeonHeart
Manage Write
구독하기 RSS 어두운 모드 밝은 모드
Code Life
윈도우 해외 IP 차단하기~
2018. 9. 21. 08:26 · GTK_LeonHeart · 4

 

 

윈도우 해외 IP 차단하기
 

우선은 아래 링크에서 국가별IP목록이 있는 파일을 받아줍니다.

GeoIPCountryWhois.zip
13.07MB

최신버전 다운로드는 아래링크 클릭

 

Free updated GeoIP legacy databases

Free updated GeoIP legacy databases Here you can find regularly updated versions of the discontinued GeoIP legacy databases. Many distributions still use old GeoIP libraries, so you might find these useful. I use these on many systems myself, so consider t

mailfud.org

위 링크에서 GeoIP-legacy.csv.gz 파일을 받아 압축을 풀어 사용하면 됩니다,

파워쉘 스크립트 작성
 
아래의 내용에서 차단하기를 원하는 국가와 GeoIPCountryWhois.csv파일 경로를 바꾸신 후 문서 편집기로 작성 후
 
GeoIPCountryWhois.csv파일이 있는곳에  .ps1파일로 저장하면 됩니다. 
 
코드는 아래 PS1 파일을 받으세요. 
 

GeoIPCountryWhois.ps1
0.00MB

 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#############Config#################
$countryCode="CN" #차단할 나라의 CountryCode
#$geoIPcvsPath="c:\GeoIPCountryWhois.csv"
$geoIPcvsPath="\GeoIPCountryWhois.csv"
$ruleName="blockCountry"
#############Config#################
 
 
$geoData=Import-Csv $geoIPcvsPath -header sIP, eIP, start, end, cc, cn |  where-object {$_.cc –eq $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++
 
}
 
Colored by Color Scripter
cs
 

 

 
실행은 시작버튼을 누른 후 검색창에 PowerShell 이라고 친 후 뜨는 Windows Powershell을 마우스 우버튼으로 클릭후
관리자 권한으로 실행하면 됩니다.
스크립트 오류시 PowerShell 를 실행한 후
Set-ExecutionPolicy Unrestricted 명령을 실행하고

 

.\GeoIPCountryWhois.ps1 를 실행 해주세요.

 

오류관련 참고 사이트: https://samsons.tistory.com/16

Set-ExecutionPolicy Unrestricted
ExecutionPolicy      <-- 현재상태확인
Unrestricted           <-- 모든 스크립트 허용 상태.

 

 
참고 URL : http://blog.netchk.net/?p=1427

 

 

 
제 블로그의 내용이 도움이 되셨나요?

여러분의 공감과 댓글이 큰 힘이됩니다 :)

▼▼▼▼▼▼▼▼▼▼▼

 

 

 

 

 

저작자표시 비영리
카테고리 다른 글
related
리눅스 해외IP 차단하기~
related
[HTML] 접기버튼 + C소스보기!
related
[WinAPI] 01 PE 파일 분석-헤더분석
related
[WinAPI] 02 PE 파일 분석-Import 분석
more

  • smile
  • cry
  • nervous
  • disappointed
  • drunk
  • confused
  • kiss
  • love
(?)
확인

Links

  • faviconLifstream NAS
  • faviconThe LAST Web page
  • favicon월반장의 바구니
  • favicon박수홍2 의 고전컴 세상
  • favicon패싱님 티스토리
  • favicon혼자 끄적이는 블로그
  • favicon땀똔즈 블로그
  • favicon변덕 심한 묘한오빠
  • faviconSONYLOVE
  • favicon북쉐프 로샤씨

Notice

  • thumbnail20.01.05 블로그 스킨 업데이트
  • thumbnail18.04.18 안녕하세요

Recent Posts

  • GTA 온라인 개인세션(화이트리스트 세션?) 프로⋯
  • [DOS 게임] 그날이 오면 3: Dragon F⋯
  • 집근처(?) 만년교라는 다리입니다.
  • 노라조 - 빵 MV
  • GTA V 실행시 미국 키보드 없애기
  • 블로그 QR 코드
+ 더 보기

Recent Comments

  • 답변이 늦어 죄송합니다. 제 블로그의 csv파일과 받⋯ GTK_LeonHeart
  • 그리고 우클릭 해서 실행 하면 팝업이 뜨고 사라지고 설⋯ 동우
  • 전 윈도우11인대요 ㅠㅠ 오늘 해보니 안되더라고요 뷁 ⋯ 동우
  • 안녕하세요. 포스팅 잘 봤습니다. 혹시 회로 공유해주실⋯ ㅇㅇ
  • 한국을 제외한 모든 국가를 차단할때는 어케하나요? ⋯ 종우니
  • 아무런 설정없이 , 아무 경로에 vi 파일만 만들어주면⋯ 갭발자
GTK_LeonHeart
Game, Media , Life, Infomation.
Blog by GTK_LeonHeart Designed by Marshall K

티스토리툴바