ping 또는 telnet으로 통신(포트) 상태 확인

ping 또는 telnet으로 통신(포트) 상태 확인

핑 테스트(ICMP)

$ ping -c 3 8.8.8.8
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_seq=1 ttl=105 time=26.5 ms
64 bytes from 8.8.8.8: icmp_seq=2 ttl=105 time=26.5 ms
64 bytes from 8.8.8.8: icmp_seq=3 ttl=105 time=26.5 ms

--- 8.8.8.8 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2003ms
rtt min/avg/max/mdev = 26.519/26.523/26.529/0.133 ms

응답이 없으면(no ping) 방화벽에 등록되지 않은 것입니다.

텔넷 IP 포트(서비스 포트) 확인

$ telnet 8.8.8.8 80
Trying 8.8.8.8...

여전히 대기 중인 경우 방화벽이 열려 있지 않은 것입니다.

$ telnet 8.8.8.8 80
Trying 8.8.8.8... 
telnet: Unable to connect to remote host: Connection refused 

연결 거부가 즉시 발생하면 방화벽이 열려 있지만 프로세스가 실행되지 않습니다.


(포트가 열려 있고 기다리지 않음)

$ telnet 8.8.8.8 80
Trying 8.8.8.8...
Connected to 8.8.8.8.
Escape character is '^)'.
Connection closed by foreign host.

방화벽이 정상적으로 열려 프로세스가 실행 중입니다.


(포트가 열리고 대기 중)

라우팅 테이블 확인

$ netstat -rn
Kernel IP routing table
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
0.0.0.0         10.10.3.1       0.0.0.0         UG        0 0          0 eth0
10.10.3.0       0.0.0.0         255.255.255.0   U         0 0          0 eth0
169.254.169.254 0.0.0.0         255.255.255.255 UH        0 0          0 eth0

tcping 명령

TCP(리눅스용)

TCP 설치

yum install -y tcping

TCP 사용

Usage: tcping (-q) (-t timeout_sec) (-u timeout_usec) <host> <port>

TCP 명령 실행

닫은

$ tcping sangchul.kr 80
sangchul.kr port 80 closed.

열려 있는

$ tcping sangchul.kr 80
sangchul.kr port 80 open.
$ tcping sangchul.kr 443
sangchul.kr port 443 open.

TCP(Windows용)

TCP 다운로드 URL

https://www.elifulkerson.com/projects/downloads/tcping-0.34/tcping.exe

TCP 사용

> tcping /? | more
--------------------------------------------------------------
tcping.exe by Eli Fulkerson
Please see http://www.elifulkerson.com/projects/ for updates.
--------------------------------------------------------------

Usage: tcping (-flags) server-address (server-port)

Usage (full): tcping (-t) (-d) (-i interval) (-n times) (-w ms) (-b n) (-r times) (-s) (-v) (-j) (-js size) (-4) (-6) (-
c) (-g count) (-S source_address) (--file) (--tee filename) (-h) (-u) (--post) (--head) (--proxy-port port) (--proxy-ser
ver server) (--proxy-credentials username:password) (-f) server-address (server-port)

 -t     : ping continuously until stopped via control-c
 -n 5   : for instance, send 5 pings
 -i 5   : for instance, ping every 5 seconds
 -w 0.5 : for instance, wait 0.5 seconds for a response
 -d     : include date and time on each line
 -b 1   : enable beeps (1 for on-down, 2 for on-up,
                        3 for on-change, 4 for always)
 -r 5   : for instance, relookup the hostname every 5 pings
 -s     : automatically exit on a successful ping
 -v     : print version and exit
 -j     : include jitter, using default rolling average
 -js 5  : include jitter, with a rolling average size of (for instance) 5.
 --tee  : mirror output to a filename specified after '--tee'
 -4     : prefer ipv4
 -6     : prefer ipv6
 -c     : only show an output line on changed state
 --file : treat the "server-address" as a filename instead, loop through file line by line
          Note: --file is incompatible with options such as -j and -c as it is looping through different targets
          Optionally accepts server-port.  For example, "example.org 443" is valid.
 -g 5   : for instance, give up if we fail 5 times in a row
 -S _X_ : Specify source address _X_.  Source must be a valid IP for the client computer.

TCP 명령 실행

tcping -h sangchul.kr
>tcping -h sangchul.kr

** Requesting  from sangchul.kr:
(for various reasons, kbit/s is an approximation)

Probing 175.126.170.70:80/tcp - HTTP is open - time=7.632ms rcv_time=222.791 status=200 bytes=37050 kbit/s=~1330.394
Probing 175.126.170.70:80/tcp - HTTP is open - time=7.879ms rcv_time=178.562 status=200 bytes=37050 kbit/s=~1659.927
Probing 175.126.170.70:80/tcp - HTTP is open - time=7.787ms rcv_time=156.653 status=200 bytes=37051 kbit/s=~1892.136
Probing 175.126.170.70:80/tcp - HTTP is open - time=7.609ms rcv_time=155.861 status=200 bytes=37051 kbit/s=~1901.752

Ping statistics for 175.126.170.70:80
     4 probes sent.
     4 successful, 0 failed.
Approximate trip times in milli-seconds:
     Minimum = 7.609ms, Maximum = 7.879ms, Average = 7.727ms
Approximate download times in milli-seconds:
     Minimum = 155.861ms, Maximum = 222.791ms, Average = 178.467ms
tcping -d -t 1.1.1.1 7777
>tcping -d -t 1.1.1.1 7777

** Pinging continuously.  Press control-c to stop **

2021:02:22 11:28:49 Probing 111.111.111.111:7777/tcp - No response - time=2012.647ms
2021:02:22 11:28:51 Probing 111.111.111.111:7777/tcp - No response - time=2007.161ms
2021:02:22 11:28:53 Probing 111.111.111.111:7777/tcp - No response - time=2006.367ms
...
2021:02:22 11:29:29 Probing 111.111.111.111:7777/tcp - Port is open - time=32.171ms
2021:02:22 11:29:31 Probing 111.111.111.111:7777/tcp - Port is open - time=22.162ms
2021:02:22 11:29:32 Probing 111.111.111.111:7777/tcp - Port is open - time=21.967ms
Control-C

Ping statistics for 111.111.111.111:7777
     158 probes sent.
     142 successful, 16 failed.  (10.13% fail)
Approximate trip times in milli-seconds (successful connections only):
     Minimum = 21.438ms, Maximum = 1015.360ms, Average = 29.750ms

참조 URL

– ping 또는 telnet으로 통신(포트) 상태 확인: https://scbyun.com/740

-tcping(리눅스용): https://scbyun.com/793
-tcping(Windows용): https://scbyun.com/622