what is a subnet mask?

tokamak

Golden Member
Nov 26, 1999
1,072
0
0
whenever i'm at a lan or messing with network settings, i always wonder what the hell 'subnet mask' exactly is. i understand the concept of IP address. we always use 255.255.255.0 for subnet at lans, because i read that it's best somewhere once. so, what the hell is it?
 

Daxxax

Senior member
Mar 9, 2001
521
0
0
I don't know if this will make anymore sense but basically it's a way to divide a ip address into two parts, the first being the network address and the second being the node address. When you see a subnet mask of 255.255.255.0 what that means is that the IP address that it is attached to uses the first three octets to specify the network and the last octet to specify the node. If the subnet mask was 255.255.0.0 then the first two octets would be the network and the last two would be the node. The reason you see 255.255.255.0 so often is because it's the most popular one. This is a simple example but it should help have a general understanding of what it does.
 

Poontos

Platinum Member
Mar 9, 2000
2,799
0
0
Originally posted by: tokamak
whenever i'm at a lan or messing with network settings, i always wonder what the hell 'subnet mask' exactly is. i understand the concept of IP address. we always use 255.255.255.0 for subnet at lans, because i read that it's best somewhere once. so, what the hell is it?
Subnet masks & IP Addresses relay on eachother.


255.255.255.0 is a classic Class C block.

N N N H


Network, Network, Network, Host

192.168.1.1

Your nework numbers are 192.168.1, and your host number is .1

Here is a comparison:


Postal Codes in Canada, are in this format: M5V 3F6 for e.g. (Letter)(Number)(Letter) (Number)(Letter)(Number)

For the postal office to sort your mail, the postal code is required. For routers to sort your packets (packages of data sent through networks), a subnet mask is required to identify the network section (192.168.1 in my e.g. above) and your host # (.1).

M5V is associated with Toronto (a city in Ontario), so first thing that the postal system reads is the M5V "OK Bob, this one is directed to Toronto", once it gets to Toronto "3F6" allows them to route the mail further and eventually narrowed down to the area the house is in, within Toronto.

With IP addresses and subnet masks, the concept is similar. Routers need to know which part of the IP address is a network # and which part is the host (assigned to a node or network device/PC on a network), so they can deliver the packets accordingly.

There is much much more, but the concept is pretty simple. The hardest part is the math in calculating the subnets, etc.

Also, I would recommend going to LearnToSubnet.com.
 

Garet Jax

Diamond Member
Feb 21, 2000
6,369
0
71
tokamak,

The subnet mask is a way of spliting a set of IP addresses into segments or subnets. The easiest scenario is taking a Class C IP address (ie. 3 specified octets X.X.X.?) and spliting it into 2 segments. Each segment would consist of 128 IP addresses. There are two ways to figure out what the subnet mask should be for this configuration (the right way and the easy way). These calculations are for Class C IP addresses and their subnet masks. They may work for Class B, but I have not tried them.

The easy way is to divide the number of segments into 256 to get 128 and subtract that from 256 to get 128. Therefore the subnet mask becomes 255.255.255.128

The right way is to reserve the number of bits within the octet that are needed to split the 256 into 2 segments. In this case, we need 1 bit to represent 2 segments. The left most bits are always used in the octet. Therefore the bit representation is 10000000 or 128 in decimal.

To take another example, suppose you wanted to segment the octet into 8 pieces. Calculating again both ways gives:

Easy:
256/8 = 32
256 - 32 = 224 ----> subnet mask becomes 255.255.255.224

Right:
3 bits are required to represent 8 items therefore last octet is 11100000 or 128 + 64 + 32 = 224 in decimal
subnet mask becomes 255.255.255.224

The next question becomes how is this mask used for something useful :D

It is used to determine what segment or subnet a particular IP address belongs. Going back to the original subnet mask 255.255.255.128, let's take IP address 192.168.0.111 (this is what the first article minendo posted talks about). If we do a bitwise AND, we get:

11111111 11111111 11111111 10000000
11000000 10100100 00000000 01101111
------------------------------------------------------
11000000 10100100 00000000 00000000 = 192.168.0.0

This represents the network address for the subnet. There are a couple other calculations that can be done, but unfortunately I am running out of time so hopefully someone else can fill them in.