Microsoft MVP성태의 닷넷 이야기
Windows: 171. "Administered port exclusions" 설명 [링크 복사], [링크+제목 복사]
조회: 10712
글쓴 사람
정성태 (techsharer at outlook.com)
홈페이지
첨부 파일
 
(연관된 글이 7개 있습니다.)
(시리즈 글이 3개 있습니다.)
Windows: 171. "Administered port exclusions" 설명
; https://www.sysnet.pe.kr/2/0/12293

Windows: 172. "Administered port exclusions"이 아닌 포트 범위 항목을 삭제하는 방법
; https://www.sysnet.pe.kr/2/0/12305

닷넷: 2158. C# - 소켓 포트를 미리 시스템에 등록/예약해 사용하는 방법(Port Exclusion Ranges)
; https://www.sysnet.pe.kr/2/0/13439




"Administered port exclusions" 설명

문서에 따르면,

You cannot exclude ports by using the ReservedPorts registry key in Windows Server 2008 or in Windows Server 2008 R2
; https://support.microsoft.com/en-us/help/2665809/you-cannot-exclude-ports-by-using-the-reservedports-registry-key-in-wi

Note In this example, "*" refers to port exclusions that were added by using the Netshell command prompt utility.


"*" 항목은 netsh 명령어로 직접 추가한 포트 범위라고 합니다. 실제로 제 테스트 PC에서 excludedportrange를 보면,

C:\WINDOWS\system32> netsh int ipv4 show excludedportrange protocol=tcp

Protocol tcp Port Exclusion Ranges

Start Port    End Port
----------    --------
        80          80
      5357        5357
      8010        8010
     50000       50059     *
     63759       63858
     63859       63958
     63959       64058

* - Administered port exclusions.

50000으로부터 60개의 포트가 (문서에 따라) netsh로 추가된 것이라고 나옵니다. 그럼 나머지는 어떻게 추가된 것일까요? 역시 동일한 문서에는,

an exclusion that is added by using the CreatePersistentTcpPortReservation or CreatePersistentUdpPortReservation function cannot be deleted by using the Netshell command prompt utility.


API에 의해서도 추가할 수 있다고 하며 그것은 netsh로 삭제할 수 없다고 합니다. 실제로 '*' 표시가 없는 항목을 neth로 삭제를 시도하면,

C:\WINDOWS\system32> netsh int ipv4 delete excludedportrange protocol=tcp startport=63759 numberofports=100
Access is denied.

관리자 권한으로 실행했음에도 저렇게 권한이 없다는 오류 메시지가 발생합니다.




해본 것은 아니지만, 아마도 '*' 표시가 없는 항목들을 삭제하려면 DeletePersistentTcpPortReservation API를 사용해야 할 것입니다. (업데이트 2020-09-01: 해당 API를 사용해 삭제하는 도구)

DeletePersistentTcpPortReservation function (is defined on Windows Vista and later.)
; https://learn.microsoft.com/en-us/windows/win32/api/iphlpapi/nf-iphlpapi-deletepersistenttcpportreservation

참고로, 전에 제가 썼던 글에서는,

소켓 바인딩 시 "System.Net.Sockets.SocketException: An attempt was made to access a socket in a way forbidden by its access permissions" 오류 발생
; https://www.sysnet.pe.kr/2/0/12240

꽤나 많은 포트들이 점유된 것을 볼 수 있는데, 프로그래머가 아닌 운영체제 관리자 입장에서 저런 포트들을 정리하고 싶을 때 API를 사용하는 것은 말이 안 됩니다. 그런 경우, "netsh int ip reset" 명령어를 사용하면 정리가 되긴 합니다.

C:\Windows\System32> netsh int ip reset
Resetting Compartment Forwarding, OK!
Resetting Compartment, OK!
Resetting Control Protocol, OK!
Resetting Echo Sequence Request, OK!
Resetting Global, OK!
Resetting Interface, OK!
Resetting Anycast Address, OK!
Resetting Multicast Address, OK!
Resetting Unicast Address, OK!
Resetting Neighbor, OK!
Resetting Path, OK!
Resetting Potential, OK!
Resetting Prefix Policy, OK!
Resetting Proxy Neighbor, OK!
Resetting Route, OK!
Resetting Site Prefix, OK!
Resetting Subinterface, OK!
Resetting Wakeup Pattern, OK!
Resetting Resolve Neighbor, OK!
Resetting , OK!
Resetting , OK!
Resetting , OK!
Resetting , OK!
Resetting , failed.
Access is denied.

Resetting , OK!
Resetting , OK!
Resetting , OK!
Resetting , OK!
Resetting , OK!
Resetting , OK!
Resetting , OK!
Restart the computer to complete this action.

단지, 주의할 점이 있다면 출력 결과를 보면 짐작할 수 있듯이 여러 가지 항목들을 함께 초기화시키므로 저 항목 중에 사용자 정의한 구성은 삭제될 수 있다는 점!




다음의 글에 보면,

Administered Port Exclusions blocking high ports
; https://dandini.wordpress.com/2019/07/15/administered-port-exclusions-blocking-high-ports/

레지스트리 키 설명이 하나 나오는데,

HKLM\SYSTEM\CurrentControlSet\Services\hns\State /v EnableExcludedPortRange 

