Windows Server는 애플리케이션이나 클라이언트 PC가 특정 포트 또는 서버 IP에 연결하지 못하는 문제를 진단할 수 있도록 관리자에게 다양한 도구를 제공합니다. DNS 문제 등 일반적인 네트워크 문제를 해결하는 유틸리티가 여러 가지 있지만, PowerShell을 즐겨 사용하는 관리자라면 Test-NetConnection이라는 강력한 cmdlet을 활용하는 것이 좋습니다.

PowerShell로 네트워크 연결 문제 해결하기
Test-NetConnection cmdlet을 사용하면 대상 연결에 대한 상세한 진단 정보를 확인할 수 있습니다. Ping 테스트, TCP 포트 테스트, 경로 추적(Trace Route)은 물론 경로 선택(Route Selection) 진단까지 지원합니다.
사용하는 옵션에 따라 출력 결과에는 ComputerName, RemoteAddress, SelectedSourceAddress, OutgoingInterfaceIndex, SelectedNetRoute 등의 정보가 포함됩니다.
주요 매개변수 정리
- CommonTCPPort: HTTP, HTTPS 등 일반적인 서비스의 TCP 포트 번호를 지정합니다.
- ComputerName: 대상 컴퓨터의 DNS 이름 또는 IP 주소를 지정합니다.
- ConstrainInterface: 경로 진단에 사용할 인터페이스 제약 조건을 지정합니다.
- ConstrainSourceAddress: 경로 진단에 사용할 원본(Source) 주소 제약 조건을 지정합니다.
- DiagnoseRouting: 원격 호스트에 대한 경로 및 원본 주소 선택 정보를 출력하는 라우팅 진단을 실행합니다.
- Hops: traceroute 명령에서 통과할 홉(hop) 수를 지정합니다.
- InformationLevel: 출력 정보 수준을 Detailed(상세) 또는 Quiet(간략)로 지정합니다.
- Port: 원격 컴퓨터의 TCP 포트 번호를 지정합니다.
- TraceRoute: Tracert를 실행하여 원격 호스트와의 연결 경로를 테스트합니다.
Test-NetConnection 실전 활용 예시
Test-NetConnection -ComputerName "www.contoso.com" -ConstrainInterface 5 -DiagnoseRouting -InformationLevel "Detailed"
ComputerName : www.contoso.com
RemoteAddress : 2600:1409:a:185::2768
ConstrainInterfaceIndex : 5
SelectedSourceAddress : 2001:4898:e0:79:75dd:64cf:d9ff:f86
OutgoingInterfaceIndex : 5
SelectedNetRoute : DestinationPrefix: ::/0
NextHop: fe80::200:5eff:fe00:202
RouteSelectionEvents : IP: Route [DestinationPrefix: ::/0 NextHop: fe80::200:5eff:fe00:202 InterfaceIndex: 4
RouteMetric: 256] is blocked for Destination: 2600:1409:a:185::2768 ConstrainInterfaceIndex: 5 ConstrainScopeZone: 1 in Compartment: 1, Reason: InterfaceConstraint.
SourceAddressSelectionEvents : IP: Source address 2001:4898:e0:79:75dd:64cf:d9ff:f86 is preferred over fe80::75dd:64cf:d9ff:f86 for destination 2600:1409:a:185::2768 Rule = 2.0.
IP: Source address 2001:4898:e0:79:75dd:64cf:d9ff:f86 is preferred over fe80::75dd:64cf:d9ff:f86 for destination 2600:1409:a:185::2768 Rule = 2.0.
RouteDiagnosticsSucceeded : True
바로 사용해 볼 수 있는 샘플 명령어 모음

아래는 실제 환경에서 바로 시도해 볼 수 있는 명령어 예시입니다. 일부 명령은 관리자 권한이 필요하므로, 반드시 필요한 권한으로 PowerShell 7 또는 PowerShell 5.1을 실행하세요.
기본 연결 테스트:
Test-NetConnection youtube.com
더 자세한 연결 정보 확인:
Test-NetConnection youtube.com -InformationLevel "Detailed"
웹 서비스 작업 시 특정 TCP 포트 테스트:
Test-NetConnection youtube.com -Port 443 -InformationLevel "Detailed"
원격 호스트 접속을 위한 라우팅 진단 수행:
Test-NetConnection -ComputerName itopstalk.com -DiagnoseRouting -InformationLevel Detailed
웹사이트의 기본 포트 확인:
Test-NetConnection -ComputerName microsoft.com -CommonTCPPort HTTP
웹사이트에 대한 Trace Route 실행:
Test-NetConnection -ComputerName google.com -TraceRoute
특히 이 cmdlet은 Windows가 아닌 플랫폼에서도 Windows와 동일한 명령 구문으로 사용할 수 있어 크로스 플랫폼 환경에서 매우 유용합니다.
다만 Microsoft.com처럼 일부 웹사이트에서는 명령이 정상적으로 작동하지 않는 경우가 있었습니다. Ping이 계속 실패하는데, 이는 해당 서버 측에서 무작위 요청을 차단하고 있기 때문일 가능성이 높습니다.