-1

I am creating that supposed to ping cloud instances and collect packets data, so to avoid ping and having to open ICMP we decided to use NMAP, but the challenge is that with NMAP I am not sure which option can show packet stats.

I tried $nmap -sn hostname but it yields nothing about packets.

  • Hey there, this site is mainly about programming, are you sure that your question fits? You should probably use https://serverfault.com/. – Rohlik Jan 31 '23 at 06:27

1 Answers1

0

the nmap -sn hostname command should have the information but it uses ICMP afaik. You can try to make it more verbose with some of those options:

nmap -sn -v3 hostname (This is a morre verbose version of the command, you can use v1 or v2 to less verbose responses)

Starting Nmap 7.93 ( https://nmap.org ) at 2023-02-01 01:44 -03
Initiating Ping Scan at 01:44
Scanning hostname [2 ports]
Completed Ping Scan at 01:44, 0.01s elapsed (1 total hosts)
Initiating Parallel DNS resolution of 1 host. at 01:44
Completed Parallel DNS resolution of 1 host. at 01:44, 0.02s elapsed
DNS resolution of 1 IPs took 0.02s. Mode: Async [#: 2, OK: 0, NX: 1, DR: 0, SF: 0, TR: 1, CN: 0]
Nmap scan report for hostname
Host is up, received syn-ack (0.0050s latency).
Nmap done: 1 IP address (1 host up) scanned in 0.03 seconds

nmap -sn -d1 hostname (This one will return a debug. You can control the verbosity increasing the number until -d6)

Starting Nmap 7.93 ( https://nmap.org ) at 2023-02-01 01:37 -03
--------------- Timing report ---------------
  hostgroups: min 1, max 100000
  rtt-timeouts: init 1000, min 100, max 10000
  max-scan-delay: TCP 1000, UDP 1000, SCTP 1000
  parallelism: min 0, max 0
  max-retries: 10, host-timeout: 0
  min-rate: 0, max-rate: 0
---------------------------------------------
Initiating Ping Scan at 01:37
Scanning hostname [2 ports]
Completed Ping Scan at 01:37, 0.00s elapsed (1 total hosts)
Overall sending rates: 468.60 packets / s.
mass_rdns: Using DNS server 8.8.8.8
mass_rdns: Using DNS server 8.8.4.4
Initiating Parallel DNS resolution of 1 host. at 01:37
mass_rdns: 0.02s 0/1 [#: 2, OK: 0, NX: 0, DR: 0, SF: 0, TR: 1]
Completed Parallel DNS resolution of 1 host. at 01:37, 0.02s elapsed
DNS resolution of 1 IPs took 0.02s. Mode: Async [#: 2, OK: 0, NX: 1, DR: 0, SF: 0, TR: 1, CN: 0]
Nmap scan report for hostname
Host is up, received syn-ack (0.0042s latency).
Final times for host: srtt: 4231 rttvar: 5000  to: 100000
No data files read.
Nmap done: 1 IP address (1 host up) scanned in 0.03 seconds

You can try hping3 for a more "ping like" experience:

hping3 -c 4 -V -p 80 -s 5050 -A hostname

using eth0, addr: xxx.xxx.xxx.xxx, MTU: 1500
HPING hostname (eth0 hostname): A set, 40 headers + 0 data bytes
len=40 ip=hostname ttl=63 DF id=0 tos=0 iplen=40
sport=80 flags=R seq=0 win=0 rtt=10.0 ms
seq=1577349516 ack=0 sum=feab urp=0

len=40 ip=hostname ttl=63 DF id=0 tos=0 iplen=40
sport=80 flags=R seq=1 win=0 rtt=19.8 ms
seq=1795140273 ack=0 sum=dd65 urp=0

len=40 ip=hostname ttl=63 DF id=0 tos=0 iplen=40
sport=80 flags=R seq=2 win=0 rtt=9.8 ms
seq=560041255 ack=0 sum=4cd urp=0

len=40 ip=hostname ttl=63 DF id=0 tos=0 iplen=40
sport=80 flags=R seq=3 win=0 rtt=9.6 ms
seq=1637236775 ack=0 sum=ced9 urp=0


--- hostname hping statistic ---
4 packets transmitted, 4 packets received, 0% packet loss
round-trip min/avg/max = 9.6/12.3/19.8 ms
LuisesK
  • 41
  • 3
  • Is there a way we can show packet stats like with ping as Ping statistics for 8.8.8.8: Packets: Sent = 4, Received = 4, Lost = 0 (0% loss), – Prince Linuxer Feb 01 '23 at 10:17
  • @PrinceLinuxer, I've updated the answer to include the hping3 tool, this is more like what you need. Hope it works! – LuisesK Feb 01 '23 at 21:22