Linux에서 모든 열린 포트 목록을 찾는 방법


이 기사에서는 컴퓨터 네트워킹의 포트에 대해 간략히 설명하고 Linux에서 열려있는 모든 포트를 나열하는 방법으로 이동합니다.

컴퓨터 네트워킹에서, 더 확실히 소프트웨어 용어에서 포트는 Linux 운영 체제에서 주어진 응용 프로그램이나 프로세스를 식별하는 통신의 끝점 역할을하는 논리적 개체입니다. 최종 시스템에서 애플리케이션을 구분하는 16 비트 숫자 (0 ~ 65535)입니다.

가장 널리 사용되는 두 가지 인터넷 전송 프로토콜 인 TCP (Transmission Control Protocol)와 UDP (User Datagram Protocol) 및 기타 덜 알려진 프로토콜은 통신 세션에 포트 번호를 사용합니다 (소스 및 대상 IP 주소와 함께 소스 및 대상 포트 번호).

또한 TCP/UDP와 같은 IP 주소, 포트 및 프로토콜의 조합을 소켓이라고하며 모든 서비스에는 고유 한 소켓이 있어야합니다.

다음은 다양한 포트 범주입니다.

  1. 0-1023 – the Well Known Ports, also referred to as System Ports.
  2. 1024-49151 – the Registered Ports, also known as User Ports.
  3. 49152-65535 – the Dynamic Ports, also referred to as the Private Ports.

cat 명령을 사용하여 Linux의 /etc/services 파일에서 다양한 애플리케이션 및 포트/프로토콜 조합 목록을 볼 수 있습니다.

$ cat /etc/services 
OR
$ cat /etc/services | less
# /etc/services:
# $Id: services,v 1.48 2009/11/11 14:32:31 ovasik Exp $
#
# Network services, Internet style
# IANA services version: last updated 2009-11-10
#
# Note that it is presently the policy of IANA to assign a single well-known
# port number for both TCP and UDP; hence, most entries here have two entries
# even if the protocol doesn't support UDP operations.
# Updated from RFC 1700, ``Assigned Numbers'' (October 1994).  Not all ports
# are included, only the more common ones.
#
# The latest IANA port assignments can be gotten from
#       http://www.iana.org/assignments/port-numbers
# The Well Known Ports are those from 0 through 1023.
# The Registered Ports are those from 1024 through 49151
# The Dynamic and/or Private Ports are those from 49152 through 65535
#
# Each line describes one service, and is of the form:
#
# service-name  port/protocol  [aliases ...]   [# comment]

tcpmux          1/tcp                           # TCP port service multiplexer
tcpmux          1/udp                           # TCP port service multiplexer
rje             5/tcp                           # Remote Job Entry
rje             5/udp                           # Remote Job Entry
echo            7/tcp
echo            7/udp
discard         9/tcp           sink null
discard         9/udp           sink null
systat          11/tcp          users
systat          11/udp          users
daytime         13/tcp
daytime         13/udp
qotd            17/tcp          quote
qotd            17/udp          quote
msp             18/tcp                          # message send protocol
msp             18/udp                          # message send protocol
chargen         19/tcp          ttytst source
chargen         19/udp          ttytst source
ftp-data        20/tcp
ftp-data        20/udp
# 21 is registered to ftp, but also used by fsp
ftp             21/tcp
ftp             21/udp          fsp fspd
ssh             22/tcp                          # The Secure Shell (SSH) Protocol
ssh             22/udp                          # The Secure Shell (SSH) Protocol
telnet          23/tcp
telnet          23/udp

Linux에서 TCP 및 UDP를 포함하여 열려있는 모든 포트 또는 현재 실행중인 포트를 나열하기 위해 네트워크 연결 및 통계를 모니터링하는 강력한 도구 인 netstat를 사용합니다.

$ netstat -lntu

Proto Recv-Q Send-Q Local Address               Foreign Address             State      
tcp        0      0 0.0.0.0:22                  0.0.0.0:*                   LISTEN      
tcp        0      0 0.0.0.0:3306                0.0.0.0:*                   LISTEN      
tcp        0      0 0.0.0.0:25                  0.0.0.0:*                   LISTEN      
tcp        0      0 :::22                       :::*                        LISTEN      
tcp        0      0 :::80                       :::*                        LISTEN      
tcp        0      0 :::25                       :::*                        LISTEN      
udp        0      0 0.0.0.0:68                  0.0.0.0:*                               

어디,

  1. -l – prints only listening sockets
  2. -n – shows port number
  3. -t – enables listing of tcp ports
  4. -u – enables listing of udp ports

Linux 시스템에서 소켓을 검사하는 데 잘 알려진 유용한 유틸리티 인 ss 명령을 사용할 수도 있습니다. 아래 명령을 실행하여 열려있는 모든 TCP 및 UCP 포트를 나열합니다.

$ ss -lntu

Netid State      Recv-Q Send-Q               Local Address:Port       Peer Address:Port 
udp   UNCONN     0      0                    *:68                     *:*     
tcp   LISTEN     0      128                  :::22                    :::*     
tcp   LISTEN     0      128                  *:22                     *:*     
tcp   LISTEN     0      50                   *:3306                   *:*     
tcp   LISTEN     0      128                  :::80                    ::*     
tcp   LISTEN     0      100                  :::25                    :::*     
tcp   LISTEN     0      100                  *:25  

더 많은 사용 정보를 위해 위 명령의 man 페이지를 읽어보십시오.

요약하면 컴퓨터 네트워킹의 포트 개념을 이해하는 것은 시스템 및 네트워크 관리자에게 매우 중요합니다. 간단하고 정확하며 잘 설명 된 예제로이 netstat 가이드를 살펴볼 수도 있습니다.

마지막으로 Linux에서 열린 포트를 나열하는 다른 방법을 공유하거나 아래 응답 양식을 통해 질문하여 저희에게 연락하십시오.