Check an open port with nping

2024-03-02
2023-04-18

The ping command is not specify the port number. In macOS, specify it with nmap.

Installation

Install nmap with Homebrew.

terminal

$ brew install nmap

Error

It sometimes occurs the following error while installing.

terminal

Error: The `brew link` step did not complete successfully
The formula built, but is not symlinked into /usr/local
Could not symlink share/man/de/man1/nmap.1
/usr/local/share/man/de/man1 is not writable.

You can try again using:
  brew link nmap
==> Summary
🍺  /usr/local/Cellar/nmap/7.93: 826 files, 26.5MB
==> Running `brew cleanup nmap`...
Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP.
Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).

It has not been executed because it has not been authorized.

terminal

$ sudo chown -R <username> /usr/local/share/man/de
$ brew list nmap

Usage

The following is an example of successful communication with the port.

terminal

$ nping rpc.uni.junonetwork.io -p 443

Starting Nping 0.7.93 ( https://nmap.org/nping ) at 2023-04-17 14:58 JST
libnsock mksock_bind_addr(): Bind to 0.0.0.0:0 failed (IOD #1): Invalid argument (22)
SENT (0.2020s) Starting TCP Handshake > rpc.uni.junonetwork.io:443 (135.125.180.36:443)
RCVD (0.4679s) Handshake with rpc.uni.junonetwork.io:443 (135.125.180.36:443) completed
libnsock mksock_bind_addr(): Bind to 0.0.0.0:0 failed (IOD #2): Invalid argument (22)
SENT (1.2042s) Starting TCP Handshake > rpc.uni.junonetwork.io:443 (135.125.180.36:443)
RCVD (1.4695s) Handshake with rpc.uni.junonetwork.io:443 (135.125.180.36:443) completed
libnsock mksock_bind_addr(): Bind to 0.0.0.0:0 failed (IOD #3): Invalid argument (22)
SENT (2.2062s) Starting TCP Handshake > rpc.uni.junonetwork.io:443 (135.125.180.36:443)
RCVD (2.5282s) Handshake with rpc.uni.junonetwork.io:443 (135.125.180.36:443) completed
libnsock mksock_bind_addr(): Bind to 0.0.0.0:0 failed (IOD #4): Invalid argument (22)
SENT (3.2079s) Starting TCP Handshake > rpc.uni.junonetwork.io:443 (135.125.180.36:443)
RCVD (3.4740s) Handshake with rpc.uni.junonetwork.io:443 (135.125.180.36:443) completed
libnsock mksock_bind_addr(): Bind to 0.0.0.0:0 failed (IOD #5): Invalid argument (22)
SENT (4.2078s) Starting TCP Handshake > rpc.uni.junonetwork.io:443 (135.125.180.36:443)
RCVD (4.4617s) Handshake with rpc.uni.junonetwork.io:443 (135.125.180.36:443) completed

Max rtt: 322.059ms | Min rtt: 253.965ms | Avg rtt: 274.761ms
TCP connection attempts: 5 | Successful connections: 5 | Failed: 0 (0.00%)
Nping done: 1 IP address pinged in 4.46 seconds

If the port is not available, the communication fails as follows.

terminal

$ nping rpc.uni.junonetwork.io -p 26657

Starting Nping 0.7.93 ( https://nmap.org/nping ) at 2023-04-17 14:59 JST
libnsock mksock_bind_addr(): Bind to 0.0.0.0:0 failed (IOD #1): Invalid argument (22)
SENT (0.0036s) Starting TCP Handshake > rpc.uni.junonetwork.io:26657 (135.125.180.36:26657)
libnsock mksock_bind_addr(): Bind to 0.0.0.0:0 failed (IOD #2): Invalid argument (22)
SENT (1.0054s) Starting TCP Handshake > rpc.uni.junonetwork.io:26657 (135.125.180.36:26657)
libnsock mksock_bind_addr(): Bind to 0.0.0.0:0 failed (IOD #3): Invalid argument (22)
SENT (2.0065s) Starting TCP Handshake > rpc.uni.junonetwork.io:26657 (135.125.180.36:26657)
libnsock mksock_bind_addr(): Bind to 0.0.0.0:0 failed (IOD #4): Invalid argument (22)
SENT (3.0082s) Starting TCP Handshake > rpc.uni.junonetwork.io:26657 (135.125.180.36:26657)
libnsock mksock_bind_addr(): Bind to 0.0.0.0:0 failed (IOD #5): Invalid argument (22)
SENT (4.0099s) Starting TCP Handshake > rpc.uni.junonetwork.io:26657 (135.125.180.36:26657)

Max rtt: N/A | Min rtt: N/A | Avg rtt: N/A
TCP connection attempts: 5 | Successful connections: 0 | Failed: 5 (100.00%)
Nping done: 1 IP address pinged in 5.01 seconds