python - Create a .txt list of IPs in a subnet -


i'd make simple text (.txt) file. python program needs make list of multiple ranges of ips in subnet, each taking 1 line.

example:

10.10.27.1 10.10.27.5 10.10.27.6 10.10.27.26 10.10.27.27 10.10.27.28 10.10.27.29 10.10.27.51 10.10.27.52 10.10.27.53 10.10.27.54 

the subnet mask /24, providing mask input not necessary. program can default supporting standard class c.

also, i'd support common ranges devices use. prompt say, "printers?" include .26 - .30. "servers?" include .5 - .7. "dhcp?" prompt include .51 - .100 of subnet. "abnormal?" include .100 - .254.

subnet?  10.10.27.1 servers?  y printers?  y dhcp?  y abnormal?  n 

output being:

10.10.27.1 10.10.27.5 10.10.27.6 10.10.27.7 10.10.27.26 10.10.27.27 10.10.27.28 10.10.27.29 10.10.27.30 10.10.27.51 (all way .100) 

what best way code this?

it looks few for loops need:

network = '10.10.27'  host in xrange(100, 255):    print("{network}.{host}".format(**locals())) 

Comments

Popular posts from this blog

c++ - How do I get a multi line tooltip in MFC -

asp.net - In javascript how to find the height and width -

c# - DataTable to EnumerableRowCollection -