4

A subnet of an IP network has a range of IP host address from 172.19.40.1 to 172.19.47.254.

  • What is the maximum number of host addresses that can exist on this subnetwork? I'm googling but not found a clear answer. how should we compute maximum number of host addresses?
1
  • just please clarify it in a beter way because it is difficult to understand
    – mbgfv
    Commented Jan 20, 2017 at 8:15

5 Answers 5

4

A subnet of an IP network has a range of IP host address from 172.19.40.1 to 172.19.47.254.

What is the maximum number of host addresses that can exist on this subnetwork? I'm googling but not found a clear answer. how should we compute maximum number of host addresses?

Method 1

Let's use a simple method to find this...

IP addresses contain four 8-bit integers; 8-bit integers have a maximum value of 255. Think of it like this... if we merely build a sequence of third-octets from 40 to 47 and account for the hosts, we'll find the answer with minimal math...

  • 172.19.40.1 through 172.19.40.255 = 255 hosts
  • 172.19.41.0 through 172.19.41.255 = 256 hosts
  • 172.19.42.0 through 172.19.42.255 = 256 hosts
  • 172.19.43.0 through 172.19.43.255 = 256 hosts
  • 172.19.44.0 through 172.19.44.255 = 256 hosts
  • 172.19.45.0 through 172.19.45.255 = 256 hosts
  • 172.19.46.0 through 172.19.46.255 = 256 hosts
  • 172.19.47.0 through 172.19.47.254 = 255 hosts

Number of hosts = 2*255 + 6*256 = 2046 hosts

Method 2

Use this method to find the number of hosts between two arbitrary IP addresses... convert the two 32-bit IP addresses to integers and subtract...

  • 172.19.40.1 => 2886936577
  • 172.19.47.254 => 2886938622

2886938622 - 2886936577 + 1 = 2046 hosts

Note that I added an extra host in the subtraction, since you're including the first host in the list of available hosts.

As someone mentioned below you can also use the host bits of the netmask, if you're merely calculating the number of hosts in an IP CIDR block.

How to convert an IPv4 addess to decimal:

172*256**3 + 19*256**2 + 40*256**1 + 1*256**0 = 2886936577

2
  • Thank you. Some of ranges are time consuming to find the number of host by this method. Is there an efficient formula for this purpose?
    – user3184352
    Commented Apr 8, 2014 at 10:04
  • thank you so much, it was perfect. if we have a mask address. for example IP_address/19. then what should we do?
    – user3184352
    Commented Apr 8, 2014 at 10:29
1

If you take 172.19.40.1 for a second and convert it to binary, then you get 10101100.00010011.00101000.00000001. So if you ignore the 172.19 part and just concentrate on the 40 part for a minute, you can see that in 00101000, the last three binary digits are 000.

If you cycle through the binary bits you'll see that you get the following:

40 = 00101000 41 = 00101001 42 = 00101010 43 = 00101011 44 = 00101100 45 = 00101101 46 = 00101110 47 = 00101111

Cool, so that means that the last three binary digits encompass every IP address from 172.19.40.xxx through 172.19.47.xxx, where xxx encompasses 0-255. Now since each number in an IP address is 2**8 hosts, another 3 binary digits makes it 2**11, which means that there are 2048 hosts. But since the first and last hosts in a subnet are broadcast addresses, it's 2**11 - 2, which is 2046.

Incidentally, that range from 172.19.40.1 through 172.19.47.254 can be represented as 172.19.40.0/21, which means the first 21 bits of a subnet mask are 1s, or network bits. so there are 11 bits left that are host bits, or 0s. Same calculation: 2**11 - 2 = 2046.

If you don't want to do the manual calculations yourself, you can find a boat load of subnet calculators that will tell you exactly how many hosts in a particular subnet.

0

Lets compute the longest common prefix between the two given IP address range.

172.19.40.1 in binary is 10101100.00010011.00101000.00000001

172.19.47.254 in binary is 10101100.00010011.00101111.11111110

Longest common prefix is 10101100.00010011.00101 which has a length of 21(excluding ".") which corresponds to subnet mask, therefore the remaining 11 bits(32 - 21 = 11) can be used for host which can either contain 0 or 1. so 2^11 = 2048.

Out of this addresses the first and last address correspond to network and broadcast address which cannot be used for host.

i.e 2048-2 = 2046 are the maximum number of host the given range of IP address can have.

0

As the Network range is 172.18.40.1 to 172.19.47.254 Network ID is 172.18.40.0 Broadcast IP is 172.18.47.255.... That means we have Range of 8 Our SM=255.255.248.0 so we have 11 Host bits

No. of Hosts=2^no. of host bits-2 =2^11-2 =2048-2 =2046

Hope this clear your doubts..

-3

If you are just wanting to know the number of hosts in any IP_Range/X:

(2^(32-X))-2

Everything is binary, so we take the number of zeros in the subnet mask (32-X), raise 2 to that power, and then subtract the network identifier and broadcast address from the result.

If you just want to know how many IP addresses (not quite the same thing as hosts) are in the range, don't bother subtracting 2.

Of course, you get nonsensical information when you use /31 (answer of 0) or /32 (-1), but asking for the number of hosts in a /31 or /32 isn't something you normally ask. Everyone 'knows' that you don't use /31 networks unless you do some sneaky stuff to avoid the net ID and broadcast addresses and /32 indicates a single host address.

If you are talking about IPv6, you just update the formula for the 128 bit mask, instead of the 32 bit mask of IPv4.

1
  • 1
    Plenty of networks use /31's for point to point connections. Also, subtracting two for a network and broadcast address is not applicable to IPv6.
    – Teun Vink
    Commented Apr 18, 2014 at 21:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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