0

This question already has an answer here:

I want to say 192.168.0.0/16 contains more IP addresses, 86 more to be precise? I've simply subtracted 168 from 254.

Can anyone clarify how you can determine which has more IP addresses?

Thanks

marked as duplicate by Ron Maupin Mar 17 at 21:18

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • an important distinction is that the first one is part of the "private adresses" (ie, the ones to use on your LAN) and the 2nd is a range of PUBLIC adress (ie, used on the Internet, and thus shouldn't be used on your lan, unless you are sure to never adress one of those , or know how to handle deciding which of the Internet/yourlan is concerned in ALL cases!)(IOW, (almost)NEVER use non-private adresses ^^) See: en.wikipedia.org/wiki/IP_address#Private_addresses . For your Q, read en.wikipedia.org/wiki/IP_address#Subnetting (/16 indicates the "Size of network number bit field") – Olivier Dulac Mar 31 '16 at 16:54
  • @OlivierDulac 169.254.0.0/16 isn't public, it's link-local 'autoconfig' tools.ietf.org/html/rfc3927 . – dave_thompson_085 Mar 31 '16 at 20:47
  • @dave_thompson_085: thanks, I forgot about those ones... But still, it is not the same as the 193.168.x range at all. Link-local ips come with great limitations, and are very different from a private address (such as, for ex, one in the 192.168.* range) (the rfc cite them, but the ttl=1 is the main one: paquets in this tange are local, and can't go through a router, so shouldn't reach another lan, etc.) – Olivier Dulac Mar 31 '16 at 20:54
12

These IP blocks contain exactly the same number of IP addresses.

An IP is made of 4 bytes, separated by dots.

Each byte can take (theorically) the value from 0 to 255, meaning 256 different values, but I will be more precise just after.

/16 in CIDR notation means that the first 16 bits (or first two bytes) never change.

In other words :

  • 192.168.0.0/16 means all the IPs starting from 192.168.0.0 to 192.168.255.255 (notice 192.168 has not moved)
  • 169.254.0.0/16 means all the IPs starting from 169.254.0.0 to 169.254.255.255 (notice 169.254 has not moved)

BUT: by convention, you cannot take the very first and the very last address of the subnet. The first is called "network address", and the last is called "broadcast address" (it means packets sent to this last address are actually sent to all hosts in the subnet).

According to this convention, each /16 block contains 256 x 256 (the last two bytes) = 65536 IP, minus the first and the last address I mentioned just above, so :

65534 IPs.

  • 1
    Good answer, but one part of your wording might be a bit confusing. Just to make it clear: The /16 means that the first 16 bits don't change. Because IPv4 addresses are 32 bits long that leaves 16 bits that can change. With a /24 you would have 8 changeable bits, etc. – Sander Steffann Mar 31 '16 at 11:03
  • 1
    Thanks Sander, you are completely right. Thank you for this precision, I edited the post. – Sébastien VALSEMEY Mar 31 '16 at 11:50
  • Note that the block actually contains all 65536 addresses. You can't use the first and last address on a network (and even then, not all of them). The /16 block may be used as a single network (unlikely), or will most probably be split in a number of smaller networks, each with its own eventual network/broadcast addresses. It might also be used as an IP address pool, in which case you may perfectly use all of them (provided the right conditions are met). – jcaron Mar 31 '16 at 15:12
  • (updating comment following @dave_thompson_085 correction) : an important distinction is that the first one is part of the "private adresses" (ie, the ones to use on your LAN) and the 2nd is a link-local range (which is a very peculiar kind, coming with many restrictions on what the paquets can do, limiting them to the lan only). I d recommend using the 192.168.x range (or probably a subnet of it) See: en.wikipedia.org/wiki/IP_address#Private_addresses – Olivier Dulac Mar 31 '16 at 20:57
  • Technically an IPv4 address consists of 4 octets - not 4 bytes. – fpmurphy Apr 1 '16 at 7:04

Not the answer you're looking for? Browse other questions tagged or ask your own question.