다른 서버나 컴퓨터의 포트가 열렸는지 확인하는 방법
다른 서버의 특정 포트가 열려 있는지 알아야 할 때가 있습니다. 윈도우와 리눅스에서 확인하는 방법을 정리합니다.
윈도우
telnet 명령어 이용하는 방법
- 텔넷 클라이언트 기능을 추가합니다.
- 명령 프롬프트(CMD) 또는 PowerShell에서 다음과 같이 명령합니다. google.com의 443 포트가 열렸는지 확인하는 것입니다.
C:\Users\JB>telnet google.com 443
- 포트가 열려 있다면 아무 내용 없는 창이 나옵니다.
- 만약 닫혀 있다면 아래와 같이 연결하지 못한다는 메시지가 나옵니다.
C:\Users\JB>telnet google.com 444 연결 대상 google.com...호스트에 연결할 수 없습니다. 포트 444: 연결하지 못했습니다.
tnc 명령어 이용하는 방법
- PowerShell에서 다음과 같이 명령합니다. google.com의 443 포트가 열렸는지 확인하는 것입니다.
- 열려 있다면 True...
PS C:\Users\JB> tnc google.com -port 443 ComputerName : google.com RemoteAddress : 142.250.76.142 RemotePort : 443 InterfaceAlias : Ethernet SourceAddress : 192.168.0.201 TcpTestSucceeded : True
- 그렇지 않다면 False를 반환합니다.
PS C:\Users\JB> tnc google.com -port 444 경고: TCP connect to (142.250.76.142 : 444) failed ComputerName : google.com RemoteAddress : 142.250.76.142 RemotePort : 444 InterfaceAlias : Ethernet SourceAddress : 192.168.0.201 PingSucceeded : True PingReplyDetails (RTT) : 34 ms TcpTestSucceeded : False
Test-NetConnection 명령어 이용하는 방법
- PowerShell에서 다음과 같이 명령합니다. google.com의 443 포트가 열렸는지 확인하는 것입니다.
PS C:\Users\jb> Test-NetConnection -ComputerName google.com -Port 443 ComputerName : google.com RemoteAddress : 142.250.207.110 RemotePort : 443 InterfaceAlias : Ethernet SourceAddress : 192.168.0.200 TcpTestSucceeded : True
리눅스
- nc 명령어로 확인할 수 있습니다.
# nc -zv google.com 443 Ncat: Version 7.70 ( https://nmap.org/ncat ) Ncat: Connected to 142.250.206.206:443. Ncat: 0 bytes sent, 0 bytes received in 0.05 seconds.