Sorry if I'm using the wrong terminology. What I'm trying to ask is if it is safe to assume that IP addresses are from the same network if they differ only in the last octet?

  • 1
    Separating IP addresses into dotted-decimal octets is purely for ease of reading. Many people are lazy and break networks on octet boundaries, but the octets really have nothing to do with where the network boundaries really are. You must look at the mask or mask length to determine that.
    – Ron Maupin
    Jan 24, 2017 at 18:33
  • 1
    What does "from the same network" mean to you? What is it precisely that you are asking us to tell you if it's safe to assume? Jan 24, 2017 at 19:09
  • There is no safe way to assume anything from groupings of IP addresses. The internet is classless and with ipv4 depletion, address spaces have been carved up and delegated many times. Even geo-ip databases are never entirely accurate from the moment they are published. One can only make assumptions using authentication.
    – Aaron
    Jan 24, 2017 at 19:32

2 Answers 2


TLDR: You can't safely make that assumption. Use a subnetting tool like http://subnetmask.info to quickly check it out

A "network" is a combination of the IP address and the subnet mask. The subnet mask defines the "size" of the network. A rather commonly found network/mask size is 24-bits (, in which case your thought would be correct and the first 3 octets determine the network while the last octet is the host.

I, on the other hand, frequently use different sized networks at my employment: One of my DMZ nets is 22-bit ( in this case any of the 1022 address from are all in the same network (note that the 3rd octet changes).

Another network for site-to-site VPN end points runs in a 28-bit ( network; only the 14 address from are in the same network. But (same 3rd octet, in fact, only 2 numbers away) is not in that network.


Most of the time and it depends.

"Same network" is a term you have to define.

Look into subnetting and how a subnet can be in different ranges.


You could f.ex easily have two VLANS (two different "networks") that are mapped to two /26 ranges in the same /24 subnet, which would immediately invalidate you hyphothesis.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .