Red Hat Enterprise Linux 9.5でのnpingコマンドの使い方をまとめました。
npingコマンドを使うためにnmapをインストール
以下のいずれかのコマンドでnmapをRHEL9.5にインストールします。
- yum install nmap
- dnf install nmap
yum install nmap
[root@localhost ~]# yum install nmap
サブスクリプション管理リポジトリーを更新しています。
メタデータの期限切れの最終確認: 18:18:31 前の 2025年02月02日 21時31分50秒 に実施しました。
依存関係が解決しました。
===============================================================================================================================================================================================
パッケージ アーキテクチャー バージョン リポジトリー サイズ
===============================================================================================================================================================================================
インストール:
nmap x86_64 3:7.92-3.el9 rhel-9-for-x86_64-appstream-rpms 5.6 M
トランザクションの概要
===============================================================================================================================================================================================
インストール 1 パッケージ
ダウンロードサイズの合計: 5.6 M
インストール後のサイズ: 24 M
これでよろしいですか? [y/N]:

dnf install nmap
[root@localhost ~]# dnf install nmap
サブスクリプション管理リポジトリーを更新しています。
メタデータの期限切れの最終確認: 18:17:09 前の 2025年02月02日 21時31分50秒 に実施しました。
依存関係が解決しました。
===============================================================================================================================================================================================
パッケージ アーキテクチャー バージョン リポジトリー サイズ
===============================================================================================================================================================================================
インストール:
nmap x86_64 3:7.92-3.el9 rhel-9-for-x86_64-appstream-rpms 5.6 M
トランザクションの概要
===============================================================================================================================================================================================
インストール 1 パッケージ
ダウンロードサイズの合計: 5.6 M
インストール後のサイズ: 24 M
これでよろしいですか? [y/N]:

今回はyumコマンドでインストールを実行しました。
[root@localhost ~]# yum install nmap
サブスクリプション管理リポジトリーを更新しています。
メタデータの期限切れの最終確認: 18:18:31 前の 2025年02月02日 21時31分50秒 に実施しました。
依存関係が解決しました。
===============================================================================================================================================================================================
パッケージ アーキテクチャー バージョン リポジトリー サイズ
===============================================================================================================================================================================================
インストール:
nmap x86_64 3:7.92-3.el9 rhel-9-for-x86_64-appstream-rpms 5.6 M
トランザクションの概要
===============================================================================================================================================================================================
インストール 1 パッケージ
ダウンロードサイズの合計: 5.6 M
インストール後のサイズ: 24 M
これでよろしいですか? [y/N]: y
パッケージのダウンロード:
nmap-7.92-3.el9.x86_64.rpm 2.1 MB/s | 5.6 MB 00:02
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
合計 2.1 MB/s | 5.6 MB 00:02
Red Hat Enterprise Linux 9 for x86_64 - AppStream (RPMs) 3.5 MB/s | 3.6 kB 00:00
GPG 鍵 0xFD431D51 をインポート中:
Userid : "Red Hat, Inc. (release key 2) <security@redhat.com>"
Fingerprint: 567E 347A D004 4ADE 55BA 8A5F 199E 2F91 FD43 1D51
From : /etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
これでよろしいですか? [y/N]: y
鍵のインポートに成功しました
GPG 鍵 0x5A6340B3 をインポート中:
Userid : "Red Hat, Inc. (auxiliary key 3) <security@redhat.com>"
Fingerprint: 7E46 2425 8C40 6535 D56D 6F13 5054 E4A4 5A63 40B3
From : /etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
これでよろしいですか? [y/N]: y
鍵のインポートに成功しました
トランザクションを確認しています
トランザクションの確認に成功しました。
トランザクションをテストしています
トランザクションのテストに成功しました。
トランザクションを実行しています
準備中 : 1/1
インストール中 : nmap-3:7.92-3.el9.x86_64 1/1
scriptletの実行中: nmap-3:7.92-3.el9.x86_64 1/1
検証中 : nmap-3:7.92-3.el9.x86_64 1/1
インストール済みの製品が更新されています。
インストール済み:
nmap-3:7.92-3.el9.x86_64
完了しました!
npingコマンドの使い方
npingコマンドの使い方をまとめました。
ポート番号を指定する
以下の例のようにポート番号を指定して通信の疎通確認ができます。
nping IPアドレス --tcp -p ポート番号
–tcpの部分には–udpを指定することも可能です。tcp,udpを指定してポート番号での通信の疎通確認ができます。
tcp,udpの指定をしない場合は以下のエラーが出ます。
[root@localhost ~]# nping 127.0.0.1 -p 22
Starting Nping 0.7.92 ( https://nmap.org/nping ) at 2025-02-03 15:58 JST
You cannot use -p (explicit port selection) in your current scan mode.
(Perhaps you meant to use --tcp or --udp)
以下実行例です。
[root@localhost ~]# nping 127.0.0.1 --udp -p 22
Starting Nping 0.7.92 ( https://nmap.org/nping ) at 2025-02-03 15:57 JST
SENT (0.0160s) UDP 127.0.0.1:53 > 127.0.0.1:22 ttl=64 id=26865 iplen=28
RCVD (0.0174s) ICMP [127.0.0.1 > 127.0.0.1 Port unreachable (type=3/code=3) ] IP [ttl=64 id=33982 iplen=56 ]
SENT (1.0174s) UDP 127.0.0.1:53 > 127.0.0.1:22 ttl=64 id=26865 iplen=28
RCVD (1.0196s) ICMP [127.0.0.1 > 127.0.0.1 Port unreachable (type=3/code=3) ] IP [ttl=64 id=34868 iplen=56 ]
SENT (2.0191s) UDP 127.0.0.1:53 > 127.0.0.1:22 ttl=64 id=26865 iplen=28
RCVD (2.0219s) ICMP [127.0.0.1 > 127.0.0.1 Port unreachable (type=3/code=3) ] IP [ttl=64 id=35479 iplen=56 ]
SENT (3.0239s) UDP 127.0.0.1:53 > 127.0.0.1:22 ttl=64 id=26865 iplen=28
RCVD (3.0262s) ICMP [127.0.0.1 > 127.0.0.1 Port unreachable (type=3/code=3) ] IP [ttl=64 id=35794 iplen=56 ]
SENT (4.0278s) UDP 127.0.0.1:53 > 127.0.0.1:22 ttl=64 id=26865 iplen=28
RCVD (4.0284s) ICMP [127.0.0.1 > 127.0.0.1 Port unreachable (type=3/code=3) ] IP [ttl=64 id=35941 iplen=56 ]
Max rtt: 2.774ms | Min rtt: 0.330ms | Avg rtt: 1.638ms
Raw packets sent: 5 (140B) | Rcvd: 5 (280B) | Lost: 0 (0.00%)
Nping done: 1 IP address pinged in 4.05 seconds