Microsoft MVP성태의 닷넷 이야기
Windows: 171. "Administered port exclusions" 설명 [링크 복사], [링크+제목 복사]
조회: 10681
글쓴 사람
정성태 (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)
13395정성태7/20/20233305개발 환경 구성: 685. 로컬에서 개발 중인 ASP.NET Core/5+ 웹 사이트에 대해 localhost 이외의 호스트 이름으로 접근하는 방법
13394정성태7/16/20233249오류 유형: 873. Oracle.ManagedDataAccess.Client - 쿼리 수행 시 System.InvalidOperationException
13393정성태7/16/20233413닷넷: 2133. C# - Oracle 데이터베이스의 Sleep 쿼리 실행하는 방법
13392정성태7/16/20233278오류 유형: 872. Oracle - ORA-01031: insufficient privileges
13391정성태7/14/20233366닷넷: 2132. C# - sealed 클래스의 메서드를 callback 호출했을 때 인라인 처리가 될까요?
13390정성태7/12/20233337스크립트: 53. 파이썬 - localhost 호출 시의 hang 현상
13389정성태7/5/20233319개발 환경 구성: 684. IIS Express로 호스팅하는 웹을 WSL 환경에서 접근하는 방법
13388정성태7/3/20233504오류 유형: 871. 윈도우 탐색기에서 열리지 않는 zip 파일 - The Compressed (zipped) Folder '[...].zip' is invalid. [1]파일 다운로드1
13387정성태6/28/20233530오류 유형: 870. _mysql - Commands out of sync; you can't run this command now
13386정성태6/27/20233600Linux: 61. docker - 원격 제어를 위한 TCP 바인딩 추가
13385정성태6/27/20233799Linux: 60. Linux - 외부에서의 접속을 허용하기 위한 TCP 포트 여는 방법
13384정성태6/26/20233557.NET Framework: 2131. C# - Source Generator로 해결하는 enum 박싱 문제파일 다운로드1
13383정성태6/26/20233307개발 환경 구성: 683. GPU 런타임을 사용하는 Colab 노트북 설정
13382정성태6/25/20233346.NET Framework: 2130. C# - Win32 API를 이용한 윈도우 계정 정보 (예: 마지막 로그온 시간)파일 다운로드1
13381정성태6/25/20233730오류 유형: 869. Fatal Python error: init_fs_encoding: failed to get the Python codec of the filesystem encoding
13380정성태6/24/20233193스크립트: 52. 파이썬 3.x에서의 동적 함수 추가
13379정성태6/23/20233205스크립트: 51. 파이썬 2.x에서의 동적 함수 추가
13378정성태6/22/20233093오류 유형: 868. docker - build 시 "CANCELED ..." 뜨는 문제
13377정성태6/22/20236857오류 유형: 867. 파이썬 mysqlclient 2.2.x 설치 시 "Specify MYSQLCLIENT_CFLAGS and MYSQLCLIENT_LDFLAGS env vars manually" 오류
13376정성태6/21/20233282.NET Framework: 2129. C# - Polly를 이용한 클라이언트 측의 요청 재시도파일 다운로드1
13375정성태6/20/20232977스크립트: 50. Transformers (신경망 언어모델 라이브러리) 강좌 - 2장 코드 실행 결과
13374정성태6/20/20233106오류 유형: 866. 파이썬 - <class 'AttributeError'> module 'flask.json' has no attribute 'JSONEncoder'
13373정성태6/19/20234395오류 유형: 865. 파이썬 - pymssql 설치 관련 오류 정리
13372정성태6/15/20233103개발 환경 구성: 682. SQL Server TLS 통신을 위해 사용되는 키 길이 확인 방법
13371정성태6/15/20233109개발 환경 구성: 681. openssl - 인증서 버전(V1 / V3)
13370정성태6/14/20233288개발 환경 구성: 680. C# - Ubuntu + Microsoft.Data.SqlClient + SQL Server 2008 R2 연결 방법 - TLS 1.2 지원
1  2  3  4  5  6  7  8  [9]  10  11  12  13  14  15  ...