0
$\begingroup$

Is it possible to pull a complete list of all IPv4 addresses and put them into a text file? Since there are 4,294,967,296 IPv4 addresses and each one takes about 4 bytes I would guess the file would be about 17.179869184 GB. Is it possible to download all of these addresses into one .txt file?

$\endgroup$
0
$\begingroup$

with easy if you know a little Python. According to https://gist.githubusercontent.com/pootzko/ac34906e11d9715d9514c75507c24dc0/raw/1c28b679d1ca23da56a930950f21a82dba379cd0/ip_generator.py

def ipRange(start_ip, end_ip):
   start = list(map(int, start_ip.split(".")))
   end = list(map(int, end_ip.split(".")))
   temp = start
   ip_range = []

   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)))    

   return ip_range

output = []   
# sample usage 
ip_range = ipRange("192.168.1.0", "192.171.3.25")
for ip in ip_range:
    output.append(ip)
fo = open("output.txt", "rw+")
line = fo.writelines(output)
fo.close()
$\endgroup$
  • $\begingroup$ How would I actually run that code thought? $\endgroup$ – Cody Rutscher May 26 '19 at 14:59
  • $\begingroup$ Also, would it be possible to do the same thing for phone numbers? Since there are 7919900 possible numbers per area code and about 300 area codes would python be able to output a file that large? $\endgroup$ – Cody Rutscher May 26 '19 at 15:18
  • $\begingroup$ Cody, you have to run this code via IDE or console. And yes, some modification of this code provide to solve another problem. $\endgroup$ – fuwiak May 26 '19 at 15:59
  • $\begingroup$ What IDE would you recommend? $\endgroup$ – Cody Rutscher May 26 '19 at 17:44
  • $\begingroup$ Spyder or Sublime. $\endgroup$ – fuwiak May 26 '19 at 20:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.