简体   繁体   中英

Iterate over the IPv4 address space or CIDR in a random order

I've been searching for this for a while, i didn't even found this question been asked before. So, i'm looking for a method to iterate over the IPv4 address space or CIDR in a nice random order without worrying of duplication. I've seen this implemented in Zmap

you could start use something like:

import random
r = random.randrange
ip = "{}.{}.{}.{}".format(r(0,255),r(0,255),r(0,255),r(0,255))

however you should still check if the IP is valid. ie filter 0.0.0.0 and so on

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM