IPv6 subnet generator using python

 Python Code ( ipv6-subnet-generator.py ) :

import ipaddress

import csv


# Configuration

network = "2407:e80:f:b::/64"

output_file = "ipv6_subnets.csv"

limit = 65536  # Excel's max is ~1.04M. We'll do 1M.


print(f"Generating first {limit} subnets...")


net = ipaddress.ip_network(network)

subnets = net.subnets(new_prefix=126)


with open(output_file, 'w', newline='') as f:

    writer = csv.writer(f)

    writer.writerow(["Subnet Number", "Network Address"])

    

    for i, subnet in enumerate(subnets):

        if i >= limit:

            break

        writer.writerow([i + 1, str(subnet)])


print(f"Done! File saved as {output_file}")

IPv6 subnet generator using python IPv6 subnet generator using python Reviewed by RIO IT on 18:49 Rating: 5
Powered by Blogger.