Is there a way to identify a Shared Address Space IP address ? (100.64.0.0/10)

Hey everyone,
This is kinda similar to my previous post about link local IPs: Shouldn't the IP address "169.254.169.254" be a private IP?

This is the problem - tested with Crystal 1.8.2:

icr:1> require "socket"
 => nil
icr:2> ip_address = Socket::IPAddress.new("100.66.18.237", 1)
 => Socket::IPAddress(100.66.18.237:1)
icr:3> ip_address.private?
 => false
icr:4> ip_address.loopback?
 => false

Currently, unless I’m mistaken, there’s no way for Crystal to classify an IP address in the 100.64.0.0/10 range. Those IPs are not private IPs or loopback IPs or public IPs.

Would it make sense to add a .shared_address_space? function or something similar so that those IPs can be correctly classified ?

The relevant RFC seems to be: RFC 6598: IANA-Reserved IPv4 Prefix for Shared Address Space
Here’s the discussion about the same issue in Python: ipaddress should make it easy to identify rfc6598 addresses · Issue #61602 · python/cpython · GitHub

Thanks!

I am starting to think we should have something like ip_address.in_range?("100.64.0.0/10") in the standard library on top of those predefined classification methods. This is easier than before now that Socket::IPAddress.parse_v*_fields? exist

1 Like

that would definitely work for me! Just to clarify: this isn’t possible at the moment right?