Monday, 26 December 2022

Batch programming to scan for online IPs

Introduction:

Batch programming is a powerful tool for automating tasks and performing actions on multiple files or devices at once. In this article, we will go over how to use batch programming to scan for online IPs on a network.

What is an IP address?

An IP (Internet Protocol) address is a numerical label assigned to each device connected to a computer network that uses the Internet Protocol for communication. It serves as an identifier for the device and allows it to communicate with other devices on the network.

There are two types of IP addresses: public and private. Public IP addresses are assigned by Internet Service Providers (ISPs) and are unique to each device. Private IP addresses, on the other hand, are used within a private network and are not visible to the Internet.

Scanning for online IPs:

To scan for online IPs on a network, we can use the "ping" command in batch programming. The "ping" command sends a request to a device to see if it is online and responds with a message if it is.

Here is an example of a batch script that scans for online IPs on a network:


@echo off

:start
echo Scanning for online IPs...

for /l %%i in (1,1,254) do (
  ping -n 1 192.168.1.%%i | find "TTL=" >nul
  if not errorlevel 1 echo 192.168.1.%%i is online
)

echo Scan complete.

pause
goto start


In this script, the "for" loop iterates through all IP addresses from 1 to 254 on the network (192.168.1.1 to 192.168.1.254). The "ping" command is used to send a request to each IP address, and the "find" command is used to check if a response was received. If a response was received, it means the device is online and the IP address is displayed.

This script will continuously scan for online IPs and display them on the screen until it is stopped.

Conclusion:

Batch programming is a useful tool for automating tasks and performing actions on multiple devices at once. In this article, we learned how to use the "ping" command in batch programming to scan for online IPs on a network. By running this script, you can easily see which devices are online and their corresponding IP addresses.

No comments:

Post a Comment