(I’m going to vastly simplify this concept. Fair warning to networking nerds.)

Let’s say the IP range in question is 192.168.0.1 to 192.168.0.255. The classic /24 network. (Also a private one.)

Where does /24 come from?

Well, in this range, the bits that DONT change are the Network bits. that’s the 192.168.0 bit in this case.

Each octect is from 0-255 - an 8 bit number (2^8 = 256).

There are 4 octets, so there are a total of 32 bits required to specify our IP address.

In terms of routing information, the computer needs to know "How much of this IP is *networking* information, and how much is *computer-specific* information. This is where the netmask comes in.

We have 256 possible addresses on our network (granted, one of them will be used for the gateway, and another for the broadcast address, but those are still addresses on the network.)

256 addresses can be represented by 8 bits. So, the last 8 bits of our binary string are the **computer specific** information. This means that 32-8 = 24 … there are 24 bits available to be used for Networking information. (/24 … 24 bits of Networking information.)

Netmask says: Take a binary string. Networking Information space = 1’s, Computer Specific information space = 0’s.

For our /24, that would be 11111111111111111111111100000000.

Break that up into 8-bit chunks: 11111111 11111111 111111111 00000000

Convert those 8 bit chunks into decimal: 255 255 255 0 (Look familiar?)

Now lets take your example:

one IP 345.345.345.0 to 345.345.345.127

So you’re looking at 128 addresses this time. We don’t need 8 bits for that, because 2^7 is 128. So we can use **7** bits of information for the computer-specific addressing, and stick that extra bit out front back into the Network addressing pool.

Because we’re using 7 bits for that, and our IP string is still 32 bits long (never changes in IPv4), that means our networking information is *25* bits long. This is a /25 network.

What is its Netmask? Well, repeat the process:

Take the 32 bit breakdown: 11111111111111111111111110000000.

Break that up into 8-bit chunks: 11111111 11111111 111111111 10000000

Convert those 8 bit chunks into decimal: 255 255 255 128

So your netmask is 255.255.255.128. It will be the same for your second network.

So what differentiates the networks? Well, both networks will have a Gateway. Normally, that’s the first IP in the range. Because of the Netmask, it knows it’s a /25, and it can say “the gateway for 345.345.345.6 will be 345.345.345.1.”

Similarly, because of the netmask, a computer can say “the gateway for 345.345.345.200 is 345.345.345.128.”

So: Test Yourself: What would be the Netmask for a network from 192.73.208.1 to 192.73.209.255? What /# is it?