-1

Number of IP-addresses in practice when paired with subnet masks: Should IP-addresses paired with different subnet masks be seen as distinct?

I know an IP-address is represented as 4 octets, i.e. using 32-bits. The total is 2^32 different IP-addresses.

But these IP-addresses are paired with a subnet mask. Does this mean that 192.168.0.1/24 and 192.168.0.1/16 are two different IP-addresses in practice? If so, why not introduce some more "layers" (more masks) that extend the 32-bit addressing scheme even further?

How many IP-addresses are there?

manjesh23
  • 369
  • 1
  • 4
  • 21
Shuzheng
  • 11,288
  • 20
  • 88
  • 186
  • Regarding your first question, for 192.168.0.1 we cannot use /24 because this is not a network this is a IP address, so we should use /32. Considering 192.168.0.0/24 and 192.168.0.0/16 these are over lapping subnets. As an example if you assign 192.168.100.100 mask 255.255.0.0 to machine A and 192.168.0.100 mask 255.255.255.0 to machine B with direct patch cable, machine A can talk to machine B but not machine B to machine A. Because machine B is on 192.168.0.0/24 subnet and if it wants to talk to 192.168.100.0/16 it needs a gateway IP which should be in 192.168.0.0/24 subnet. – manjesh23 Jan 08 '16 at 15:18
  • we have a 128 bit addressing scheme called IPv6 which is 2^128. – manjesh23 Jan 08 '16 at 15:33

1 Answers1

2

Should IP-addresses paired with different subnet masks be seen as distinct?

No. A subnet mask is not a qualifier or namespace for IP addresses. Netmasks have no part in associating IP addresses with machines. Rather, they are associated with the physical and logical topology of the (IPv4) network, and they are needed for hosts to participate in the network appropriately. Using a different netmask does not change the meaning of IP addresses, so netmasks do not provide a mechanism for expanding the address space.

Does this mean that 192.168.0.1/24 and 192.168.0.1/16 are two different IP-addresses in practice?

No. In fact, those are not IP addresses at all -- they are (address, netmask) pairs, both with the same address part. On any given network, they refer to the same machine (if they refer to any machine at all). The IP address involved is in one of the non-routable ranges, however. These are usually used for internal networks, typically behind a router that performs network address translation (NAT) so that multiple machines can access the network without having globally-unique addresses. That has nothing to do with netmasks, however.

How many IP-addresses are there?

There are exactly 232 (a bit less than 5 billion) distinct IPv4 addresses. Not all of them are usable as host addresses. Use of private networks with NAT-ed access to the Internet expands the total number of machines that can be connected, but that does not change the number of distinct addresses, and it anyway is not related to netmasks.

John Bollinger
  • 160,171
  • 8
  • 81
  • 157
  • This should be a comment, not an answer. – manjesh23 Jan 08 '16 at 15:20
  • 1
    @manjesh23, I beg to differ. The main question, as presented in the title and the quote/highlight, is "Should IP-addresses paired with different subnet masks be seen as distinct?" As originally posted, this answer responded directly to that question. Nevertheless, I have expanded it with direct answers to two of the ancillary questions. – John Bollinger Jan 08 '16 at 15:29
  • Excellenct answer! However, why do we use subnet masks then? I understand that they "partition" the network into subnets, but why is this important? Why can't the router not just route based on the IP-address itself? – Shuzheng Jan 08 '16 at 15:45
  • John Bollinger, could you also recommend a good book source for this topic? – Shuzheng Jan 08 '16 at 15:49
  • @NicolasLykkeIversen, for efficient network operation, machines need to know whether they can communicate directly with the target machine, or whether they need to route through a gateway (and if so, which one). Machines use netmasks for these determinations and related ones. There are also uses not directly related to routing. – John Bollinger Jan 08 '16 at 16:10
  • 1
    @NicolasLykkeIversen, requests for reference books and tutorials are off-topic for Stack Overflow. Although I haven't a specific reference to recommend, googling "ip networking" turns up several promising-looking resources among the top hits. – John Bollinger Jan 08 '16 at 16:13