37

I have network with a range 10.0.0.0/24. This means I have 10.0.0.0 to 10.0.0.255, however I cannot use 10.0.0.0 or 10.0.0.255, but I can use anything between that.

Why is this? The mask 255.255.255.0 implies that the last digit is the host address, so why can't I use 0 or 255?

  • 7
    Note that this is IPv4-only. IPv6 has different rules regarding the first and last address in a subnet. – Michael Hampton Aug 9 '16 at 21:07
  • 1
    On linux, you'll have no problem using the first address. Some old systems think that .0 is a broadcast address and prevent you from using it, but that is wrong :) – Navin Aug 11 '16 at 0:34
71

In a /24 network you can't use 0 because it is the identification of the network (devices use it to recognize the different networks they are connected to).

In a Windows PC open a Command Prompt and type netstat -r. You will get the routing table used by the PC, each network is listed using the network identification (first address).

enter image description here

The last address, 255 in the case of a /24 network, is the broadcast address. Devices connected to the network use it to send a broadcast, a message intended for all devices on the network.

In general the first address is the network identification and the last one is the broadcast, they cannot be used as regular addresses.

  • 9
    For /31 there is a special exception, though: these are assumed to be point-to-point links implicitly because they only have two addresses. – Simon Richter Aug 9 '16 at 15:15
  • 10
    Posting your public IP address and username for said system gives me the heebie-jeebies. – mikeazo Aug 9 '16 at 16:08
  • 8
    @mikeazo Why? You have decent passwords and fail2ban, right? Besides, every IPv4 address on the Internet gets attacked. – Michael Hampton Aug 9 '16 at 21:05
  • 4
    @MichaelHampton because now the internet knows his username, his IP address and that he's not (succesfully) using SSH keys, but passwords instead. That already refines the search space. But you're right: for a professional, this shouldn't be a problem. It's not a good practice to teach the world though. – Konerak Aug 10 '16 at 5:48
  • 29
    @mikeazo It's a screenshot I found googling netstat -r. It's not my system. – jcbermu Aug 10 '16 at 7:47
8

Note that you can not use the first and last address in the range if it is used to number devices in a broadcast domain (i.e. a physical network or a vlan etc.). As the other answer indicates indeed the first and last are used as network and broadcast address respectively in that scenario. In addition in some scenarios the first address is also interpreted as broadcast.

However there are other usage scenarios where you can use the first and last address. E.g. if you are a firewall admin and you are given the 10.0.0.0-10.0.0.255 range by your network admin, then you can use all 256 addresses as NAT addresses on your firewall. I admit that I have not seen this done very often, and when it's done it may cause some confusion - as most people's first reaction is to think it is not allowed - and this confusion may well be a reason to advise against it.

If you're nitpicking then ok, strictly speaking the 10.0.0.0-10.0.0.255 in that scenario is not a /24 network, it's a range or a block of addresses but I believe that it is common practice to still refer to this as "the 10.0.0.0/24 subnet" in such a scenario.

  • 7
    "I admit that I have not seen this done very often, and when it's done it may cause some confusion - as most people's first reaction is to think it is not allowed - and this confusion may well be a reason to advise against it." – If I remember correctly, some of those "confused people" are the designers of the Windows NT networking stack (at least the original one upto Vista), so, unless you are willing to deal with Windows users complaining that their computer works in every network except yours and explain to them that that's Microsoft's fault, not yours, you'd be well advised to simply … – Jörg W Mittag Aug 9 '16 at 11:34
  • 9
    leave those two addresses unused. – Jörg W Mittag Aug 9 '16 at 11:35
  • 1
    @JörgWMittag, wait, are you saying that given the network 10.0.0.0/22 (i.e. 10.0.0.0-10.0.3.255), pre-7 Windows is unable to use 10.0.1.0 or 10.0.2.255? (Though I don't suppose it matters much any more, since versions that old aren't supported any longer) – ilkkachu Aug 9 '16 at 12:45
  • 2
    @ilkkachu: I'm not sure how you came up with those numbers. The network address for 10.0.0.0/22 is 10.0.0.0 and the broadcast address is 10.0.3.255. If I remember correctly, there are certain problems with using (a least one) those two addresses in a network with Windows computers with the old (pre-Vista) TCP/IP stack. I don't remember exactly what those problems were, and if those problems only exist when you are trying to assign one of those IPs to the Windows PC or if there are also communication problems between a Windows PC and those IPs. I also don't remember whether it's the network … – Jörg W Mittag Aug 9 '16 at 13:03
  • 2
    @JörgWMittag ilkkachu Even today, with variable sub-nets, several OS's (not just Windows) and a lot of other software have issues using any address ending in 0 or 255. Even if it is valid as an inside address of a range >256. This is a leftover of class-A/B/C addressing and a programmer assuming that any computer is on a class-C subnet and therefore 0 and 255 are per definition invalid. Even if your OS and software does it right, it is still possible to have to connect to another computer that has issues with it. Best to avoid .0 and .255 altogether even if they are valid in your setup. – Tonny Aug 9 '16 at 14:50
4

A reading of Internet Standard Subnetting Procedure, Toward an Internet Standard Scheme for Subnetting and specifically BROADCASTING INTERNET DATAGRAMS IN THE PRESENCE OF SUBNETS section 7 describes the rationale for the choices you present.

Your hypothesis is correct for CIDR subnets with continguous bitmasks.

It is easier to regard the broadcast address as Bcast = Host | ~Mask. This explicitly ignores the choice of bits in the subnet. Correspondingly the network address is Net = Bcast & ~Mask.

Strictly, the all zeros (.0 for CIDR/24) address can be used, but could confuse some software, while all ones (.255) is reserved as a well-known broadcast address.

Some early BSD Unix 4.2 releases before RFC 919 were shipped using the Net address as the broadcast. This caused some confusion in mixed environments until the 4.3 release.

1

Network Address

The network for Local area network (LAN) or Wide area network (WAN) is provided with address based on their capacity. The terminals attached to the network use these address to communicate with each other. The system by default reserves some address for the admin communication. Usually “255” addresses are used to broadcast messages in Linux or Fedora systems. The administrator uses this address to broadcast or address all the users of the network. In case of emergency shutdown the administrator can broadcast the message to its users to save their doings. Some operating systems provide facility to assign “0” address.

Find out more about Networking Basics: Network addressing by Microsoft

Also have a look at What is Network Address Translation?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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