I am trying to fetch the ips from the ranges (172.16.3.20 to 192.168.1.1) using the following code but it is taking lot of time and cpu and sometimes it doesnt work at all. Is there any better way of finding it? Output required is as follows:
172.16.3.21
172.16.3.22
...
...
192.167.255.255
192.168.1.1
Code:
start = list(map(int, start_ip.split(".")))
end = list(map(int, end_ip.split(".")))
ip_range = []
temp = start
ip_range.append(start_ip)
while temp != end:
start[3] += 1
for i in (3, 2, 1):
if temp[i] == 256:
temp[i] = 0
temp[i-1] += 1
ip_range.append(".".join(map(str, temp)))