기본적으로 EnableExcludedPortRange 항목은 등록이 안 되어 있습니다. 해당 글에 보면 Hyper-V가 설치된 시스템에서 50000 포트 영역의 항목이 있었다고 하지만 제가 관리하는 시스템 중에는 VM 내에서도 있는 걸로 보아 꼭 그런 것은 아닌 것 같습니다.

어쨌든, 저렇게 점유하는 항목을 없애려면 EnableExcludedPortRange 설정을 레지스트리에 추가하면 됩니다. 그다음 재부팅을 하면 다음과 같이 50000 포트 영역이 없어진 것을 확인할 수 있습니다.

C:\WINDOWS\system32> netsh int ipv4 show excludedportrange protocol=tcp

Protocol tcp Port Exclusion Ranges

Start Port    End Port
----------    --------
        80          80
      5357        5357
      8010        8010
     64269       64368
     64369       64468
     64469       64568

* - Administered port exclusions.




[이 글에 대해서 여러분들과 의견을 공유하고 싶습니다. 틀리거나 미흡한 부분 또는 의문 사항이 있으시면 언제든 댓글 남겨주십시오.]

[연관 글]






[최초 등록일: ]
[최종 수정일: 4/13/2023]

Creative Commons License
이 저작물은 크리에이티브 커먼즈 코리아 저작자표시-비영리-변경금지 2.0 대한민국 라이센스에 따라 이용하실 수 있습니다.
by SeongTae Jeong, mailto:techsharer at outlook.com

비밀번호

댓글 작성자
 




1  2  3  4  5  6  7  8  9  10  11  [12]  13  14  15  ...
NoWriterDateCnt.TitleFile(s)
13322정성태4/15/20234945VS.NET IDE: 182. Visual Studio - 32비트로만 빌드된 ActiveX와 작업해야 한다면?
13321정성태4/14/20233739개발 환경 구성: 676. WSL/Linux Octave - Python 스크립트 연동
13320정성태4/13/20233745개발 환경 구성: 675. Windows Octave 8.1.0 - Python 스크립트 연동
13319정성태4/12/20234200개발 환경 구성: 674. WSL 2 환경에서 GNU Octave 설치
13318정성태4/11/20234006개발 환경 구성: 673. JetBrains IDE에서 "Squash Commits..." 메뉴가 비활성화된 경우
13317정성태4/11/20234163오류 유형: 855. WSL 2 Ubuntu 20.04 - error: cannot communicate with server: Post http://localhost/v2/snaps/...
13316정성태4/10/20233491오류 유형: 854. docker-compose 시 "json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)" 오류 발생
13315정성태4/10/20233670Windows: 245. Win32 - 시간 만료를 갖는 컨텍스트 메뉴와 윈도우 메시지의 영역별 정의파일 다운로드1
13314정성태4/9/20233745개발 환경 구성: 672. DosBox를 이용한 Turbo C, Windows 3.1 설치
13313정성태4/9/20233841개발 환경 구성: 671. Hyper-V VM에 Turbo C 2.0 설치 [2]
13312정성태4/8/20233823Windows: 244. Win32 - 시간 만료를 갖는 MessageBox 대화창 구현 (개선된 버전)파일 다운로드1
13311정성태4/7/20234319C/C++: 163. Visual Studio 2022 - DirectShow 예제 컴파일(WAV Dest)
13310정성태4/6/20233881C/C++: 162. Visual Studio - /NODEFAULTLIB 옵션 설정 후 수동으로 추가해야 할 library
13309정성태4/5/20234052.NET Framework: 2107. .NET 6+ FileStream의 구조 변화
13308정성태4/4/20233942스크립트: 47. 파이썬의 time.time() 실숫값을 GoLang / C#에서 사용하는 방법
13307정성태4/4/20233724.NET Framework: 2106. C# - .NET Core/5+ 환경의 Windows Forms 응용 프로그램에서 HINSTANCE 구하는 방법
13306정성태4/3/20233569Windows: 243. Win32 - 윈도우(cbWndExtra) 및 윈도우 클래스(cbClsExtra) 저장소 사용 방법
13305정성태4/1/20233912Windows: 242. Win32 - 시간 만료를 갖는 MessageBox 대화창 구현 (쉬운 버전)파일 다운로드1
13304정성태3/31/20234276VS.NET IDE: 181. Visual Studio - C/C++ 프로젝트에 application manifest 적용하는 방법
13303정성태3/30/20233568Windows: 241. 환경 변수 %PATH%에 DLL을 찾는 규칙
13302정성태3/30/20234191Windows: 240. RDP 환경에서 바뀌는 %TEMP% 디렉터리 경로
13301정성태3/29/20234320Windows: 239. C/C++ - Windows 10 Version 1607부터 지원하는 /DEPENDENTLOADFLAG 옵션파일 다운로드1
13300정성태3/28/20233953Windows: 238. Win32 - Modal UI 창에 올바른 Owner(HWND)를 설정해야 하는 이유
13299정성태3/27/20233737Windows: 237. Win32 - 모든 메시지 루프를 탈출하는 WM_QUIT 메시지
13298정성태3/27/20233679Windows: 236. Win32 - MessageBeep 소리가 안 들린다면?
13297정성태3/26/20234355Windows: 235. Win32 - Code Modal과 UI Modal
1  2  3  4  5  6  7  8  9  10  11  [12]  13  14  15  ...