3

TL;DR

Given 8.8.8.8, what do I call its 8.8.8.0 or 8.8.8.1?

Why do I need this information?

I'm working on a program that resolves the location of IP addresses. To reduce the number of API requests it makes, I replace the last octet of each IP address with 0 and cache the results, presuming that whole subnet belongs to the same location anyway.

What do I need to know?

I need to name the database column for that value, and I'd like to do that properly. What word should I choose for a column name?

Also, is there something I need to know about 8.8.8.0 vs 8.8.8.1? Should I prefer one over another?

I found this question but there doesn't seem to be an answer to my question on that page.

Thank you!

2 Answers2

6

The first IP address in a prefix is usually called the network address. In most setups, the first assignable address is the gateway, though any IP address within a prefix could be configured as gateway. So assuming 8.8.8.8 is in a /24 network, 8.8.8.0 would be the network address and 8.8.8.1 the gateway.

Also, is there something I need to know about 8.8.8.0 vs 8.8.8.1? Should I prefer one over another?

That's hard for us to tell, we don't know your application, but if you're looking at /24's, I'd take 8.8.8.0.

Teun Vink
  • 17,433
  • 6
  • 46
  • 70
2

You're making the assumption that all networks are /24s (equivalent of a pre-CIDR "Class C", with a subnet mask of 255.255.255.0), which is definitely not the general case. There are lots of much smaller and much larger blocks.

You should try to find out the CIDR network the IP is part of, and make a note of that network. A CIDR network is defined by its starting address and prefix-length.

The starting address can be called:

  • the start address
  • the network address
  • the prefix

Depending on what exactly you are trying to achieve, different levels of granularity may be needed. It may be enough for you to know that a given block is allocated to a single ISP and has a single "route" in BGP. Or you may want to know the specific company the network is assigned to.

jcaron
  • 1,003
  • 5
  • 10