Suppose we have a Class C Subnet (255.255.255.0), why do we get to have 254 hosts on it even though we have 256 unique internal IPv4 addresses from 192.168.1.0 to 192.168.1.255? Even if we scale up the number of subnets using the mask 255.255.255.254, why can't we have any devices on the subnet even though there is 192.168.1.0 and 192.168.1.1 available?

up vote 3 down vote accepted

First, classful routing is dead, and it has been for over 20 years, killed by VLSM and CIDR (see RFCs 1518 and 1519).

For IPv4 you cannot use the network or broadcast addresses as host address assignments. In your example, 192.168.1.0 is the network address, and 192.168.1.255 is the broadcast address. Those addresses have special meaning to IPv4, and assigning them to hosts causes problems.

There are a couple of exceptions to this:

  • Using a /32 (255.255.255.255) address only gives you one possible address. This is often used for loopback addresses, and the address must be routed.
  • Using a /31 (255.255.255.254) network has only two possible addresses, both of which can be used for host addresses. used for a point-to-point link. Meaning you can use both 192.168.1.0 and 192.168.1.1 (the only two available addresses) as host addresses. This is per RFC 3021 Using 31-Bit Prefixes on IPv4 Point-to-Point Links.

So, Your example of increasing the number of networks using /31 (255.255.255.254) networks will work for point-to-point links.

This only applies to IPv4, since IPv6 can use all the addresses in a subnet, even the first and last addresses.

First ip address of any subnet (for example 102.168.0.0) is network address. It is reserved for that purpose.

The last one is reserved for broadcast address. (192.168.1.255)

The second address (192.168.1.1) , well, it is best for default gateway. Why? You have to set default gateway on each device maybe; which one are you gonna remember the best? 192.168.1.1 or 1.149 for example? So the first and the last are reserved. The first is gateway...

  • 1
    The first address is the network address (192.168.1.0). Any valid host address can be used as a gateway address, since a gateway is just a host. It may be a good practice for the gateway to always use the first host address (second network address, 192.168.1.1), but that address is not reserved for anything. – Ron Maupin May 16 '16 at 22:02
  • I was counting like this: First address ---> .0 Second ----> .1 – Capt May 16 '16 at 22:14
  • 1
    Some places will use the last available IP address as the default gateway, so in this example, 192.168.1.254. Or they may use something else entirely, say they are using something like HSRP and their first router is 192.168.1..1, their second is 192.168.1..2 and the HSRP/default gateway address is 192.168.1..3. As long as an organization uses what makes sense to them and is consistent it really doesn't matter which address is used as the default gateway. – YLearn May 16 '16 at 22:22
  • Yes, but my point is that these are all something the admin agrees upon. It's just the way it is. – Capt May 16 '16 at 22:51
  • What I was getting at is that the mention of the gateway address in an answer to this question is a non sequitur. It really serves more to confuse the issue. – Ron Maupin May 16 '16 at 22:53

Simple formula....find your number of hosts then subtract 2...first address in the subnet=network ID, last IP is the broadcast address used for communication out of the network to other networks.

These two IPs are not valid for assignment to devices on the subnet.

Your Answer

 
discard

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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