Microsoft MVP성태의 닷넷 이야기
Windows: 171. "Administered port exclusions" 설명 [링크 복사], [링크+제목 복사]
조회: 10679
글쓴 사람
정성태 (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

비밀번호

댓글 작성자
 




... 16  17  18  [19]  20  21  22  23  24  25  26  27  28  29  30  ...
NoWriterDateCnt.TitleFile(s)
13144정성태10/20/20225682.NET Framework: 2059. ClrMD를 이용해 윈도우 환경의 메모리 덤프로부터 닷넷 모듈을 추출하는 방법파일 다운로드1
13143정성태10/19/20226208오류 유형: 821. windbg/sos - Error code - 0x000021BE
13142정성태10/18/20224886도서: 시작하세요! C# 12 프로그래밍
13141정성태10/17/20226696.NET Framework: 2058. [in,out] 배열을 C#에서 C/C++로 넘기는 방법 - 세 번째 이야기파일 다운로드1
13140정성태10/11/20226042C/C++: 159. C/C++ - 리눅스 환경에서 u16string 문자열을 출력하는 방법 [2]
13139정성태10/9/20225904.NET Framework: 2057. 리눅스 환경의 .NET Core 3/5+ 메모리 덤프로부터 모든 닷넷 모듈을 추출하는 방법파일 다운로드1
13138정성태10/8/20227182.NET Framework: 2056. C# - await 비동기 호출을 기대한 메서드가 동기로 호출되었을 때의 부작용 [1]
13137정성태10/8/20225566.NET Framework: 2055. 리눅스 환경의 .NET Core 3/5+ 메모리 덤프로부터 닷넷 모듈을 추출하는 방법
13136정성태10/7/20226150.NET Framework: 2054. .NET Core/5+ SDK 설치 없이 dotnet-dump 사용하는 방법
13135정성태10/5/20226381.NET Framework: 2053. 리눅스 환경의 .NET Core 3/5+ 메모리 덤프를 분석하는 방법 - 두 번째 이야기
13134정성태10/4/20225094오류 유형: 820. There is a problem with AMD Radeon RX 5600 XT device. For more information, search for 'graphics device driver error code 31'
13133정성태10/4/20225435Windows: 211. Windows - (commit이 아닌) reserved 메모리 사용량 확인 방법 [1]
13132정성태10/3/20225309스크립트: 42. 파이썬 - latexify-py 패키지 소개 - 함수를 mathjax 식으로 표현
13131정성태10/3/20227949.NET Framework: 2052. C# - Windows Forms의 데이터 바인딩 지원(DataBinding, DataSource) [2]파일 다운로드1
13130정성태9/28/20225086.NET Framework: 2051. .NET Core/5+ - 에러 로깅을 위한 Middleware가 동작하지 않는 경우파일 다운로드1
13129정성태9/27/20225374.NET Framework: 2050. .NET Core를 IIS에서 호스팅하는 경우 .NET Framework CLR이 함께 로드되는 환경
13128정성태9/23/20227946C/C++: 158. Visual C++ - IDL 구문 중 "unsigned long"을 인식하지 못하는 #import파일 다운로드1
13127정성태9/22/20226400Windows: 210. WSL에 systemd 도입
13126정성태9/15/20227007.NET Framework: 2049. C# 11 - 정적 메서드에 대한 delegate 처리 시 cache 적용
13125정성태9/14/20227195.NET Framework: 2048. C# 11 - 구조체 필드의 자동 초기화(auto-default structs)
13124정성태9/13/20226921.NET Framework: 2047. Golang, Python, C#에서의 CRC32 사용
13123정성태9/8/20227379.NET Framework: 2046. C# 11 - 멤버(속성/필드)에 지정할 수 있는 required 예약어 추가
13122정성태8/26/20227392.NET Framework: 2045. C# 11 - 메서드 매개 변수에 대한 nameof 지원
13121정성태8/23/20225379C/C++: 157. Golang - 구조체의 slice 필드를 Reflection을 이용해 변경하는 방법
13120정성태8/19/20226812Windows: 209. Windows NT Service에서 UI를 다루는 방법 [3]
13119정성태8/18/20226382.NET Framework: 2044. .NET Core/5+ 프로젝트에서 참조 DLL이 보관된 공통 디렉터리를 지정하는 방법
... 16  17  18  [19]  20  21  22  23  24  25  26  27  28  29  30  ...