Vous êtes sur la page 1sur 26

© Cisco Press

13 - Analyzing Subnet Masks

By Muhammad Asghar Khan


asghar.psh@gmail.com

Reference: Cisco CCENT/CCNA ICND1 100-101 Official Cert Guide By WENDELL ODOM
1/2
Agenda
 Subnet Mask Formats
 Binary
 Dotted-decimal notation (DDN)
 Prefix (also called CIDR)

 Subnet Mask Conversion


 Binary to Prefix/Prefix to Binary
 Binary to Decimal/Decimal to Binary
 Prefix to DNN/DNN to Prefix

 Exercise Subnet Mask Conversion

2 www.asghars.blogspot.com
2/2
Agenda
 Identifying Subnet Design Choices Using Masks
 Masks Divide the Subnet’s Addresses into Two Parts
 Masks and Class Divide Addresses into Three Parts
 Classless and Classful Addressing

 Calculations Based on the IPv4 Address Format


 Exercise Calculations Based on the IPv4 Address Format

3 www.asghars.blogspot.com
1/3
Subnet Mask Formats
 Subnet masks can be represented in three different formats
 Binary
 Dotted-decimal notation (DDN)
 Prefix (also called CIDR)
 Binary
 Subnet masks can be written as 32-bit binary numbers
according to the following rules:
 If 1s exist, they are on the left
 If 0s exist, they are on the right
 The value must not interleave 1s and 0s
 E.g. 10101010 01010101 11110000 00001111 is illegal because the
value interleaves 0s and 1s

4 www.asghars.blogspot.com
2/3
Subnet Mask Formats
 Dotted-decimal notation (DDN)
 DDN converts each set of 8 bits into the decimal
equivalent
 For example;
binary mask 11111111 00000000 00000000
00000000 can be converted to DNN as 255.0.0.0
 Prefix (also called CIDR)
 This format was introduced in in the early 1990s
 This format takes advantage of the rule that the subnet
mask starts with some number of 1s, and then the rest of
the digits are 0s. Prefix format lists a slash (/) followed by
the number of binary 1s in the binary mask
5 www.asghars.blogspot.com
3/3
Subnet Mask Formats
 E.g. the prefix equivalent of 255.0.0.0 is /8
 CIDR stands for classless inter domain routing

6 www.asghars.blogspot.com
1/4
Subnet Mask Conversion
 Converting Between Binary and Prefix Masks
 Binary to Prefix
 Count the number of binary 1s in the binary mask, and write
the total, in decimal, after a /
 Prefix to Binary
 Write P binary 1s, where P is the prefix value, followed by as
many binary 0s as required to create a 32-bit number
 Converting Between Binary and DDN Masks
 Binary to Decimal
 Organize the bits into four sets of eight. For each octet, find
the binary value in the table (on next slide) and write down
the corresponding decimal value

7 www.asghars.blogspot.com
2/4
Subnet Mask Conversion
 Decimal to Binary
 For each octet, find the decimal value in the table and write
down the corresponding 8-bit binary value
 Memorize the contents of table given below for the
conversion process

8 www.asghars.blogspot.com
3/4
Subnet Mask Conversion
 E.g. in 11111111 11111111 11000000 00000000 ; 11111111 maps to
255, 11000000 maps to 192 and 00000000 maps to 0 thus
mask in DDN is 255.255.192.0
 Converting Between Prefix and DNN Masks
 To convert between the prefix-to-decimal formats is to
first convert to binary
 To move from decimal-to-prefix, first convert decimal to
binary and then from binary to prefix
 For the exams, set a goal to master these conversions
doing the math in your head

9 www.asghars.blogspot.com
4/4
Subnet Mask Conversion
 Figure shows an example with a prefix-to-decimal
conversion. The left side shows the conversion to binary
as an interim step

 Similarly, when converting from decimal-to-prefix,


mentally convert to binary along the way, and as you
improve, just think of the binary as the number of 1s in
each octet

10 www.asghars.blogspot.com
1/4
Exercise Subnet Mask Conversion
 11111111 11111111 11000000 00000000
 In Prefix; /18
 In DDN
 For first octet
