Subnet masks are used to tell which part of the IP address represents the network on which the computer is connected (network portion) and the computer's unique identifier on that network (host portion). The term netmasks is often used interchangeably with the term subnet masks, this book will use the latter term for the sake of consistency.
A simple analogy would be a phone number, such as (808) 225-2468. The (808) represents the area code, and the 225-2468 represents the telephone within that area code. Subnet masks allow you to specify how long you want the area code to be (network portion) at the expense of the number of telephones in that are in the area code (host portion)
Most home networks use a subnet mask of 255.255.255.0. Each 255 means this octet is for the area code (network portion). So if your server has an IP address of 192.168.1.25 and a subnet mask of 255.255.255.0, the network portion would be 192.168.1 and the server or host would be device #25 on that network.
In all cases, the first IP address in a network is reserved as the network's base address and the last one is reserved for broadcast traffic that is intended to be received by all devices on the network. In our example, 192.168.1.0 would be the network address and 192.168.1.255 would be used for broadcasts. This means you can then use IP addresses from #1 to #254 on your private network.
Calculating The Number of Addresses Assigned to a Subnet
Most office and home networks use networks with 255 IP addresses or less in which the subnet mask starts with the numbers 255.255.255. This is not a pure networking text, so I'll not discuss larger networks because that can become complicated, but in cases where less than 255 IP addresses are required a few apply. There are only seven possible values for the last octet of a subnet mask. These are 0, 192, 128, 224, 240, 248 and 252. You can calculate the number of IP addresses for each of these by subtracting the value from 256.
In many cases the subnet mask isn't referred to by the dotted decimal notation, but rather by the actual number of bits in the mask. So for example a mask of 255.255.255.0 may be called a /24 (slash 24) mask instead. A list of the most commonly used masks in the office or home environment is presented in Table 2-2.
Table 2-2: The "Dotted Decimal" And "Slash" Subnet Mask Notations
Dotted Decimal Format | Slash Format | Available Addresses |
---|---|---|
255.255.255.0 | /24 | 256 |
255.255.255.128 | /25 | 128 |
255.255.255.192 | /26 | 64 |
255.255.255.224 | /27 | 32 |
255.255.255.240 | /28 | 16 |
255.255.255.248 | /29 | 8 |
255.255.255.252 | /30 | 4 |
So for example, if you have a subnet mask of 255.255.255.192, then you have 64 IP addresses in your subnet (256 - 192)
Calculating the Range of Addresses on Your Network
If someone gives you an IP address of 97.158.253.28 and a subnet mask of 255.255.255.248, how do you determine the network address and the broadcast address, in other words the boundaries, of your network? The following section outlines the steps to do this using both a manual and programmed methodology.
Manual Calculation
Take out your pencil and paper, manual calculation can be tricky. Here we go!
- Subtract the last octet of the subnet mask from 256 to give the number of IP addresses in the subnet. (256 - 248) = 8
- Divide the last octet of the IP address by the result of step 1; don't bother with the remainder (for example 28 / 8 = 3). This gives you the theoretical number of subnets of the same size that are below this IP address.
- Multiply this result by the result of step 1 to get the network address (8 x 3 = 24). Think of it as the third subnet with 8 addresses in it. The network address is therefore 97.158.253.24
- The broadcast address is the result of step 3 plus the result of step 1 minus 1. (24 + 8 -1 = 31). Think of it as the broadcast address being the network address plus the number of IP addresses in the subnet minus 1". The broadcast address is 97.158.253.31
Let's do this for 192.168.3.56 with a mask of 255.255.255.224:
- 256 - 224 = 32
- 56/32 = 1
- 32 x 1 = 32. Therefore the network base address is 192.168.3.32
- 32 + 32 - 1 = 63. Therefore the broadcast address is 192.168.3.63
Let's do this for 10.0.0.75 with a mask of 255.255.255.240
- 256 - 240 = 16
- 75/16 = 4
- 16 x 4 = 64. Therefore the network base address is 10.0.0.64
- 64 + 16 -1 = 79. Therefore the broadcast address is 10.0.0.79
Note: As a rule of thumb, the last octet of your network base address must be divisible by the "256 minus the last octet of your subnet mask" and leave no remainder. If you are sub-netting a large chunk of IP addresses it's always a good idea to lay it out on a spreadsheet to make sure there are no overlapping subnets. Once again, this calculation exercise only works with subnet masks that start with "255.255.255".
No comments:
Post a Comment