Vous êtes sur la page 1sur 62

SUBNETTING

PURPOSE OF SUBNETTING

BEST PRACTICE
Suppose

that you decide to use a private


Class
B
IP
address
(for
example,172.16.0.0/16) for your internal IP
addressing. For performance reasons, you
probably would not want to support as many
as 65,534 hosts in a single broadcast domain.

Therefore,

a best practice is to take such a


network address and subnet the network
(thereby extending the number of network

IP Address Block
group

of IP addresses
1 block = 1 subnet = 1 network

Network Address
representative

of the whole block


first address of the ip block
always an even number
used for routing (routers talk via
network address)

Broadcast Address

the

last address in a
block
always odd number

Host Address
usable

ip address

For instance
192.168.1.0 - network address
192.168.1.1
.
.

host addresses

.
192.168.1.254
192.168.1.255 - broadcast address

/ - Prefix Length
192.168.1.0/24 - refers to the network bits and
the number of IP addresses that can be created.

CIDR
CLASSLESS

INTER-DOMAIN ROUTING
Pronounced as CIDER
CIDR is a slash notation of subnet mask. CIDR tells us
number of on bits in a network address.
Gets its name from the notion that it ignores the
traditional A,B,C class designations and sets the
network-host ID boundary wherever it wants to, in a
way that simplifies routing across the resulting IP
address space.

SUBNETTING
A

subnetwork, or subnet, is a logical,


visible subdivision of an IP network.
represents stealing bits from the
host portion of the address and using
stolen (borrowed) bits to create
multiple routing regions within the
context of a single network address.

Classful vs Classless
Classful
192.168.1.0

/24

255.255.255.0

(CLSM-Constant Length Subnet Mask)

Classless
192.168.1.0

/29

255.255.248.0

(VLSM-Variable Length Subnet Mask)

Subnet Mask Table


128 192 224 240 248 252 254 255

MAGIC
NUMBER

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

Exercises
Given

a subnet mask of /17, what is the


corresponding dotted-decimal notation?

Given

a subnet mask of /22, what is the


corresponding dotted-decimal notation?

Given

a subnet mask of /30, what is the


corresponding dotted-decimal notation?

CREATING MULTIPLE
SUBNETS IN A
NETWORK

BORROWED BITS
When

you add bits to a classful mask,


the bits you add are referred to as
borrowed bits . The number of
borrowed bits you use determines how
many subnets are created and the
number of usable hosts per subnet.

Creating Subnets
Number

of created subnets = 2 s (where


s is the number of borrowed bits)
Example : 192.168.1.0/28
Answer : 192.168.1.0/24 with a 28-bit
subnet mask yields 16 subnets.
Subnet Mask = 255.255.255.240

Calculating Number of Hosts


Number

of assignable IP address in a subnet = 2


the number of host bits in the subnet mask)

Example

