October 7th, 2004, 10:59 AM
Increment IP an adress?
how can i increment an ip adress in a speacial range? when start ip and stop ip is given ?
with best regards
October 7th, 2004, 12:49 PM
Something like this perhaps?
base_ip = "192.168.1"
start_oct = raw_input("Enter your start IP octet: ")
end_oct = raw_input("Enter your end IP octet: ")
for octet in xrange(int(start_oct), int(end_oct) + 1):
ip = base_ip + "." + str(octet)
Up the Irons
What Would Jimi Do? Smash amps. Burn guitar. Take the groupies home.
"Death Before Dishonour, my Friends!!" - Bruce D ickinson, Iron Maiden Aug 20, 2005 @ OzzFest
Down with Sharon Osbourne
"I wouldn't hire a butcher to fix my car. I also wouldn't hire a marketing firm to build my website." - Nilpo
October 8th, 2004, 06:36 AM
Yet another way to do this ,
def incrementAddress(address, to = 249, by = 1):
position = address.rindex('.') + 1
for each in xrange(1, to + 1, by):
yield address[:position] + str(each)
if __name__ == '__main__':
for IP in incrementAddress('126.96.36.199', 5):