Store IP Addresses in MongoDB

/ IPAM, Node.js, JS, MongoDB

Store IP Addresses in MongoDB

Programatically store IPv4 and/or IPv6 IP addresses in MongoDB.

Recently, I wanted to write some IP Address Management tools using server side Javascript (nodejs) and be able to store IP Address data into a MongoDB backend database. Simple! I'll just perform IP-to-Decimal conversions like I always do. Problem solved. End of article? Wait! Not so fast...

That won't work since:

  • Javascript's native Number data type only supports 64-bit integers
  • MongoDB doesn't have a data types that would support BigInts - so, I couldn't use one of the many Number-to-BigInt libraries

The solution...

Read More...