2(where h is

: 192.168.1.0/28

Number

of host bits = 32 Number of bits in subnet mask

Number

of host bits = 32 28 = 4

Number

of assignable IP addresses in a subnet = 2

Number

of assignable IP addresses in a subnet = 2

2 = 16 2 =

14

Therefore,

From this calculation, you can conclude that


each of the 192.168.1.0/28 subnets has 14 usable IP
addresses.

Subnet

Mask = 255.255.255.240

Another solution
/28

=
11111111.11111111.11111111.1
1110000
Remaining zeros = 4 = 2 4 2 =
16 2 = 14 useable host
addresses

Practice Exercise#1
Your

company has been assigned


the 172.20.0.0/16 network for use at
one of its sites. You need to use a
subnet mask that will accommodate
47 subnets while simultaneously
accommodating
the
maximum
number of hosts per subnet. What

Answer:
172.20.0.0/16

with a 22-bit subnet mask


yields 64 subnets.
32 22 = 10
Formula : 2 h 2 = 2 10 2 = 1024 -2 =
1022 usable IP addresses
Subnet Mask = 255.255.252.0

Practice Exercise 2
Your

company has been assigned


the 172.20.0.0/16 network for use at
one of its sites. You need to calculate
a
subnet
mask
that
will
accommodate 100 hosts per subnet
while maximizing the number of
available subnets. What subnet

Answer:
Because

an IPv4 address has 32 bits and you need 7


host bits, you can calculate the number of subnet
bits by subtracting the 7 host bits from 32 (that is,
the total number of bits in an IPv4 address).

This

results in a 25-bit subnet mask (that is, 32 total


bits 7 host bits = 25 subnet mask bits).

Therefore,

you can conclude that to meet the


scenarios requirements, you should use a subnet
mask of /25, which could also be written as
255.255.255.128.

CALCULATING IP
ADDRESS RANGES

Example
Your

company has been assigned the


172.20.0.0/16 network for use at one of
its sites. You need to use a subnet mask
that will accommodate 47 subnets while
simultaneously
accommodating
the
maximum number of hosts per subnet.
What subnet mask will you use?

Answer:
172.20.0.0/16

with a 22-bit subnet mask


yields 64 subnets.
32 22 = 10
Formula : 2 h 2 = 2 10 2 = 1024 -2 =
1022 usable IP addresses
Subnet Mask = 255.255.252.0

Solution:
Step

1 - The subnet mask (in binary) is


11111111.11111111.11111100.00000000. The interesting octet is
the third octet because the third octet contains the last 1 in the
subnet mask. 172.20.0.0/22, Subnet Mask = 255.255.252.0

Step

2 - The decimal value of the third octet in the subnet mask is


252 (11111100 in decimal). Therefore, the block size is 4 (256
252 = 4)128 192 224 240 248 252 254 255

1
9
17
25

2
10
18
26

3
11
19
27

4
12
20
28

5
13
21
29

6
14
22
30

7
15
23
31

8
16
24
32

Step

3 - The first subnet is 172.20.0.0/16 (the value of the original 172.20.0.0


network with the borrowed bits [the first six bits in the third octet] set to 0).

Step

4 - Counting by 4 (the block size) in the interesting octet (the third octet)
allows you to calculate the remaining subnets:

172.16.0.0
172.16.4.0
172.16.8.0
.
.
172.16.252.0

How to get Broadcast Address


Use

this magic number


128

64

32

16

In

the third octet, 11111100, the last 1 falls under the value of 4,
then you add 2 + 1 to get the BROADCAST ADDRESS

2+

1 are the value of the remaining zero in the third octet.

172.20.0.0

yields to 0 + 3 = Broadcast = 3.255 (remember, 255 is


the broadcast address)

IP Address Range
Subnet Address

Broadcast Address

Usable IP Address

172.16.0.0

172.16.3.255

172.16.0.1 172.16.3.254

172.16.4.0

172.16.7.255

172.16.4.1 172.16.7.254

172.16.8.0

172.16.11.255

172.16.8.1
172.16.11.254

172.16.12.0

172.16.15.255

172.16.12.1
172.16.15.254

172.16.248.0

172.16.251.255

172.16.248.1
172.16.251.254

172.16.252.0

172.16.255.255

172.16.252.1
172.16.255.254

Practice Exercise # 2
Determine

the subnets created


by the 20-bit subnet mask
applied to the 172.20.0.0/16
network:

ANSWER
SUBNE
T No.

SUBNET
ADDRESS

BROADCAST
ADDRESS

USEABLE HOST
ADDRESSES

172.20.0.0

172.20.15.255

172.20.0.1 172.20.15.254

172.20.16.0

172.20.31.255

172.20.16.1
172.20.31.254

172.20.32.0

172.20.47.255

172.20.32.1
172.20.47.254

172.20.48.0

172.20.63.255

172.20.48.1
172.20.63.254

172.20.64.0

172.20.79.255

172.20.64.1
172.20.79.254

172.20.80.0

172.20.95.255

172.20.80.1
172.20.95.254

SUBNET MASK : 255.255.240.00


7
172.20.96.0
172.20.111.255
8

172.20.112.0

172.20.127.255

172.20.96.1
172.20.111.254
172.20.112.1

ANSWER
SUBNET NO

SUBNET
ADDRESS

BROADCAST
ADDRESS

USEABLE HOST
ADDRESSES

172.20.128.0

172.20.143.255

172.20.128.1
172.20.143.254

10

172.20.144.0

172.20.159.255

172.20.144.1
172.20.159.254

11

172.20.160.0

172.20.175.255

172.20.160.1
172.20.175.254

12

172.20.176.0

172.20.191.255

172.20.176.1
172.20.191.254

13

172.20.192.0

172.20.207.255

172.20.192.1
172.20.207.254

SUBNET MASK : 255.255.240.00


14
172.20.208.0
172.20.223.255
15

172.20.224.0

172.20.239.255

172.20.208.1
172.20.223.254
172.20.224.1

IN SUMMARY
How

many subnets? 2s = number of


subnets
How many hosts per subnet? 2h 2
What are the valid subnets? 256
subnet mask = block size, or increment
number.
Whats the broadcast address for each
subnet?

VLSM

VLSM
is

the more realistic way of


subnetting a network to make for the
most efficient use of all of the bits.
is the process of subnetting a
subnet and using different subnet
masks for different networks in your
IP plan.

EXAMPLE

HOW TO

Step 1 Determine How Many H Bits Will


Be Needed to Satisfy the Largest Network
A

is the largest network with 50


hosts. Therefore, you need to know
how many H bits will be needed:

If 2H 2 = Number of
valid hosts per subnet

Then

2H 2 50

Therefore

for H)

