This question already has an answer here:

Let's have the following address of the network: What are the first and last IP addresses of this network?

Following this answer https://serverfault.com/a/327782/288201 I assume that:

/23 means 23 bits for the subnet. At 8 bits per byte we get 16 bits for the first two bytes, and then seven (7) for the third => 1111 1111. 1111 1111. 1111 1110. 0000 0000, right?

It means our last two bytes will be of the form (nnnn nnnH. HHHH HHHH), where n is a subnet bit and H a host bit.

Thus the network address is (nnnn nnn|0 0000 0000) -> .0, the broadcast is (nnnn nnn|1 1111 1111) -> 2^9 is broadcast? Impossible. Here I miss something, something simple. So what would be the first and last IP? This is what I don't get following the answer mentioned in the link above (by b0fh).

First, last

marked as duplicate by Michael Hampton May 10 '15 at 14:55

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.

  • 1
    You've answered your own question. It's correct. Why do you think it's impossible? – Andrew Schulman May 10 '15 at 10:55
  • Maybe I just interpreted it incorrectly. 2^9 is 512 and it cannot be value of broadcast of couse (max. only 255), right? But it is number of hosts (minus 2 reserved for network address and broadcast). But how I get the first and the last IP? Especially the last one is the one I'm not sure about. Do I really add +1 to the 176 and the rest is 255 - 1? – zus May 10 '15 at 11:00
  • @zus I think what you need to realize is that with CIDR (what we have all been using since the mid nineties), the octet boundaries are of little importance. – Håkan Lindqvist May 10 '15 at 11:22

What's confusing you is that you are trying to convert the host part into a decimal value and sum it up to the network address while the host part is split in two octects.

Your network is :


Your netmask is :


Your wildcard mask (the part that will change) :


Typically, when you say 2^9 = 512 is broadcast, you are simply forgetting that one bit of the host part is in the last bit of the third octect. So as it changes you will get either this :


Or this :


So here your "512" decimal form is in fact (should always be dotted decimal form so you don't make this mistake). The non-network part will go from to + The last address being the broadcast address you find out that this is

You can also get it by adding the wildcard mask to your network address :


+ 00000000.00000000.00000001.11111111

= 11000000.10101000.10110001.11111111

Which is

  • 1
    Thanks, you are answering exactly to me, to my thinking. – zus May 10 '15 at 12:13

I'll try to clarify what I interpret as your source of confusion:

An IPv4 address is a single 32 bit integer but it's not normally formatted that way when we write out an address.

As I'm sure you are aware, the norm is to write the address as [first eight bits in decimal].[next eight bits in decimal].[next eight bits in decimal].[last eight bits in decimal] but it's important to realize that it's really just a different way of formatting that single, potentially very big, number.

When you specify a CIDR netmask (/n) that says how many bits out of the 32 bit address form the network identifier, the remaining bits forming the host identifier.

In your example,, the first 23 bits are the network prefix, leaving 9 bits for the host identifier, which means that the host identifier straddles the last octet boundary. The host identifier will affect the last two segments of the a.b.c.d-formatted address.

To illustrate this, I'll include sipcalc output showing both the addresses as raw bits (really more relevant to understanding the math) as well as a.b.c.d-formatted addresses.

$ sipcalc -b                                                                                             
-[ipv4 :] - 0

[CIDR bitmaps]
Host address            - 11000000.10101000.10110000.00000000
Network address         - 11000000.10101000.10110000.00000000
Network mask            - 11111111.11111111.11111110.00000000
Broadcast address       - 11000000.10101000.10110001.11111111
Cisco wildcard          - 00000000.00000000.00000001.11111111
Network range           - 11000000.10101000.10110000.00000000 -
Usable range            - 11000000.10101000.10110000.00000001 -


$ sipcalc                                                                                               
-[ipv4 :] - 0

Host address            -
Host address (decimal)  - 3232280576
Host address (hex)      - C0A8B000
Network address         -
Network mask            -
Network mask (bits)     - 23
Network mask (hex)      - FFFFFE00
Broadcast address       -
Cisco wildcard          -
Addresses in network    - 512
Network range           - -
Usable range            - -


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