Subnetting Basics
Subnetting Basics
8/4/2013
Objectives
Understand what an IP address is. Understand why we need to subnet. Be able to subnet Be able to interpret CIDR notation
8/4/2013
IP Address
An IP address is a 32-bit sequence of 1s and 0s. To make the IP address easier to use, the address is usually written as four decimal numbers separated by periods. This way of writing the address is called the dotted decimal format.
8/4/2013
IP Private Addresses
No two machines that connect to a public network can have the same IP address because public IP addresses are global and standardized Private IP addresses are a solution to the problem of the exhaustion of public IP addresses. Addresses that fall within these ranges are not routed on the Internet backbone:
Connecting a network using private addresses to the Internet requires the usage of NAT 8/4/2013
Logical Addressing
At the network layer, we use logical, hierarchical addressing. With Internet Protocol (IP), this address is a 32-bit addressing scheme divided into four octets. Do you remember the classes 1st octets value?
Class A: 1 - 126 Class B: 128 - 191 Class C: 192 - 223 Class D: 224 - 239 (multicasting) Class E: 240 - 255 (experimental)
8/4/2013
N
Class B :
N
Class C :
N
8/4/2013
H
6
Why Subnet?
Remember: we are usually dealing with a broadcast topology. Can you imagine what the network traffic overhead would be like on a network with 254 hosts trying to discover each others MAC addresses? Subnetting allows us to segment LANs into logical broadcast domains called subnets, thereby improving network performance.
7
8/4/2013
To correctly subnet a given network address into subnet addresses, ask yourself the following questions:
1. 2. 3. 4.
How many bits do I need to borrow? Whats the subnet mask? Whats the magic number or multiplier? What are the first three subnetwork addresses?
8/4/2013
First, you need to know how many bits you have to work with. Second, you must know either how many subnets you need or how many hosts per subnet you need. Finally, you need to figure out the number of bits to borrow.
8/4/2013
Remember: you must borrow at least 2 bits for subnets and leave at least 2 bits for host addresses. 2 2 bits borrowed allows 2 - 2 = 2 subnets
8/4/2013
10
2 2x BL 2 2x
Remember: we need to subtract two to provide for the subnetwork and broadcast addresses.
8/4/2013 11
Class C Example: 210.93.45.0 Design goals specify at least 5 subnets so how many bits do we borrow? How many bits in the host portion do we have to work with (HB)? Whats the BB in our HB = BB + BL formula? (8 = BB + BL) 2 to the what power will give us at least 5 subnets? 3 2 - 2 = 6 subnets
12
8/4/2013
How many bits are left for hosts? HB = BB + BL 8 = 3 + BL BL = 5 So how many hosts can we assign to each subnet? 5 2 - 2 = 30 hosts
13
8/4/2013
Class B Example: 185.75.0.0 Design goals specify no more than 126 hosts per subnet, so how many bits do we need to leave (BL)? How many bits in the host portion do we have to work with (HB)? Whats the BL in our HB = BB + BL formula? (16 = BB + BL) 2 to the what power will insure no more than 126 hosts per subnet and give us the most subnets? 7 2 - 2 = 126 hosts
14
8/4/2013
How many bits are left for subnets? HB = BB + BL 16 = BB + 7 BB = 9 So how many subnets can we have? 9 2 - 2 = 510 subnets
8/4/2013
15
We determine the subnet mask by adding up the decimal value of the bits we borrowed. In the previous Class C example, we borrowed 3 bits. Below is the host octet showing the bits we borrowed and their decimal values.
1
128
1
64
1
32 16 8 4 2 1
We add up the decimal value of these bits and get 224. Thats the last non-zero octet of our subnet mask. So our subnet mask is 255.255.255.224
8/4/2013 16
To find the magic number or the multiplier we will use to determine the subnetwork addresses, we subtract the last non-zero octet from 256. In our Class C example, our subnet mask was 255.255.255.224. 224 is our last non-zero octet. Our magic number is 256 - 224 = 32
8/4/2013
17
Quickly calculate the last non-zero octet when given the number of bits borrowed. Determine the number of bits borrowed given the last nonzero octet. Determine the amount of bits left over for hosts and the number of host addresses available.
Bits Non-Zero Borrowed Octet Hosts 2 192 62 3 224 30 4 240 14 5 248 6 6 252 2
8/4/2013
18
We now take our magic number and use it as a multiplier. Our Class C address was 210.93.45.0. We borrowed bits in the fourth octet, so thats where our multiplier occurs
We keep adding 32 in the fourth octet to get all six available subnet addresses.
19
8/4/2013
Now you can see why we subtract 2 when determining the number of host address. Lets look at our 1st subnet: 210.93.45.32 What is the total range of addresses up to our next subnet, 210.93.45.64?
210.93.45.32 to 210.93.45.63 or 32 addresses
.32 cannot be assigned to a host. Why? .63 cannot be assigned to a host. Why? So our host addresses are .33 - .62 or 30 host addresses-just like we figured out earlier.
20
8/4/2013
CIDR
8/4/2013
21
CIDR Notation
Classless Interdomain Routing is a method of representing an IP address and its subnet mask with a prefix. For example: 192.168.50.0/27 What do you think the 27 tells you?
27 is the number of 1 bits in the subnet mask. Therefore, 255.255.255.224 Also, you know 192 is a Class C, so we borrowed 3 bits!! Finally, you know the magic number is 256 - 224 = 32, so the first useable subnet address is 197.168.50.32!!
8/4/2013
202.151.37.0/26
Subnet mask?
255.255.255.192
Class C so 2 bits borrowed 256 - 192 = 64 202.151.37.64 64 + 64 + 64 = 192, so 202.151.37.192
23
Bits borrowed?
Magic Number?
8/4/2013
198.53.67.0/30
Subnet mask?
255.255.255.252
Class C so 6 bits borrowed 256 - 252 = 4 4 + 4 + 4 = 12, so 198.53.67.12 4 + 4 + 4 - 1 = 11, so 198.53.67.11
24
Bits borrowed?
Magic Number?
8/4/2013
200.39.89.0/28
32 + 16 -1 = 47, so 200.39.89.47
25
8/4/2013
194.53.45.0/29
Class C, so 5 bits borrowed Last non-zero octet is 248 Magic number is 256 - 248 = 8 Subnets are .8, .16, .24, .32, ect. So 194.53.45.26 belongs to the third subnet address (194.53.45.24) and is a host address.
What broadcast address would this host use to communicate with other devices on the same subnet?
8/4/2013
No Worksheet Needed!
After some practice, you should never need a subnetting worksheet again. The only information you need is the IP address and the CIDR notation. For example, the address 221.39.50/26 You can quickly determine that the first subnet address is 221.39.50.64. How?
For the rest of the addresses, just do multiples of 64 (.64, .128, .192).
27
8/4/2013
The Key!!
8/4/2013
Below are some practice problems. Take out a sheet of paper and calculate...
Bits borrowed Last non-zero octet Second subnet address and broadcast address
1. 2. 3.
4.
5.
8/4/2013
Bits Last NonMagic 2nd Subnet's 2nd Subnet's Address Class Borrowed Zero Octet Number Address Broadcast 192.168.15.0/26 C 2 192 64 192.168.15.128 192.168.15.191 220.75.32.0/30 C 6 252 4 220.75.32.8 220.75.32.11 200.39.79.0/29 C 5 248 8 200.39.79.16 220.39.79.23 195.50.120.0/27 C 3 224 32 195.50.120.64 195.50.120.95 202.139.67.0/28 C 4 240 16 202.139.67.32 202.139.67.47 Challenge: 132.59.0.0/19 B 3 224 32 132.59.64.0 132.59.95.255 64.0.0.0/16 A 8 255 1 64.2.0.0 64.2.255.255
8/4/2013
30