Skip to main content

A Python script that pings all potential IPv4 addresses in a subnet and reports response times.

Project description

PingSubnet

https://readthedocs.org/projects/pingsubnet/badge/

A Python script that will detect network adapters and ping every potential IPv4 address in the subnet.

If more than one network adapter is present, it will attempt to determine if any are invalid (possessing a loopback or self-assigned address) and present the user with a list of adapters to choose from.

The output is printed to the screen in tab-separated format (TSV) with a header row. This makes it easy to import into a spreadsheet or database.

Here is a (partially sanitized) example run:

Starting PingSubnet at 2024-12-31 23:59:59

Network Interfaces Detected:
  0 - Ethernet - 192.168.42.200
  1 - Ethernet 2 - 192.168.56.1
Enter the number to the left of your selection (or 'x' to exit): 0

Detected properties:
  Windows operating system
  interface name: Ethernet
  local hostname: NunYa
  local IP address: 192.168.42.200
  local network mask: 255.255.255.0
  local MAC address: 00:01:02:AA:BB:C8

Pinging addresses from 192.168.42.0 to 192.168.42.255

Threading 254 pings, pinging each host 3 times, and using a timeout of 5000 milliseconds...
Starting all threads...
Waiting for all threads to finish...

All online host IP and MAC addresses:
IP  MAC     Hostname        Ping    ping unit
192.168.42.1        00:01:02:AA:BB:01               1.6     ms
192.168.42.2        00:01:02:AA:BB:02               5.5     ms
192.168.42.3        00:01:02:AA:BB:03       homeassistant   1.6     ms
192.168.42.4        00:01:02:AA:BB:04       pi.hole 1.1     ms
(truncated for brevity)
192.168.42.200      00:01:02:AA:BB:C8       NunYa   12.5    ms

44 out of 254 hosts responded to a ping within 5.0 seconds.
Scanning took 12.22 seconds.

Goodbye from PingSubnet

In that example you will see the first two devices did not return a hostname. I still haven’t figured out why the socket library can sometimes detect the hostname and sometimes cannot. If anyone knows, tell me, so I can update this code (or update my DHCP server) to better handle hostnames.

Documentation

For detailed information on how to install and use this tool, please refer to the official documentation.

https://www.codefactor.io/repository/github/adamjhowell/pingsubnet/badge

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pingsubnet-0.1.0.tar.gz (9.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pingsubnet-0.1.0-py3-none-any.whl (9.0 kB view details)

Uploaded Python 3

File details

Details for the file pingsubnet-0.1.0.tar.gz.

File metadata

  • Download URL: pingsubnet-0.1.0.tar.gz
  • Upload date:
  • Size: 9.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.13

File hashes

Hashes for pingsubnet-0.1.0.tar.gz
Algorithm Hash digest
SHA256 9afc999c63e223bbe0a932995df58e700994f37b91908fba0fd4e51109223eae
MD5 6399d76220992b91d20d7a75b6114dd2
BLAKE2b-256 53d41ae5c7382a3067429959a4c2237fd2619b84f8de844b09c4f436ab200a52

See more details on using hashes here.

File details

Details for the file pingsubnet-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: pingsubnet-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 9.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.13

File hashes

Hashes for pingsubnet-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4d7fa528951913798229f1832ec357dc0ff9ce933e7247ee416fc9e82dba1468
MD5 928cb192351931c11b5cf45910bc2a41
BLAKE2b-256 b921f77a72d0ae5605d59baa8bcf90505a20543816fd0c6dee412eb28376dd1b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page