Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am not sure if this is the right place to make this question but I thought this is one of the most appropriate SE's site to make a question on networking. Please move it to other more appropriate sites. Thanks.

So suppose I have a block of IPv4 addresses and one of the hosts address is Is it possible for me to find the first and last address of this block of address?

I am thinking like: is 182.44.82.(0001 0000) where the (0001 0000) is the binary for 16.

Since the mask is /26, I thought I could do this:

IP:   182.44.82.(0001 0000)
Mask: 182.44.82.(1111 1000)

And then this means I left with only the last 3 bits for the IP addresses, which makes the first address going to be and the last address But this doesn't look quite right. How can I calculate the first and last addresses of this block of addresses?

share|improve this question
up vote 1 down vote accepted

/26 means 26 bits for the subnet. At 8 bits per byte you get 24 for the first three bytes, and two for the last. It means your last byte will be of the form (nnhh hhhh), where n is a subnet bit and h a host bit. 16 is indeed (0001 0000), so you get (00xx xxxx).

Thus the network address is (00|00 0000) -> .0, the broadcast is (00|11 1111) -> .63, and the first and last useable addresses are .1 and .62.

share|improve this answer

IPv4 addresses are 32-bit unsigned INTs.

Since both the address and netmask can be expressed as a 32-bit unsigned INT, and they are intimately related, this is easy:

first = (addr && netmask)
last = (addr && netmask) + !netmask
share|improve this answer
Is the ! sign flipping the bits? Eg: !(101101) = 010010, is this right? – xenon Nov 4 '11 at 13:09
Correct. I was using C semantics, where ! means NOT. It is equivalent to (MAXINT XOR netmask), which may make it more clear for you. – adaptr Nov 4 '11 at 13:11

Subnet Calculator might work, Assuming the network class is class 'B' you get -

share|improve this answer
Why assume ? He stated the CIDR netmask is /26. Really, "classes" are not exactly relevant anymore. – adaptr Nov 4 '11 at 13:20

as given - any block of IP address is where /26 define the Prefix and to find First addr and Last addr you should know these formula:

First addrs = any IP addrs AND Netmask

Last addrs = any IP addrs OR ( ! Netmask )

to find Netmask :- as u given the Prefix is /26 that means 26 1's there Netmask = 11111111 11111111 1111111 11000000 (

! Netmask= 00000000 00000000 00000000 00111111

Now First addrs- AND you will get First addrs =

and Last addrs- OR ( ! Netmask) you will get Last addrs =

(use binary calculation to get these ans)

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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