# How to find largest possible IPv4 network within specified range

Let's say, we are given a range of `192.168.101.64` - `192.168.102.128`.

What is the easiest way to find the largest possible IPv4 network within specified range, including network address, subnet mask and broadcast address?

Same thing for `192.168.104.31` - `192.168.106.127`.

In the first case I think it would be network for 127 hosts:

`Network address: 192.168.102.0`

`Subnet mask: 255.255.255.0`

`Broadcast: 192.168.102.128`

But I'm not sure about this and does not have any idea for the second case.

• Normally, IP addresses are assigned either individually (one by one, per host; not per network) or in subnet blocks (in which case your question is moot). Either way, your question appears to not match the way things are done in the real world. What is the real problem you are trying to solve, here? There might exist a much easier solution that accomplishes your actual goal. – a CVn May 23 '14 at 14:02
• This question appears to be off-topic because it does not appear to be about an actual problem. See What types of questions should I avoid asking?. – a CVn May 23 '14 at 14:03
• @MichaelKjörling The problem is, some addresses are assigned to existing subnets and I have to create another subnet in some weird range of addresses (between these existing ones) for as many hosts as possible. – Sebastian Potasiak May 23 '14 at 14:22
• Really this all comes down to CIDR principles. You can use a subnet calculator to figure it out if you don't want to learn all the math involved. Here is a good reference for manually calculating it out based on an IP address and subnet mask: wikihow.com/Calculate-Network-and-Broadcast-Address - otherwise, there are dozens of subnet calculators such as this one: subnetmask.info – MaQleod May 23 '14 at 15:58

For 192.168.101.64-192.168.102.128: You have two /25 ranges as largest: 192.168.101.128/25, 192.168.102.0/25

For 192.168.104.31 - 192.168.106.12: The largest is a /24: 192.168.105.0/24 You also have two /25 ranges as second largest: 192.168.104.128/25, 192.168.106.0/25.

• This. I think that's about the best one can do with the ranges given. Note that these are separate subnets, so without some sort of bridging or routing, hosts on one side of the /25 boundary aren't going to be able to talk to hosts on the other side of the boundary. – a CVn May 23 '14 at 18:30

I believe that this would be a 192.168.104.0/22 network

This would encompass host ranges from 192.168.104.1 - 192.168.107.254 Broadcast of 192.168.107.255 Subnet 255.255.255.252 Ammt of hosts would be 762

If u were to go to a /23 subnet your range of hosts would only go up to 192.168.105.254

• I think he is asking about the largest sections within those specified and not looking for one including them. – Bgs May 23 '14 at 15:41