User Tools

Site Tools


networking:subnet_masks:introduction_to_ip_addresses_and_subnetting

Networking - Subnet Masks - Introduction to IP Addresses and Subnetting

An IP address contains a network portion and a host portion.

The netmask determines the division between these portions.

Together the operating system can determine which IPs are part of the local subnet and which ones are outside.


The Classless Internet Domain Routing (CIDR) Notation

An IPv4 IP address (32 bits) of 192.168.1.200 with a subnet mask of 255.255.255.0 is represented in CIDR notation as: 192.168.1.200/24 (First 24 bits have binary value of 1, 11111111 = 255). The /24 is called the netmask.

  • The network address is 192.168.1.0 (Logical AND between the address and the netmask).
  • There's one subnet with 256 addresses.
  • Only 254 addresses are usable because the first one is used for the network address and the last is the broadcast address.

If we use 192.168.1.200/26, the netmask is 255.255.255.192. This netmask tells us that the broadcast addresses will begin with 192.168.1 and that the range of each subnet is 64 (256-192).

The way to find out the number of subnets and hosts is simple.

  • Find out the number of added bits (26-24 = 2).
  • Find out how many bits are left (8-2 = 6).
  • Calculate 2^6 and you get 64. This is the number of hosts per subnet.
  • For the total number of subnets all you do is divide 256/64 and we'll get 4 subnets.

A table might make this clearer:

MASK BITS# OF SUBNETS# OF HOSTSADDED BITSSUBNET MASK BITS (DEC)
/24125600
/2521281128
/264642192
/278323224
/2816164240
/293285248
/306446252

The next steps is to find:

  • Network Address of the IP
  • Broadcast Address of the IP

Let's take for example 192.168.1.75/27. Using the chart above we know there are 8 subnets with 32 addresses each. This IP obviously cannot reside in the .32 to .63 range so it must be in the .64 to .93 range. Hence the network address for 192.168.1.75/27 is 192.168.1.64 and the broadcast address is 192.168.1.95.


Summary

So what's the point of all this madness?

Here's a real world example. Say you're hired to divide up a 10.14.1.0/24 network into 20 subnets. Each subnet represents a department in the company. How would you do this? From looking at the chart above, you'll need to allocate 32 subnets, which means you need to change the netmask to /29. Each subnet will have 8 hosts which has only 5 usable addresses (You need one for network address, broadcast, and router).

networking/subnet_masks/introduction_to_ip_addresses_and_subnetting.txt · Last modified: 2020/08/19 16:11 by 192.168.1.1

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki