From: Paul Robinson Date: 2006-04-21T02:28:53+09:00 Subject: Re: Converting IP range to array of IP's On 20 Apr 2006, at 18:08, Peter Ertl wrote: > lets say you have a 192.168.0.0/10 subnet: That's CIDR. > 192.168.1.0 (which is a subnet but no host) > 192.168.1.255 (which is the broadcast) That isn't. It's a long time since I last did any proper CIDR subnetting, but if you really are setting things up so flat that you have a /10 then . 1.255 isn't a broadcast address, no? You're mixing up a CIDR subnet mask with the notion of an old Class C there aren't you? Or am I completely wrong on this and my memory is playing tricks? The largest subnet I've dealt with in the last 5 years is a /27... > "all ips between ip1 and ip2 where _each_ of the digits is between the > corresponding digit in ip1 and ip2" > > example: > 192.168.1.3 - 192.168.2.4: > > [192, 168, 1, 3] > [192, 168, 1, 4] > [192, 168, 2, 3] > [192, 168, 2, 4] What you have there is two ranges - .1.3-.1.4 and .2.3-.2.4 so I think if expressed as one range, I'd want to go all the way up - be consistent with how ranges work elsewhere in Ruby: > ('bar'..'bbs').to_a => ["bar", "bas", "bat", "bau", "bav", "baw", "bax", "bay", "baz", "bba", "bbb", "bbc", "bbd", "bbe", "bbf", "bbg", "bbh", "bbi", "bbj", "bbk", "bbl", "bbm", "bbn", "bbo", "bbp", "bbq", "bbr", "bbs"] Incidentally, my distant memory of the subject would suggest going straight from a bar to a BBS often resulted in deep regret the following morning - best to stop when you get to BBC or even better a BBQ... :-) -- Paul Robinson