ポート開放をnpingコマンドで確認する
2023-04-18
pingではポート番号を指定できませんが,macOSではnmapをインストールするとポート番号を指定してpingできます.
インストール
Homebrewを用いてインストールします.
terminal
$ brew install nmap
参考:https://qiita.com/Yu-s/items/4b4f683fda374c8ddcc9
エラーが発生した場合
インストール中に以下のエラーが発生することがあります.
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`).
権限が付与されていないことから実行できないというエラーです.
所有者を変更して実行し直すことでコマンドが利用できるようになります.
terminal
$ sudo chown -R <username> /usr/local/share/man/de
$ brew list nmap
参考:brew install nmapで/usr/local/share/man/de/man1 is not writableとなる問題 - Qiita
コマンドの利用方法
ポートとの通信が成功した例は以下の通りです.
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
ポートが利用できない場合は,以下のように通信に失敗します.
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