Row1 264 232 216 28 24 22 21 20
Row2 128 64 32 16 8 4 2 1
Octet 1 1 1 1 1 1 1 1
Add Row2 columns whose bit value is 1 in octet row
128+64+32+16+8+4+2+1 = 255

 For second octet


Row1 264 232 216 28 24 22 21 20
Row2 128 64 32 16 8 4 2 1
Octet 1 1 1 1 1 1 1 1
11 www.asghars.blogspot.com
Add Row2 columns whose bit value is 1 in octet row
2/4
Exercise Subnet Mask Conversion
 For third octet
Row1 264 232 216 28 24 22 21 20
Row2 128 64 32 16 8 4 2 1
Octet 1 1 0 0 0 0 0 0
Add Row2 columns whose bit value is 1 in octet row
128+64 = 192

 For fourth octet


Row1 264 232 216 28 24 22 21 20
Row2 128 64 32 16 8 4 2 1
Octet 0 0 0 0 0 0 0 0
Add Row2 columns whose bit value is 1 in octet row
=0

 Therefore; in DNN format it is 255.255.192.0

12 www.asghars.blogspot.com
3/4
Exercise Subnet Mask Conversion
 255.255.255.252
 In Binary
 1st octet

Row1 264 232 216 28 24 22 21 20


Row2 128 64 32 16 8 4 2 1
Add different combo of Row2 columns till we get the
value of octet, in question then place 1 for each
column you added in octet column
128 + 64 + 32 + 16 + 8 + 4 + 2 + 1 = 255
Octet 1 1 1 1 1 1 1 1

 For 2nd and 3rd octets result will be the same as of 1st octet

13 www.asghars.blogspot.com
4/4
Exercise Subnet Mask Conversion
 For 4th octet

Row1 264 232 216 28 24 22 21 20


Row2 128 64 32 16 8 4 2 1
Add different combo of Row2 columns till we get the
value of octet, in question then place 1 for each
column you added in octet column
128 + 64 + 32 + 16 + 8 + 4 = 252
Octet 1 1 1 1 1 1 0 0

 Therefore, in binary format mask will be 11111111 11111111


11111111 11111100
 In Prefix, /30

14 www.asghars.blogspot.com
Identifying Subnet Design Choices Using 1/4
Masks
 Masks Divide the Subnet’s Addresses into Two Parts
 The subnet mask subdivides the IP addresses in a subnet
into two parts: the prefix, or subnet part, and the host
part
 IP addresses in the same subnet have the same value in
the prefix part (subnet part) of their addresses
 The host part of an address identifies the host uniquely
inside the subnet
 The subnet mask defines the dividing line between the
prefix and the host part
 The concept is shown graphically in figure

15 www.asghars.blogspot.com
Identifying Subnet Design Choices Using 2/4
Masks
 Masks and Class Divide Addresses into Three Parts
 When we apply the Class A, B and C rules to the address,
this divides the prefix into two parts: network and subnet
part
 The combined network and subnet parts act like the
prefix because all addresses in the same subnet must
have identical values in the network and subnet parts
 Figure shows the same example as in the previous section

16 www.asghars.blogspot.com
Identifying Subnet Design Choices Using 3/4
Masks
 Classless and Classful Addressing
 Classful addressing means that you think about Class A, B,
and C rules, so the prefix is separated into the network and
subnet parts
 Classless addressing means that you ignore the Class A, B,
and C rules and treat the prefix part as one part
 When you see the words classless and classful, be careful to
note the context: addressing, routing, or routing protocols
 After you know how to break an address down using both
classless and classful addressing rules, you can easily
calculate a couple of important facts using some basic math
formulas

17 www.asghars.blogspot.com
Identifying Subnet Design Choices Using 4/4
Masks
 First for any subnet, after you know the number of host bits,
you can calculate the number of host IP addresses in the
subnet (2H-2)
 Second if you know the number of subnet bits (using classful
addressing concepts) and you know that only one subnet
mask is used throughout the network, you can also calculate
the number of subnets in the network (2s)
 Figure shows the relationship between /P, N, S, and H

