Shouldn't the IP address "" be a private IP?

Hey everyone,

I have a script that checks whether an IP is public or private. Here are the important bits from crystal i

Crystal interpreter 1.7.2 (2023-01-23).
EXPERIMENTAL SOFTWARE: if you find a bug, please consider opening an issue in
icr:1> require "socket"
 => nil
icr:2> ip_address ="", 0)
 => Socket::IPAddress(
icr:3> ip_address.private?
 => false
icr:4> ip_address.loopback?
 => false
icr:5> ip_address.unspecified?
 => false

My question is - shouldn’t the IP come up as a Private IP ?

If not - what’s the best way to check if this IP is not a public IP ?


1 Like

Looking at the code, it seems we’re currently only handling the ranges defined in RFC1918 and are missing those defined in RFC6890 as Reserved-by-Protocol, specifically:


  • (which is the range your IP is in)


  • ::1/128
  • ::/128
  • ::ffff:0:0/96
  • fe80::/10

Can you file an issue for this?


Hi @Blacksmoke16 , I appreciate the quick response!

Sure thing, I’ll report back once I’ve filed the issue.

Hi @Blacksmoke16, I have filed this an issue here: the IP is not recognized as as a Private IP · Issue #13198 · crystal-lang/crystal · GitHub

Thanks again!