March 2019
Beginner
490 pages
12h 40m
English
Suppose you have a CIDR network address such as 12:3456:78:90ab:cd:ef01:23:30/125, and you want to generate a range of all the IP addresses that it represents (12:3456:78:90ab:cd:ef01:23:30 to 12:3456:78:90ab:cd:ef01:23:37). The ipaddress module can be easily used to perform such calculations:
>>> import ipaddress >>> net6 = ipaddress.ip_network('12:3456:78:90ab:cd:ef01:23:30/125') >>> net6 IPv6Network('12:3456:78:90ab:cd:ef01:23:30/125') >>> for ip in net: ... print(ip) 12:3456:78:90ab:cd:ef01:23:30 12:3456:78:90ab:cd:ef01:23:31 12:3456:78:90ab:cd:ef01:23:32 12:3456:78:90ab:cd:ef01:23:33 12:3456:78:90ab:cd:ef01:23:34 12:3456:78:90ab:cd:ef01:23:35 12:3456:78:90ab:cd:ef01:23:36 12:3456:78:90ab:cd:ef01:23:37 ...Read now
Unlock full access