18 www.asghars.blogspot.com
Calculations Based on the IPv4 Address 1/4
Format
 For any subnet, after you know the number of host bits, you can
calculate the number of host IP addresses in the subnet
 Next, if you know the number of subnet bits (using classful
addressing concepts) and you know that only one subnet mask is
used throughout the network, you can also calculate the number
of subnets in the network
 Hosts in the subnet
 2H – 2, where H is the number of host bits

 Subnets in the network


 2S, where S is the number of subnet bits

 The two parts with classless addressing must add up to 32 (P + H


= 32), and with classful addressing, the three parts must add up
to 32 (N + S + H = 32). Figure 13-8 shows the relationships

19 www.asghars.blogspot.com
Calculations Based on the IPv4 Address 2/4
Format
 To find all the information about specific IP address
(8.1.4.5) and subnet mask (255.255.0.0) follow the
following steps:
1. Convert mask to prefix format
 1st octet
Row1 264 232 216 28 24 22 21 20
Row2 128 64 32 16 8 4 2 1
Add different combo of Row2 columns till we get the
value of octet, in question then place 1 for each
column you added in octet column
128 + 64 + 32 + 16 + 8 + 4 + 2 + 1 = 255
Octet 1 1 1 1 1 1 1 1

 2nd octet will have same value as that of 1st octet

20 www.asghars.blogspot.com
Calculations Based on the IPv4 Address 3/4
Format
 3rd octet
Row1 264 232 216 28 24 22 21 20
Row2 128 64 32 16 8 4 2 1
Add different combo of Row2 columns till we get the
value of octet, in question then place 1 for each
column you added in octet column
0= 0
Octet 0 0 0 0 0 0 0 0

 4th octet will have same value as that of 3rd octet


 So the mask in binary will be 11111111 11111111 00000000
00000000
 In prefix format it will be /16

21 www.asghars.blogspot.com
Calculations Based on the IPv4 Address 4/4
Format
2. Determine N based on the class
 8 is in the range of Class A, so N = 8
3. Determine S
 S = P-N = 16-8 = 8
4. Determine H
 H = 32 – P = 32 – 16 = 16
5. Calculate hosts per subnet
 2H-2 = 216 – 2 = 65,534 hosts/subnet
6. Calculate number of subnets
 2s = 28 = 256 subnets

22 www.asghars.blogspot.com
Exercise Calculations Based on the IPv4 1/3
Address Format
 IP address 130.4.102.1, mask 255.255.255.0
1. Convert mask to binary
 For 1st, 2nd and 3rd octet

Row1 264 232 216 28 24 22 21 20


Row2 128 64 32 16 8 4 2 1
Add different combo of Row2 columns till we get the
value of octet, in question then place 1 for each
column you added in octet column
128 + 64 + 32 + 16 + 8 + 4 + 2 + 1 = 255
Octet 1 1 1 1 1 1 1 1

23 www.asghars.blogspot.com
Exercise Calculations Based on the IPv4 2/3
Address Format
 For 4th octet
Row1 264 232 216 28 24 22 21 20
Row2 128 64 32 16 8 4 2 1
Add different combo of Row2 columns till we get the
value of octet, in question then place 1 for each
column you added in octet column
0= 0
Octet 0 0 0 0 0 0 0 0

 So in binary format mask is 11111111 11111111 11111111 00000000,


in prefix /24
2. Determine N based on the class
 130 is in the range of Class B, so N = 16
3. Determine S
 S = P-N = 24-16 = 8
24 www.asghars.blogspot.com
Exercise Calculations Based on the IPv4 3/3
Address Format
4. Determine H
 H = 32 – P = 32 – 24 = 8
5. Calculate hosts per subnet
 2H-2 = 28 – 2 = 14 hosts/subnet
6. Calculate number of subnets
 2s = 28 = 256 subnets

25 www.asghars.blogspot.com
Note
Before moving forward you should be able to
find— the size of the three parts (N, H and S),
plus the formulas to calculate the number of
subnets and hosts— in around 15 seconds

26 www.asghars.blogspot.com

Vous aimerez peut-être aussi