You are on page 1of 39

5/24/2011

IP Subnetting

How to Subnet

5/24/2011

In this lesson we will cover:


Given a scenario, evaluate the proper use of
the following addressing technologies and
addressing schemes
Network+ 2009 1.4

What we will cover


Addressing Technologies
How to Subnet Quickly and Easily
CIDR and Supernetting

5/24/2011

Why a Subnet Mask?


One solution to the IP address shortage
Formalized in 1985 (RFC 950)
Subnet Mask breaks a single class A, B or C
network in to smaller pieces
Logically structure your network

Class C Network 192.168.20.0/24


192.168. 20.0
255.255.255.0

OR 192.168.20.0/24

Convert Address to Binary

192 .
168 . 20
.
0
1100000.10101000.00010100.00000000
1111111.11111111.11111111.00000000
Host part of address
Network part of address
Default Class C
subnet mask

Count
256

00000000 = 0
.
.
111111111 = 255

5/24/2011

Subnet Mask Values


Bits Borrowed
1

Bit Weight
128

64

32

16

Decimal Value

128

192

224

240

248

252

254

255

Benefits of Subnetworks
Smaller networks are
easier to manage.

Overall traffic is reduced.


You can more easily
apply network security
policies.

5/24/2011

What is subnetting?
Network

Network

172

16

Network

Network

Host

Host

Subnet

Host

Subnetting is the process of borrowing bits from the host bits, in


order to divide the network into smaller subnets

Subnetting does NOT give you more


host IP addresses
Network

Network

172

16

Network

Network

Host

Host

Subnet

Host

You lose two host IP Addresses for each subnet


One for the subnet IP address and one for the subnet broadcast
IP address

5/24/2011

Subnetting is like dividing up a basket


of fruit

64

64

64

64
256 fruit
00000000 = 0
.
.
111111111 = 255

64 x 4 = 256
256

However, with subnetting, two address


cannot be used for host, in each
subnet
64 - 2 = 62

64 - 2 = 62

64 - 2 = 62

64 - 2 = 62
256 - 2 = 254

00000000 = 0
.
.
111111111 = 255

248

Reserved Addresses where:


All host bits are zero
All host bits are one

5/24/2011

A Simple Subnetted Network


172.16.2.200

172.16.3.5
IP: 172.16.2.1
E0

172.16.2.2

E1
IP: 172.16.3.1

172.16.2.160

172.16.3.100

172.16.3.150

172.16. 2 . 160

172.16. 3 . 100

Network Subnet Host

Network Subnet

Host

Subnets in a class B network


172.16.3.0
172.16.4.0

172.16.2.0

172.16.1.0
172.16.0.0

172.16. 2 . 160

The Internet

Network Subnet Host

5/24/2011

How many subnets do we get when


we borrow bits
Bits
Borrowed

# of Subnets in
powers of 2

Subnets

0, 1

21

00, 01,10, 11

22

000, 001, 010, 011, 100,


101, 110, 111

23

0000, 0001, 0010, 0011,


0100, 0101, 0110, 0111,
1000, 1001, 1010, 1011,
1100, 1101, 1110, 1111

24

16

Values

Borrowing one host bit will give us two


subnets
Subnets

Hosts

Dec.

128

64

32

16

127

Start from zero, count up until all the host bits


are one That will be the end of the first
subnet

5/24/2011

Borrowing one host bit will give us two


subnets
Subnets

Hosts

Dec.

128

64

32

16

127

128

255

When we count up one more the host bits reset to zero and the subnet
bit changes to one.
That is the start of the second subnet
Continue counting until the host bits are all ones.
That is the end of the second subnet

Borrowing two host bits will give us


four subnets
Dec.

128

64

32

16

63

64

127

128

191

192

255

5/24/2011

My Company

Management

Sales

Accounts

Manufacturing

We use the 192.168.10.0/24 Network


We want to put each department in its own
subnetwork

Class C network 192.168.10.0/24.


Borrowing 2 bits will give 4 Subnets
Original SN Mask:

11111111.11111111.11111111.00000000

New SN Mask:

11111111.11111111.11111111.11000000

1. 192.168.10.00000000 = 192.168.10.0
2. 192.168.10.01000000 = 192.168.10.64

Bit
borrowed

3. 192.168.10.10000000 = 192.168.10.128
4. 192.168.10.11000000 = 192.168.10.192

10

