Get all IP addresses from a given IP address and subnet mask

Shraddha Agrawa
Tera Contributor

Hi Team,

 

We have a requirement to run a loop and scan  all the IPs which are present in a subnet .

A subnet can have a number of IPs associated to it.

We need to have a javascript code to scan all the IPs within a subnet.

Thanks

2 REPLIES 2

Jan Cernocky
Tera Guru

Hi Shraddha,

If i understand well you need to figure out what the IP addresses are, right?

E.g. for 

34.103.160.30/28 

you want to calculate usable Host IP range?

find_real_file.png

From top of my head I can think of two options

a. Use some existing API to get the data, by quick google search this might be useful https://subnet.im/api.html

b. Convert the IP and mask to binary and and do a calculation per octet to figure out the ranges (you may need a bit of networking experience or knowledge how the subnets are being calculated)

Appli
Mega Sage
Mega Sage

Hi, what exactly scan are you going to perform with each IP from the range? Just trying to understand your use case better.

Hope it helps

Hope it helps