Microsoft MVP성태의 닷넷 이야기
Windows: 171. "Administered port exclusions" 설명 [링크 복사], [링크+제목 복사]
조회: 10695
글쓴 사람
정성태 (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)
13599정성태4/17/2024230닷넷: 2241. C# - WAV 파일의 PCM 사운드 재생(Windows Multimedia)파일 다운로드1
13598정성태4/16/2024253닷넷: 2240. C# - WAV 파일 포맷 + LIST 헤더파일 다운로드1
13597정성태4/15/2024316닷넷: 2239. C# - WAV 파일의 PCM 데이터 생성 및 출력파일 다운로드1
13596정성태4/14/2024592닷넷: 2238. C# - WAV 기본 파일 포맷파일 다운로드1
13595정성태4/13/2024702닷넷: 2237. C# - Audio 장치 열기 (Windows Multimedia, NAudio)파일 다운로드1
13594정성태4/12/2024905닷넷: 2236. C# - Audio 장치 열람 (Windows Multimedia, NAudio)파일 다운로드1
13593정성태4/8/20241020닷넷: 2235. MSBuild - AccelerateBuildsInVisualStudio 옵션
13592정성태4/2/20241199C/C++: 165. CLion으로 만든 Rust Win32 DLL을 C#과 연동
13591정성태4/2/20241162닷넷: 2234. C# - WPF 응용 프로그램에 Blazor App 통합파일 다운로드1
13590정성태3/31/20241071Linux: 70. Python - uwsgi 응용 프로그램이 k8s 환경에서 OOM 발생하는 문제
13589정성태3/29/20241137닷넷: 2233. C# - 프로세스 CPU 사용량을 나타내는 성능 카운터와 Win32 API파일 다운로드1
13588정성태3/28/20241191닷넷: 2232. C# - Unity + 닷넷 App(WinForms/WPF) 간의 Named Pipe 통신파일 다운로드1
13587정성태3/27/20241147오류 유형: 900. Windows Update 오류 - 8024402C, 80070643
13586정성태3/27/20241284Windows: 263. Windows - 복구 파티션(Recovery Partition) 용량을 늘리는 방법
13585정성태3/26/20241092Windows: 262. PerformanceCounter의 InstanceName에 pid를 추가한 "Process V2"
13584정성태3/26/20241046개발 환경 구성: 708. Unity3D - C# Windows Forms / WPF Application에 통합하는 방법파일 다운로드1
13583정성태3/25/20241146Windows: 261. CPU Utilization이 100% 넘는 경우를 성능 카운터로 확인하는 방법
13582정성태3/19/20241220Windows: 260. CPU 사용률을 나타내는 2가지 수치 - 사용량(Usage)과 활용률(Utilization)파일 다운로드1
13581정성태3/18/20241566개발 환경 구성: 707. 빌드한 Unity3D 프로그램을 C++ Windows Application에 통합하는 방법
13580정성태3/15/20241133닷넷: 2231. C# - ReceiveTimeout, SendTimeout이 적용되지 않는 Socket await 비동기 호출파일 다운로드1
13579정성태3/13/20241493오류 유형: 899. HTTP Error 500.32 - ANCM Failed to Load dll
13578정성태3/11/20241625닷넷: 2230. C# - 덮어쓰기 가능한 환형 큐 (Circular queue)파일 다운로드1
13577정성태3/9/20241858닷넷: 2229. C# - 닷넷을 위한 난독화 도구 소개 (예: ConfuserEx)
13576정성태3/8/20241540닷넷: 2228. .NET Profiler - IMetaDataEmit2::DefineMethodSpec 사용법
13575정성태3/7/20241670닷넷: 2227. 최신 C# 문법을 .NET Framework 프로젝트에 쓸 수 있을까요?
[1]  2  3  4  5  6  7  8  9  10  11  12  13  14  15  ...