Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Does anyone know of a tool or utility that can be used to quickly find out if an IPv6 prefix falls within a certain range?

For instance given the input prefix range of fe80-febf and the input prefix of fe79 it would return true to indicate that the latter argument is within the former.

Or another example might be given the input prefix range of fe80-febf and the input prefix of fe81 it would return false to indicate that the latter argument would be outside the range specified in the former.

share|improve this question

2 Answers 2

up vote 2 down vote accepted

I'd break out the python, personally.

>>> x = 'fe79'
>>> int('fe80', 16) <= int(x, 16) <= int('febf', 16)
False
>>> x = 'fe81'
>>> int('fe80', 16) <= int(x, 16) <= int('febf', 16)
True
share|improve this answer
    
Hmm if there was a way to do this in Javascript I think it would be easiest since most people have that lying around...I'll bet there's a way to do that...looking further into this... –  leeand00 Oct 28 '11 at 16:33
    
I suppose I could just throw it into codepad.org too... –  leeand00 Oct 28 '11 at 16:44
    
Okay here's a url to the codepad.org of your suggestion: bit.ly/uXU53j Thanks! –  leeand00 Oct 28 '11 at 16:52

Fully expanding the address to the 39 character string representation and then using string comparison?

Not the fastest but maybe the easiest

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.