H = 6 (6 is the smallest valid value

You

need 6 H bits to satisfy the requirements


of Network A.

32-26

= 6 hosts bits

Started

with: NNNNNNNN (these are the 8


bits in the fourth octet) (192.168.100.0/24)

Now
All

have: NNHHHHHH (192.168.100.0/26)

subnetting will now have to start at this


reference point, to satisfy the requirements of

Step 2 Pick a Subnet for the


Largest Network to Use
To

solve for increment size (block size) -> 256-192 = 64

NN

= 00HHHHHH (The Hs = The 6 H bits you need for Network A)

00000000

=
01000000 =
10000000 =
11000000 =

.0
.64
.128
.192

Step 3 Pick the Next Largest


Network to Work With
Network

B = 27 hosts
Determine the number of H bits needed
for this network:
2H 2 27
H=5

You

started with a pattern of 2 N bits and


6 H bits for Network A. You have to
maintain that pattern.
Pick one of the remaining /26 networks to
work with Network B.
For the purposes of this example, select
the .128/26 network: 192.168.100.128/26

But

you need only 5 H bits, not


6. Therefore, you are left with
10N00000
Where:
10 represents the original
pattern of subnetting.
N represents the extra bit.
00000 represents the 5 H bits

Because

you have this extra bit, you can


create two smaller subnets from the original
subnet:

10000000
10100000
Converted

follows:

to decimal, these subnets are as

10000000

=.128

10100000

=.160

You have now subnetted a subnet!

Each

of these sub-subnets will have a new subnet mask.


The original subnet mask of /24 was changed into /26
for Network A.

You

then take one of these /26 networks and break it


into two /27 networks:

10000000 and 10100000 both have 3 N bits and 5


H bits.
The

mask now equals:


11111111.11111111.11111111.11100000 or
255.255.255.224 or /27

Pick

one of these new sub-subnets for Network B:


10000000 /27 = Network B

Use

the remaining sub-subnet for future growth, or you


can break it down further if needed.

You want to make sure the addresses are not


overlapping with each other. So go back to the
original table.

You can now break the .128/26 network into two


smaller /27 networks and assign Network B.

Step 4 Pick the Third Largest


Network to Work With
Networks

C and Network D = 12
hosts each
Determine the number of H bits
needed for these networks:
2H 2 12
H=4

You

need 4 H bits to satisfy the


requirements of Network C and Network D.
You started with a pattern of 2 N bits and 6
H bits for Network A. You have to maintain
that pattern.
You now have a choice as to where to put
these networks.
You could go to a different /26 network, or
you could go to a /27 network and try to fit
them into there.

For

the purposes of this example, select the other /


27 network.160/27:

10100000 (The 1 in the third bit place is


no longer bold, because it is part of the N bits.)
But

you only need 4 H bits, not 5. Therefore, you are


left with 101N0000

Where:

10 represents the original pattern of subnetting.


N represents the extra bit you have.
00000 represents the 5 H bits you need for
Network B.

Because

you have this extra bit, you


can create two smaller subnets from
the original subnet:
10100000

10110000
Converted to decimal, these subnets
are as follows:
10100000 = .160
10110000 = .176

These

new sub-subnets will now have new


subnet masks. Each sub-subnet now has 4
N bits and 4 H bits, so their new masks will
be

11111111.11111111.11111111.11110000
or
255.255.255.240
or
/28

Pick one of these new subsubnets for Network C and one for
Network D

Step 5 Determine Network


Numbers for Serial Links
All

serial links between routers have the


same property in that they only need
two addresses in a networkone for
each router interface.
Determine the number of H bits needed
for these networks:
2H 2 2
H=2

You

need 2 H bits to satisfy the


requirements of Networks E, F, G, and H.
You have two of the original subnets left
to work with.
For the purposes of this example, select
the .0/26 network:
00000000

But

you need only 2 H bits, not 6. Therefore, you are left with

00NNNN00
where

00 represents the original pattern of subnetting.


NNNN represents the extra bits you have.
00 represents the 2 H bits you need for the serial links.
Because

you have 4 N bits, you can create 16 sub-subnets from


the original subnet:

00000000

= .0/30

00000100

= .4/30

00001000

= .8/30

Vous aimerez peut-être aussi