5/24/2011

Finding the Decimal equivalent for


each Subnet
192.168.10.00000000
192.168.10.0
192.168.10.01000000
192.168.10.64
192.168.10.10000000
192.168.10.128
192.168.10.11000000
192.168.10.192

1
2
8

6
4

3
2

1
6

1
0

1
0

SUBNETTING ANY NETWORK

11

5/24/2011

Table of Converting Binary to Decimal


Bit
Position

Power

27

26

25

24

23

22

21

20

Decimal
Value

128

64

32

16

Bits Available for Subnetting


Class A: 11111111.00000000. 00000000. 00000000
Available for Subnetting

Class B: 11111111.11111111. 00000000. 00000000


Available for Subnetting

Class C: 11111111. 11111111. 11111111. 00000000


Available for Subnetting

12

5/24/2011

Subnetting Class C
Class C Network 192.168.10.0
11000000.10101000.00001010.00000000
N .
N
.
N
.
H
11111111.11111111.11111111.00000000
255

255

255

. 224

11111111 . 11111111 . 11111111 . 11100000


Host Field

Subnet Field

Three bits borrowed from the Host field and used to


designate the Subnet
We will get 8 (23 subnets)

Subnetting Class B
Class B Network 147.10.0.0
10010011.00001010.00000000.00000000
N .
N
.
H
.
H
11111111.11111111.00000000.00000000
255

255

248

11111111 . 11111111 . 11111000 . 00000000


Subnet Field

Host Field

Five bits borrowed from the Host field and used to designate the
Subnet
We will get 32 (25 subnets)

13

5/24/2011

Subnetting Class A
Class A Network 28.0.0.0
00011100. 00000000.00000000.00000000
N .
H
.
H
.
H
11111111.00000000.00000000.00000000
255

255

240

11111111 . 11111111 . 11110000 . 00000000


Subnet Field

Host Field

Twelve bits borrowed from the Host field and used to designate
the Subnet
We will get 4096 (212 subnets)

Previously the use of the first and last


subnets were discouraged
Called IP subnet zero
Only 2n 2 subnets will be obtained
Subnetwork # Subnetwork ID

Host Range

Broadcast ID

192.168.10.0

.0 - .30

192.168.10.31

192.168.10.32

.33 - .62

192.168.10.63

192.168.10.64

.35 - .64

192.168.10.95

192.168.10.96

.97 - .126

192.168.10.127

192.168.10.128

.129 - .158

192.168.10.159

192.168.10.160

.161 - .190

192.168.10.191

192.168.10.192

.193 - .222

192.168.10.223

192.168.10.224

.225 - .254

192.168.10.255

14

5/24/2011

By default, now, all subnets are used


All subnets will be used
2n subnets will be obtained
Default mode

Subnetwork # Subnetwork ID

Host Range

Broadcast ID

192.168.10.0

.1 - .30

192.168.10.31

192.168.10.32

.33 - .62

192.168.10.63

192.168.10.64

.65 - .94

192.168.10.95

192.168.10.96

.97 - .126

192.168.10.127

192.168.10.128

.129 - .158

192.168.10.159

192.168.10.160

.161 - .190

192.168.10.191

192.168.10.192

.193 - .222

192.168.10.223

192.168.10.224

.225 - .254

192.168.10.255

The Number of Subnets we get from


borrowing n host bits

Where n is the number of Ones (1s) in the


subnet mask.
Note: use 2n 2 if no ip subnet-zero is set not
using first and last subnet

15

5/24/2011

How many hosts per subnet?


h

2 -2
Where h is the number of Zeros (0s) in the
subnet mask.

Determining the Subnet Number


Finding the Subnetwork
Packet Address

201.10.11.85

11001001.00001010.00001011.010 10101
Logical AND

Subnet Mask

255.255.255.224

11111111.11111111.11111111.111 00000

Subnetwork ID

201.10.11.64

11001001.00001010.00001011.010 00000

ANDing
0

AND

AND

AND

AND

16

5/24/2011

Planning IP Addressing Scheme


1.

Determine the number of required network IDs:

2.

Determine the number of required host IDs per subnet:

3.

One for each subnet


One for each wide area network connection

One for each TCP/IP host


One for each router interface

Based on the above requirements, create the following:

One subnet mask for your entire network


A unique subnet ID for each physical segment
A range of host IDs for each subnet

Quick and Easy Subnetting

