Trying Explaining Subnet Masks


The simple answer: A subnet mask helps define if an IP address belongs to a LAN or outside of the LAN

A Subnet mask consist of 4 numbers (also called Octets) ranging from 0 to 255. In most cases is either a 0 or 255. The subnet mask, like the name suggests “masks” or filters (include or exclude certain values) to identify if an IP belongs to a LAN or outside of a LAN Wherever you see a “255” the # has to be exactly in the same local area network
wherever you see a “0” the number is usually the host part of the network and it indicates the numbers will be different indicates (see network classes below)

Example: the two IPs 192.168.10.5 and 192.168.10.8 are in the same subnet since the 255.255.255.0 mask makes only the last octet different, making both IPs part of the same network and subnet, so in that case one computer will be sending the packets directly to that other computer on the same local network and we don’t even need a gateway.

192.168.10.5 192.168.10.8
255.255.255.0 255.255.255.0
192.168.10.x 192.168.10.y

On the other hand an IP address 192.168.20.5 is NOT part of the same network as the other two IPs because the third octet is on a different SUBNET. A gateway (router) is needed here to “route” the packets from one subnet (the “10”) to another (the “20” subnet”)

192.168.20.5
255.255.255.0
192.168.w.z

A subnet example:

255.255.255.255 – (total of addresses is 256; remember 0 to 255 = 256)
So, if we subtract 240 from 256 = 16. The 16 are the steps the subnets go up in
So, for a 255.255.255.240 subnet there are 16 possible subnets each one with 16 possible IP addresses

How many IP addresses are available on a 240 subnet mask (or 255.255.255.240 subnet mask)
Answer: You need to subtract 240 from 256
256 –
255.255.255.240
=16

Thus, 0 to 15 = 1st subnet
16 to 31 = 2nd subnet
32 to 47 = 3rd subnet
48 to 63 = 4th subnet
64 to 79 = 5th subnet
80 to 95 = 6th subnet
96 to 111 = 7th subnet
112 to 127= 8th subnet
128 to 143 = 7th subnet
144 to 159 = 8th subnet
160 to 175 = 9th subnet
176 to 191 = 10th subnet
192 to 207 = 11th subnet
208 to 223 = 12th subnet
224 to 239 = 13th subnet
240 to 255 = 14th subnet

so there are 16 steps between these subnets (14 hosts one network address and one broadcast address)

Dotted Decimal Representation of Subnet Masks

Subnet masks are frequently expressed in dotted decimal notation. After the bits are set for the network ID and host ID portion, the resulting 32-bit number is converted to dotted decimal notation. Note that even though expressed in dotted decimal notation, a subnet mask is not an IP address.

A default subnet mask is based on the IP address classes and is used on TCP/IP networks that are not divided into subnets. Table 1.14 lists the default subnet masks using the dotted decimal notation for the subnet mask.

Table 1.14 Default Subnet Masks (Dotted Decimal Notation)

Address Class
Bits for Subnet Mask
Subnet Mask
Class A
11111111 00000000 00000000 00000000
255.0.0.0
Class B
11111111 11111111 00000000 00000000
255.255.0.0
Class C
11111111 11111111 11111111 00000000
255.255.255.0
Custom subnet masks are those that differ from these default subnet masks when you are doing subnetting or supernetting. For example, 138.96.58.0 is an 8-bit subnetted class B network ID. Eight bits of the class-based host ID are being used to express subnetted network IDs. The subnet mask uses a total of 24 bits (255.255.255.0) to define the subnetted network ID. The subnetted network ID and its corresponding subnet mask is then expressed in dotted decimal notation as:

138.96.58.0, 255.255.255.0

Top Of Page
Network Prefix Length Representation of Subnet Masks

Because the network ID bits must always be chosen in a contiguous fashion from the high order bits, a shorthand way of expressing a subnet mask is to denote the number of bits that define the network ID as a network prefix using the network prefix notation: /. Table 1.15 lists the default subnet masks using the network prefix notation for the subnet mask.

Table 1.15 Default Subnet Masks (Network Prefix Notation)

Address Class
Bits for Subnet Mask
Network Prefix
Class A
11111111 00000000 00000000 00000000
/8
Class B
11111111 11111111 00000000 00000000
/16
Class C
11111111 11111111 11111111 00000000
/24
For example, the class B network ID 138.96.0.0 with the subnet mask of 255.255.0.0 would be expressed in network prefix notation as 138.96.0.0/16.

As an example of a custom subnet mask, 138.96.58.0 is an 8-bit subnetted class B network ID. The subnet mask uses a total of 24 bits to define the subnetted network ID. The subnetted network ID and its corresponding subnet mask is then expressed in network prefix notation as:

138.96.58.0/24

Network prefix notation is also known as Classless Interdomain Routing (CIDR) notation.

Note

Because all hosts on the same network must use the same network ID, all hosts on the same network must use the same network ID as defined by the same subnet mask. For example, 138.23.0.0/16 is not the same network ID as 138.23.0.0/24. The network ID 138.23.0.0/16 implies a range of valid host IP addresses from 138.23.0.1 to 138.23.255.254. The network ID 138.23.0.0/24 implies a range of valid host IP addresses from 138.23.0.1 to 138.23.0.254. Clearly, these network IDs do not represent the same range of IP addresses.

Top Of Page
Determining the Network ID

To extract the network ID from an arbitrary IP address using an arbitrary subnet mask, IP uses a mathematical operation called a logical AND comparison. In an AND comparison, the result of two items being compared is true only when both items being compared are true; otherwise, the result is false. Applying this principle to bits, the result is 1 when both bits being compared are 1, otherwise the result is 0.

IP performs a logical AND comparison with the 32-bit IP address and the 32-bit subnet mask. This operation is known as a bit-wise logical AND. The result of the bit-wise logical AND of the IP address and the subnet mask is the network ID.

For example, what is the network ID of the IP node 129.56.189.41 with a subnet mask of 255.255.240.0?

To obtain the result, turn both numbers into their binary equivalents and line them up. Then perform the AND operation on each bit and write down the result.

10000001 00111000 10111101 00101001 IP Address

11111111 11111111 11110000 00000000 Subnet Mask

10000001 00111000 10110000 00000000 Network ID

The result of the bit-wise logical AND of the 32 bits of the IP address and the subnet mask is the network ID 129.56.176.0.
source: technet

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: