2

Currently I am in need of being able to tell the difference between a private address and a web reachable one.

I need to be able to test for the following:

You are given a list of ipv6 on an interface and need to know which addresses are web reachable. It is possible for none of these addresses to be non private. If the address is changed, it would be best to be able to track which one (I can figure that out after I have a private address test method).

This is written in javascript on node.js

1
  • "after I have a private address test method)." Actually, IPv6 does not have private addresses the way IPv4 does. IPv6 used to have site-local addresses, but they were deprecated in favor of ULA. IPv4 private addresses can be reused in many different networks, but IPv6 ULA addresses must have a high probability of being unique. The IPv6 global address pool is 2000::/3, although there are a few blocks in that range that are not globally reachable. See iana.org/assignments/iana-ipv6-special-registry/… Commented Oct 23, 2019 at 15:28

2 Answers 2

3

What you're looking for is the IPv6 scope: "web reachable" are addresses in the global scope. The scopes are described here:

http://en.wikipedia.org/wiki/IPv6_address#IPv6_address_scopes

You could parse the address yourself -- OR you could save yourself some time and use the ipv6 module (npm install ipv6 --save):

var v6 = require('ipv6').v6;

var addr = new v6.Address('2001:db8:85a3:8d3:1319:8a2e:370:7348');

if(addr.getScope()==='Global'){
    console.log('valid global ipv6 address');
}

Disclaimer: I don't really know that much about IPv6...but I'm figuring it out. I found this discussion of the different scopes useful, by the way:

Link-local and global IPs on IPv6 interfaces

Sign up to request clarification or add additional context in comments.

Comments

0

I'm working with the following assumptions:

  • you're using appropriate standards to define private vs. web-reachable
  • for our purposes web-reachable means not private
  • in particular, we're only interested in the format of the address, not whether a device will actually respond at that address

... with those assumptions, it should be fairly easy. According to this page (which links here), you just have to test that the address starts with fd1, perhaps with the regular expression /^fd1/, to confirm that it is a private address.

Likewise, according to this page, you can test for 0:0:0:0:0:0:0:1 or ::1 for the loopback address.

2 Comments

By your test fe80 addresses are global.
Ethan's answer is way better than mine, I can't admit to knowing that much about ipv6 addresses, just what my research showed, which is what I linked to, though I realize now that I think I misunderstood my first link, as it appears to randomly generate a compliant address rather than provide more general info.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.