17

5/24/2011

Five Easy Questions


1. How many subnets does the chosen subnet
mask produce?
2. How many valid hosts per subnet are
available?
3. What are the valid subnets?
4. Whats the broadcast address of each
subnet?
5. What are the valid hosts in each subnet?

How many subnets?

Where n is the number of Ones (1s) in


the subnet mask.
n
Note: use 2 2 if no ip subnet-zero is
set not using first and last subnet

18

5/24/2011

How many hosts per subnet?

2 -2
Where h is the number of Zeros
(0s) in the subnet mask.

What are the valid subnets?


256 minus interesting octet value = block size, or
increment number.
Also equal to 2h where h is the number of host
bits, in the interesting octet
Count from zero in block-size until you reach the
subnet mask value and these are your subnets.
e.g. subnet mask 224
256 224 = 32
Valid subnets will be 0, 32, 64, 96, 128, 160, 192,
224

19

5/24/2011

Whats the broadcast address for each subnet?

Real easy
Based on the valid subnets obtained -- the
broadcast address is always the number right
before the next subnet.

What are the valid hosts?


Numbers between the subnets
First valid host number after subnet address
Last valid host number before broadcast
address

20

5/24/2011

FINDING THE SUBNET ADDRESS OF


192.168.173.237/29

Calculate the Subnet Address


IP Address

192
00001010

168
00010100

173
10101101

237
11101101

255
11111111

248
11111000

173
10101101

232
11101000

LOGICAL AND

Subnet
Mask

255
11111111

255
11111111
RESULT

Subnet
Address

192
00001010

168
00010100

21

5/24/2011

Another method to find subnet


address
1. 192.168.173.237/29

9. 192.168.173.237

2. Class? C

10. Divide interesting octet by block size

3. Default Subnet Mask?: 255.255.255.0 11. 237 / 8 = 29.625


or /24
12. Ignore decimal = 29
4. Bits borrowed?: 5
13. Multiply value by block size
5. Current subnet mask:
29 x 8 = 232
255.255.255.248
14. Subnet address is:
6. Block size: 256 -248 = 8
192.168.173.232
7. To find subnet address:
8. Determine Interesting octet

Determining How Many Bits to Borrow

Network address: 192.168.10.0


Subnets needed: Six
Bits to borrow: 128 64 32 16 8 4 2 1
Borrowing three bits for the subnet will fit the requirements:

Three subnet bits: 23 = 8 subnets


Five bits remain for host: 25 2 = 30 hosts per subnet
Default Class C mask: 11111111.11111111.11111111.00000000
Modified Class C mask: 11111111.11111111.11111111.11100000
Required Subnet in dotted-decimal notation = 255.255.255.224

22

5/24/2011

Determining the Subnet and Host Addresses


Network
Mask
Subnet
0

192

168

10

255

255

255

224

11111111

11111111

11111111

11100000

Octet
1

Octet
2

Octet
3

Octet
4

First
Host

Last
Host

Directed
Broadcast

192

168

10

30

31

11000000

10101000

00001010

00000000

00000001

00011110

00011111

192

168

10

32

33

62

63

11000000

10101000

00001010

00100000

00100001

00111110

00111111

192

168

10

64

65

94

95

11000000

10101000

00001010

01000000

01000001

01011110

01011111

192

168

10

96

97

126

127

11000000

10101000

00001010

01100000

01100001

01111110

01111111

Determining the Subnet and Host Addresses (cont.)

Subnet

Octet
1

Octet
2

Octet
3

Network
Address

First
Host

Last
Host

Directed
Broadcast

192

168

10

128

129

158

159

11000000

10101000

00001010

10000000

10000001

10011110

10011111

192

168

10

160

161

190

191

11000000

10101000

00001010

10100000

10100001

10111110

10111111

192

168

10

192

193

222

223

11000000

10101000

00001010

11000000

11000001

11011110

11011111

192

168

10

224

225

254

255

11000000

10101000

00001010

11100000

11100001

11111110

11111111

23

5/24/2011

Question
What is the subnet for the host IP address
201.100.5.68/28?

Question
How many subnetworks and hosts are
available per subnet if you apply a /28 mask to
the 210.10.2.0 class C network?

24

5/24/2011

Classless Inter-domain Routing


(CIDR)

