DEV Community

Mohana Vamsi
Mohana Vamsi

Posted on

Basic Network Scanner

This script written with Python scans the local network for identifying active devices. Useful for network monitoring to check the unapproved device on your network.

Code Example:

import os

def scan_network(network):

print("Scanning network : " + network)

response = os.popen("ping -c 1 " + network).read()

if response.find('1 packets transmitted, 1 received') >= 0:

print("The network is online-" + network)

else:

print("The network is offline-" + network)

for i in range(1, 255):

scan_network("192.168.1." + str(i));

Use Case: This can be used further in the audit of networks to identify unauthorized devices that may have connected to your system.

Tip: You can modify the script to scan your entire subnet and produce an inventory of devices connected to your network.

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay