0

This question already has an answer here:

Lets say I have to create 256 subnets (it could be any number), how would I find the first and last (network/broadcast addresses) for a randomly chosen subnet? For instance, subnet 139.

I'll give an example. Network IP: 145.0.0.0/8 This IP needs to be subsetted into 300 subnets. Network mask: 255.0.0.0 Network address (first address):145.0.0.0/8 Broadcast address: 145.255.255.255/8 Number of hosts: 2^(32-8) = 16777216 Addresses/subnet: 65536 (16777216/256) Subnet mask: /16

I'm not really concerned about usable addresses, just trying to understand a concept.

The first subnet would be: Network address: 145.0.0.0/16 Broadcast Address: 145.0.255.255

So, is there a formula or method to finding a randomly picked subnet's network/broadcast address?

marked as duplicate by Mike Pennington, Teun Vink Feb 7 '17 at 6:22

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.

0

Take the subnet number, subtract one (the first one is 0), and put that in the subnet part of the address. In your example, 145.0.0.0/8 will have 256 /16 subnets. The 139th subnet will be 145.138.0.0/16. You only need the subnet and the mask to figure out anything else.

To do this correctly (otherwise you can make some serious mistakes with non-octet bounded networks), you need to do it in binary. See this answer for how to do all the calculations.

  • Ok thanks! That makes sense. So what if the number of subnets is more than 256? Lets say I need 512 subnets. I'm assuming I would borrow from the right. So subnet 405, would be 145.255.149.0? (255 for the second octet, then the remaining [405-256] for the third octet? – Jeremy Feb 5 '17 at 19:35
  • You need to calculate the subnet mask. To get 512 subnets from a /8 network the subnets need to be /17. That gets you off the octet boundaries, and you need to do this in binary. Get 404 in binary (110010100) and place it into the subnet part of the address. You get 14.202.0.0/17. Forget octets, they are only to make an address easier for humans to read, and they really play no part in addressing. IPv4 addresses are simply 32-bit binary numbers. – Ron Maupin Feb 5 '17 at 19:39

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