CIDR
RFC 4632 (2006) Obsoletes RFC 1519 (1993)
Slow the growth of global routing tables
Reduce the rate of consumption of IPv4
address space.
Replace the Class A/B/C Classfull) network
address assignment system
With Classless", hierarchical blocks of IP
addresses (referred to as prefixes)

25

5/24/2011

CIDR Address Strategy


Notation
n.n.n.n/32
n.n.n.x/31
n.n.n.x/30
n.n.n.x/28
n.n.n.0/24
n.n.x.0/21
n.n.0.0/16
n.x.0.0/12
n.0.0.0/8
x.0.0.0/4
0.0.0.0/0

Addrs/
Block
1
2
2
16
256
2048
65536
1048576
16777216
268435456
4294967296

# Blocks
4294967296
2147483648
2147483648
268435456
16777216
2097152
65536
4096
256
16
1

Host route
P2P link
Legacy P2P link
Legacy Class C
Legacy Class B

Legacy Class A
Default route

Classless Internet Domain Routing


Subnet Mask

CIDR

0.0.0.0

/0

128.0.0.0

/1

192.0.0.0

/2

224.0.0.0

/3

240.0.0.0

/4

248.0.0.0

/5

252.0.0.0

/6

254.0.0.0

/7

255.0.0.0

/8

26

5/24/2011

Classless Internet Domain Routing


Subnet Mask

CIDR

255.128.0.0

/9

255.192.0.0

/10

255.224.0.0

/11

255.240.0.0

/12

255.248.0.0

/13

255.252.0.0

/14

255.254.0.0

/15

255.255.0.0

/16

Classless Internet Domain Routing


Subnet Mask

CIDR

255.255.128.0

/17

255.255.192.0

/18

255.255.224.0

/19

255.255.240.0

/20

255.255.248.0

/21

255.255.252.0

/22

255.255.254.0

/23

255.255.255.0

/24

27

5/24/2011

Classless Internet Domain Routing


Subnet Mask

CIDR

255.255.255.128

/25

255.255.255.192

/26

255.255.255.224

/27

255.255.255.240

/28

255.255.255.248

/29

255.255.255.252

/30

255.255.255.254

/31

255.255.255.255

/32

VARIABLE-LENGTH
SUBNET MASKS

28

5/24/2011

Variable-Length
Subnet Masks (VLSM) vs. Classless
Inter-domain Routing (CIDR)
VLSM focus on
within an
Organization

CIDR focus is
the Internet

What Is a Variable-Length
Subnet Mask?
Subnet 172.16.14.0/24 is divided into smaller
subnets:
Subnet with one mask (/27)
Then further subnet one of the unused /27 subnets
into multiple /30 subnets

29

5/24/2011

Calculating VLSMs

A Working VLSM Example

30

5/24/2011

What Is Route
Summarization?
Routing protocols can summarize addresses of
several networks into one address

Summarizing Within an Octet

31

5/24/2011

Supernetting Summarizing Within an


Octet
192.168.16.0/24 = 11000000.10101000.000100 00.00000000
192.168.17.0/24 = 11000000.10101000.000100 01.00000000
192.168.18.0/24 = 11000000.10101000.000100 10.00000000
192.168.19.0/24 = 11000000.10101000.000100 11.00000000

Number of Common Bits = 22

Non-Common Bits = 10

192.168.16.0 /22

Supernetting Summarizing Within an


Octet
192.168.16.0/24 = 11000000.10101000.00010 000.00000000
192.168.17.0/24 = 11000000.10101000.00010 001.00000000
192.168.18.0/24 = 11000000.10101000.00010 010.00000000
192.168.19.0/24 = 11000000.10101000.00010 011.00000000
192.168.20.0/24 = 11000000.10101000.00010 100.00000000
192.168.21.0/24 = 11000000.10101000.00010 101.00000000
192.168.22.0/24 = 11000000.10101000.00010 110.00000000
192.168.23.0/24 = 11000000.10101000.00010 111.00000000
Number of Common Bits = 21

Non-Common Bits = 11

192.168.16.0 /21

32

5/24/2011

Summarizing Addresses in a VLSMDesigned Network


172.16.128.0 - 172.16.143.255

172.16.64.0 - 172.16.79.255

Implementation Considerations
Multiple IP addresses must have the same
highest-order bits.
Routing decisions are made based on the entire
address.
Routing protocols must carry the prefix (subnet
mask) length.

33

5/24/2011

Route Summarization Operation


Supports host-specific routes, blocks of networks,
default routes
Routers use the longest match
192.16.5.33
192.16.5.32
192.16.5.0
192.16.0.0
0.0.0.0

/32
/27
/24
/16
/0

Host
Subnet
Network
Block of Networks
Default

Summarizing Routes in a
Discontiguous Network

RIPv1 and IGRP do not advertise subnets, and therefore


cannot support discontiguous subnets.
OSPF, EIGRP, and RIPv2 can advertise subnets, and
therefore can support discontiguous subnets.

34

5/24/2011

VLSM EXAMPLE

VLSM Example
Your company has been assigned IP network 195.39.71.0 /24. Given that
headquarters (60 hosts) is connected to five branch offices (12 hosts each)
by a WAN link, and to an ISP (the ISP owns the addresses on that link),
determine an appropriate IP addressing scheme.

Headquarters
ISP

60 users

Branch 1
12 users

Branch 2
12 users

Branch 3
12 users

Branch 4
12 users

Branch 5
12 users

35

5/24/2011

Given the IP address


195.39.71.0 /24, subnet
according to the largest
subnet needed.
(Headquarters 60 hosts)

You would need to borrow


2 bits or /26. This would
give you 4 networks with
64 host addresses on each
subnet.

128

63

191
192

64

255

127

We will start at the first


subnet (subnet 0).

128
Headquarters
60 hosts

We will start addressing


with 195.39.71.0 /26.
Headquarters needs 60
hosts, so we will assign
them .0 - .63

26 bit mask or /26


(255.255.255.192)

64

192

36

5/24/2011

The 5 Branch offices


only need 12 hosts
each.

128
Headquarters
60 hosts

We will use the block


.128 - .191 block (64
addresses). Here we
will apply VLSM.

26 bit mask or /26


(255.255.255.192)

160

Branch 1
12 hosts
/28

Branch 3
12 hosts
/28

(255.255.255.240) (255.255.255.240)

144

176

Branch 2
12 hosts
/28

Branch 4
12 hosts
/28

(255.255.255.240) (255.255.255.240)

192

64

Using a /28 mask will


give us 14 hosts at
each location. This
will take care of 4 of
the Branch offices.

To obtain a block for


Branch 5, we will need
to subnet the .192 .255 block using a /28
mask.

128
Headquarters
60 hosts

26 bit mask or /26


(255.255.255.192)

Branch 1
12 hosts
/28

160
Branch 3
12 hosts
/28

(255.255.255.240) (255.255.255.240)

144
Branch 2
12 hosts
/28

176
Branch 4
12 hosts
/28

(255.255.255.240) (255.255.255.240)

64

192

224

Branch 5
12 hosts
/28
(255.255.255.240)

208

37

5/24/2011

Now we need to
address the 5 WAN
links that connect to
the Branch offices.
These are point-topoint connections and
only require 2
addresses.

128
Headquarters
60 hosts
26 bit mask or /26
(255.255.255.192)

144

176
Branch 4
12 hosts
/28

Branch 2
12 hosts
/28

(255.255.255.240) (255.255.255.240)

192

64

Branch 5
12 hosts
/28

208

Here we will use a /30


mask to further subnet
the subnets.

Subnet 0 could also


be further
subnetted according
to the needs of the
network.

Branch 3
12 hosts

/28
(255.255.255.240) (255.255.255.240)

(255.255.255.240)

The remaining
networks could be
used for future
growth of either
LANs or WANs.

160

Branch 1
12 hosts
/28

232
224
WAN
WAN
1

228
WAN
2

236

WAN
4

240
248
WAN
5

244

128
Headquarters

60 hosts
26 bit mask or /26
(255.255.255.192)

Branch 1
12 hosts
/28

160
Branch 3
12 hosts
/28

(255.255.255.240) (255.255.255.240)

144
Branch 2
12 hosts
/28

176
Branch 4
12 hosts
/28

(255.255.255.240) (255.255.255.240)

64

192
Branch 5
12 hosts
/28
(255.255.255.240)

208

224
WAN
1

228
WAN
2

232
WAN
3

236

WAN
4

240
248
WAN
5

244

38

5/24/2011

Applying the Addresses to the Topology


Address
provided by ISP

195.39.71.0 /26

195.39.71.128 /28

195.39.71.144 /28

195.39.71.160 /28

195.39.71.176 /28

195.39.71.192 /28

39