Sie sind auf Seite 1von 13

HOME

COMPTIA

CAREERS

WINDOW

LINUX

CISCO

TIPS AND TRICKS

NETWORKING

Youarehere: Home // Cisco // CCNAStudyGuide640802 // SubnettingSupernettingandVLSM //


SubnettingTutorialWithExamples

Subnetting Tutorial With Examples


Subnetting is a process of dividing large network into the smaller networks based on layer 3 IP address.
Every computer on network has an IP address that represent its location on network. Two version of IP
addressesareavailableIPv4andIPv6.InthisarticlewewillperformsubnettingonIPv4.

IPv4
IPaddressesaredisplayedindotteddecimalnotation,andappearasfournumbersseparatedbydots.Each
numberofanIPaddressismadefromeightindividualbitsknownasoctet.Eachoctetcancreatenumber
value from 0 to 255. An IP address would be 32 bits long in binary divided into the two components,
networkcomponentandhostcomponent.Networkcomponentisusedtoidentifythenetworkthatthepacket
isintendfor,andhostcomponentisusedtoidentifytheindividualhostonnetwork.
IPaddressesarebrokenintothetwocomponents:
Networkcomponent:Definesnetworksegmentofdevice.
Hostcomponent:Definesthespecificdeviceonaparticularnetworksegment

IPClassesindecimalnotation






0[Zero]isreservedandrepresentsallIPaddresses.
127isareservedaddressandisusedfortesting,likealoopbackonaninterface.
255isareservedaddressandisusedforbroadcastingpurposes.

Subnetmask
Subnetmaskisa32bitslongaddressusedtodistinguishbetweennetworkaddressandhostaddressinIP
address. Subnet mask is always used with IP address. Subnet mask has only one purpose, to indentify
whichpartofanIPaddressisnetworkaddressandwhichpartishostaddress.
ForexamplehowwillwefigureoutnetworkpartitionandhostpartitionfromIPaddress192.168.1.10?Here
weneedsubnetmasktogetdetailsaboutnetworkaddressandhostaddress.
Indecimalnotationsubnetmaskvalue1to255representnetworkaddressandvalue0[Zero]
representhostaddress.
Inbinarynotationsubnetmaskonbit[1]representnetworkaddresswhileoffbit[0]representhost

address.
Indecimalnotation

 


Networkaddressis192.168.1andhostaddressis10.
Inbinarynotation

 


Networkaddressis11000000.10101000.00000001andhostaddressis00001010

IPClass

DefaultSubnet

Networkbits

Hostbits

Totalhosts

Validhosts

255.0.0.0

First8bits

Last24bits

16,777,216

16,777,214

255.255.0.0

First16bits

Last16bits

65,536

65,534

255.255.255.0

First24bits

Last8bits

256

254

NetworkID
First address of subnet is called network ID. This address is used to identify one segment or broadcast
domainfromalltheothersegmentsinthenetwork.

BlockSize
Blocksizeisthesizeofsubnetincludingnetworkaddress,hostsaddressesandbroadcastaddress.

BroadcastID
Therearetwotypesofbroadcast,directbroadcastandfullbroadcast.
Directbroadcastorlocalbroadcastisthelastaddressofsubnetandcanbehearbyallhostsinsubnet.
FullbroadcastisthelastaddressofIPclassesandcanbehearbyallIPhostsinnetwork.Fullbroadcast
addressis255.255.255.255
The main difference between direct broadcast and full broadcast is that routers will not propagate local
broadcastsbetweensegments,buttheywillpropagatedirectedbroadcasts.

HostAddresses
Alladdressbetweenthenetworkaddressandthedirectedbroadcastaddressiscalledhost address for the
subnet.YoucanassignhostaddressestoanyIPdevicessuchasPCs,servers,routers,andswitches.

Subnetting
Subnettingisaprocessofbreakinglargenetworkinsmallnetworksknownassubnets.Subnettinghappens
when we extend default boundary of subnet mask. Basically we borrow host bits to create networks. Let's
takeaexample
Beinganetworkadministratoryouareaskedtocreatetwonetworks,eachwillhost30systems.
Single class C IP range can fulfill this requirement, still you have to purchase 2 class C IP range, one for
each.SingleclassCrangeprovides256totaladdressesandweneedonly30addresses,thiswillwaste226
addresses.Theseunusedaddresseswouldmakeadditionalrouteadvertisementsslowingdownthenetwork.
WithsubnettingyouonlyneedtopurchasesinglerangeofclassC.Youcanconfigureroutertotakefirst26
bits instead of default 24 bits as network bits. In this case we would extend default boundary of subnet
maskandborrow2hostbitstocreatenetworks.Bytakingtwobitsfromthehostrangeandcountingthem
as network bits, we can create two new subnets, and assign hosts them. As long as the two new network
bitsmatchintheaddress,thentheaddressbelongstothesamenetwork.Youcanchangeeitherofthetwo
bits,andyouwouldbeinanewsubnet.

AdvantageofSubnetting
Subnettingbreakslargenetworkinsmallernetworksandsmallernetworksareeasiertomanage.
Subnettingreducesnetworktrafficbyremovingcollisionandbroadcasttraffic,thatoverallimprove
performance.
Subnettingallowsyoutoapplynetworksecuritypolicesattheinterconnectionbetweensubnets.
SubnettingallowsyoutosavemoneybyreducingrequirementforIPrange.

Subnettingmath
Subnetting process involves binary math calculation. Computers communicate with each others in binary
language. To succeed in any kind of networking career, you might be fluent in binary math calculation.
Subnettingneedstwotypeofcalculation,convertdecimaltobinaryandconvertbinarytodecimal.
Binarysystemworksexactlysameasdecimalsystem,exceptthebasenumber.Basenumberis2inbinary
system and 10 in decimal system. To calculate decimal equivalent value of a binary number, you have to
replacebasevalue10with2.Binarynumbersaredisplayedincolumnsandeachpositioninbinarysystem
hasdoublevaluethanthepositioninright.Fromearliersectionofthisarticleyouknowthateachnumberof
an IP address is made from eight individual bits known as octet. So you should remember at least eight
decimalequivalentvaluefrombinaryposition.
Baseposition

27

26

25

24

23

22

21

20

Decimalvalue

128

64

32

16

Convertdecimaltobinary
To convert a decimal number in binary we would use addition till number method. In this method we start
adding from left to get target value. If after adding right position value, sum is lower than target number,
keepadding,orifsumisgreaterthantargetnumberskipthepositionvalue.Onlythevalueofonbit[1]will
beaddedinsum.Offbit[0]haszerovalue.Forexample,convertdecimalnumber117inbinary.
Targetdecimalnumber117
MovedirectionFromLeft===========================>toRight
Baseposition

27

26

25

24

23

22

21

20

Decimalvalue

128

64

32

16

Bitstatus

Decimalvalueinaddition

64

32

16

Binaryvalueof117is01110101.
Decimalcalculation

Bitinbinary

128isgreaterthan117

offthebit

0+64=64islessthan117

onthebit

0+64+32=96islessthan117

onthebit

0+64+32+16=112islessthan117

onthebit

0+64+32+16+8=120isgreaterthan117

offthebit

0+64+32+16+0+4=116islessthan117

onthebit

0+64+32+16+0+4+2=118isgreaterthan117

offthebit

0+64+32+16+0+4+0+1=117isequivalentto117

onthebit

Convertbinaryindecimal
Toconvertabinaryindecimalwewillfollowabovemethodinreversemode.Wewillfindthedecimalvalue
ofonbinarybitpositionandaddthem.Forexampleconvert10101010binarynumberindecimal.
Targetbinarynumber10101010
MovedirectionFromLeft===========================>toRight
Baseposition

27

26

25

24

23

22

21

20

Decimalvalue

128

64

32

16

Bitstatus

Decimalvalueinaddition

128

32

Decimalvalueof10101010is170[128+0+32+0+8+0+2+0]
Binarybit

Decimalvalue

1Onbit

128

0Offbit

1Onbit

64

0Offbit

1Onbit

32

0Offbit

1Onbit

0Offbit

1Onbit

0Offbit

Reviewabovemethodanddoasmuchpracticeoffollowingasyoucan.
Pickanynumberfrom0255andconvertitinbinary.
Pickanycombinationfrom0000000011111111andconvertitindecimal.
Betteryouarewiththisconversion,thebetteryouwilldoonthesubnetting.

Combinationprovidedbybinaryposition
Nowyouknowtheprocessofconvertingbinaryindecimalanddecimalinbinary.Ournextstepistofigure
outthecombinationprovidedbyabinaryposition.
Firstbitprovidetwocombination0or1.Ifwetaketwobitsthanwehavefourcombinations00,01,10,11.IP
addresshas32bits,soyoushouldbeabletofindthenumberofcombinationsprovidedbyeachbitposition
untilpositionnumber32.
Numberofbit[s]

Numberofcombinations

Numberofbits

Numberofcombinations

17

131072

18

262144

19

524288

16

20

1048576

32

21

2097152

64

22

4194304

128

23

8388608

256

24

16777216

512

25

33554432

10

1024

26

67108864

11

2048

27

134217728

12

4096

28

268435456

13

8192

29

536870912

14

16384

30

1073741824

15

32768

31

2147483648

16

65536

32

4294967296

Defaultsubnetmask
Class

SubnetMask

Format

255.0.0.0

Network.Host.Host.Host

255.255.0.0

Network.Network.Host.Host

255.255.255.0

Network.Network.Network.Host

Keytermstoremembers
Asubnetisasmallerportionoflargenetworktreatedasitsownseparatenetwork.Tocreatesubnet
weborrowbitsfromhostportionandassignthemasnetworkbits.Thismeanmorenetworks,fewer
hosts.
Ifthenetworkbitsontwoaddressesdonotmatch,thenthetwopacketsareintendedfortwo
separatenetworks.
Ona32bitsIPaddressatleasteightbitsmustbelongtothenetworkportionandatleast2bitsmust
belongtothehostportion.
EachIPaddresshasapredefinedIPclassandthatcannotbechanged.
Eachclasshasapredefineddefaultsubnetmaskthattellustheoctets,whicharealreadypartofthe
networkportion,aswellashowmanybitswehaveavailabletoworkwith.
Whatevernetworkclassisit,wecannotchangethosebitsthatarealreadyassigned.
WecannotassignthenetworkIDandthebroadcastaddresstoahost.
Regardlesshowmanybitsareleftinthehostfield,networkIDandthebroadcastaddressmustbe
reserved.
Subnetbitsstartattheleftandgototheright,withoutskippingbits.

CIDR[ClasslessInterDomainRouting]
CIDRisaslashnotationofsubnetmask.CIDRtellsusnumberofonbitsinanetworkaddress.

ClassAhasdefaultsubnetmask255.0.0.0.thatmeansfirstoctetofthesubnetmaskhasallonbits.
Inslashnotationitwouldbewrittenas/8,meansaddresshas8bitson.
ClassBhasdefaultsubnetmask255.255.0.0.thatmeansfirsttwooctetsofthesubnetmaskhave
allonbits.Inslashnotationitwouldbewrittenas/16,meansaddresshas16bitson.
ClassChasdefaultsubnetmask255.255.255.0.thatmeansfirstthreeoctetsofthesubnetmask
haveallonbits.Inslashnotationitwouldbewrittenas/24,meansaddresshas24bitson.

Method of subnetting
Insubnettingwefindtheansweroffollowingquestions.
Whatissubnetmaskforgivenaddress?
Howmanysubnetsdoesgivensubnetmaskprovide?
Whatisblocksizeforgivensubnetmask?
Whatarethevalidsubnets?
Whatarethetotalhosts?
Howmanyvalidhostsareavailablepersubnet?
Whatisbroadcastaddressofeachsubnet?
Whatisnetworkaddressofeachsubnet?
Toanswerabovequestionsweusefollowingmethodofsubnetting.
Whatissubnetmaskforgivenaddress?
Subnetting take places when we extend the default subnet mask. We cannot perform subnetting with
defaultsubnetmaskandeveryclasseshavedefaultsubnetmask.Tofigureoutsubnettedsubnetmask,we
first need to write down the default subnet mask. Now find the host bits borrowed to create subnets and
convert them in decimal. For example find the subnet mask of address 188.25.45.48/20 ? This address
belongtoclassBandclassBhasdefaultsubnetmask255.255.0.0[/16inCIDR].Weborrowed4bitsfrom
hosts portion. As you know subnetting move from left to right and it cannot skip any network bit. So this
subnet mask in binary would be 11111111. 11111111.11110000.00000000. First two octet have default
value so its decimal value would be 255.255. We will convert third octet in decimal value. To convert a
binary number in decimal we add its decimal equivalent value. In our example it would be
128+64+32+16+0+0+0+0 = 240. Our fourth octet has all bits off so its decimal value would be
0+0+0+0+0+0+0+0=0.Ouranswersubnetmaskwouldbe255.255.240.0
Howmanysubnetsdoesgivensubnetmaskprovide?
Tocalculatethenumberofsubnetsprovidedbygivensubnetmaskweuse2N , where N = number of bits
borrowedfromhostbitstocreatesubnets.Forexamplein192.168.1.0/27,Nis3.Bylookingataddresswe
can determined that this address is belong to class C and class C has default subnet mask 255.255.255.0
[/24 in CIDR]. In given address we borrowed 27 24 = 3 host bits to create subnets. Now 23 = 8, so our
answeris8.
Whatisblocksizeforsubnetmask?
Block size or increment number is used to calculate the valid subnets. Once you figure out the block size,
calculation of valid subnets become pieces of cake. To figure out the block size, use this formula 256
Subnetmask=blocksize.Forexampleblocksizeforsubnetmask255.255.255.240is256240=16.
Whatarethevalidsubnets?
Calculating valid subnet is two steps process. First calculate total subnet by using formula 2N. In second
step find the block size and count from zero in block until you reach the subnet mask value. For example
calculatethevalidsubnetsfor192.168.1.0/26.
Borrowedhostbitsare2[2624].

Totalsubnetsare22=4.
Subnetmaskwouldbe255.255.255.192.
Blocksizewouldbe256192=64.
Startcountingfromzeroatblocksof64,soourvalidsubnetswouldbe0,64,128,192.
Whatarethetotalhosts?
Total hosts are the hosts available per subnet. To calculate total hosts use formula 2H = Total hosts. H is
number host bits. For example in address 192.168.1.0/26 we have 32 26 [Total bits in IP address Bits
consumedbynetworkaddress]=6.Totalhostspersubnetwouldbe26=64.
Howmanyvalidhostsareavailablepersubnet?
Validhostsarethenumberofhoststhosecanbeassignedtodevices.Asweknow,weneedtoreducetwo
address per subnet, one for network ID and another for broadcast ID. So our formula, to calculate valid
hostswouldbeTotalhosts2=Validhosts.Inaboveexamplewehave64hostspersubnet,sovalidhosts
ineachsubnetwouldbe642=62.
Whatisbroadcastaddressofeachsubnet?
Broadcastaddressisthelastaddressofsubnet.Thisaddressisreservefornetworkbroadcast,andcannot
beassignedtoanyhost.Inaboveexample
0Subnethasbroadcastaddress63
64Subnethasbroadcastaddress127
128Subnethasbroadcastaddress191
192Subnethasbroadcastaddress255
Whatisthenetworkaddressofeachsubnet?
Network address is the first address of subnet. This address is used to locate the network, and cannot be
assignedtoanyhost.Inaboveexampleaddress0,64,128,192arethenetworkaddress.
NetworkaddressisalwaysthefirstIPaddressofsubnet.
BroadcastaddressisalwaysthelastIPaddressofsubnet(IPaddressbeforethenextsubnet).
ValidhostsaretheIPaddressesbetweennetworkaddressandbroadcastaddress.
At this point you have powered with all essential tools for subnetting. In last section of this article we will
practically implement what we have learn so far. Due to length of this article I will include examples only
fromclassC.

ClassCSubnetting
DefaultsubnetmaskofclassCis255.255.255.0.CIDRnotationofclassCis/24,whichmeans24bitsfrom
IPaddressarealreadyconsumedbynetworkportionandwehave8hostbitstoworkwith.Wecannotskip
network bit, when we turned them on. Subnetting moves from left to right. So Class C subnet masks can
onlybethefollowing:
CIDR

Decimal

Binary

/25

128

10000000

/26

192

11000000

/27

224

11100000

/28

240

11110000

/29

248

11111000

/30

252

11111100

Aswehavealreadydiscussedearlierinthisarticlethatwehavetohaveatleast2hostbitsforassigningIP
addressestohosts,thatmeanswecan'tuse/31and/32forsubnetting.
/25
CIDR /25 has subnet mask 255.255.255.128 and 128 is 10000000 in binary. We used one host bit in
networkaddress.

N=1[Numberofhostbitusedinnetwork]
H=7[Remaininghostbits]
Totalsubnets(2N):21=2
Blocksize(256subnetmask):256128=128
Validsubnets(Countblocksfrom0):0,128
Totalhosts(2H):27=128
Validhostspersubnet(Totalhost2):1282=126
Subnets

Subnet1

Subnet2

NetworkID

128

Firsthost

129

Lasthost

126

254

BroadcastID

127

255

/26
CIDR /26 has subnet mask 255.255.255.192 and 192 is 11000000 in binary. We used two host bits in
networkaddress.

N=2
H=6
Totalsubnets(2N):22=4
Blocksize(256subnetmask):256192=64
Validsubnets(Countblocksfrom0):0,64,128,192
Totalhosts(2H):26=64
Validhostspersubnet(Totalhost2):642=62
Subnets

Subnet1

Subnet2

Subnet3

Subnet4

NetworkID

64

128

192

Firsthost

65

129

193

Lasthost

62

126

190

254

BroadcastID

63

127

191

255

/27
CIDR /27 has subnet mask 255.255.255.224 and 224 is 11100000 in binary. We used three host bits in
networkaddress.

N=3
H=5
Totalsubnets(2N):23=8
Blocksize(256subnetmask):256224=32
Validsubnets(Countblocksfrom0):0,32,64,96,128,160,192,224
Totalhosts(2H):25=32
Validhostspersubnet(Totalhost2):322=30

Subnets

Sub1

Sub2

Sub3

Sub4

Sub5

Sub6

Sub7

Sub8

NetworkID

32

64

96

128

160

192

224

Firsthost

33

65

97

129

161

193

225

Lasthost

30

62

94

126

158

190

222

254

BroadcastID

31

63

95

127

159

191

223

255

Sub=Subnet

/28
CIDR /28 has subnet mask 255.255.255.240 and 240 is 11110000 in binary. We used four host bits in
networkaddress.

N=4
H=4
Totalsubnets(2N):24=16
Blocksize(256subnetmask):256240=16
Validsubnets(Countblocksfrom0):0,16,32,48,64,80,96,112,128,144,160,176,192,208,224,240
Totalhosts(2H):24=16
Validhostspersubnet(Totalhost2):162=14
Ihopeyouhaveunderstandthepatternofmakingthesubnetchartwithabove
information's. Let's join me in this practice. For this example and next two
examplesIwillfillonlytwosubnets[firstandlastone],it'syourturntofillthe
middlesubnets.

Subnets

Subnet1

Subnet2ToSubnet15(Filledbyyou)

Subnet16

NetworkID

........................................

240

Firsthost

........................................

241

Lasthost

14

........................................

254

BroadcastID

15

......................................

255

/29
CIDR /29 has subnet mask 255.255.255.248 and 248 is 11111000 in binary. We used five host bits in
networkaddress.

N=5
H=3
Totalsubnets(2N):25=32
Blocksize(256subnetmask):256248=8
Validsubnets(Countblocksfrom0):
0,8,16,24,32,40,48,56,64,72,80,88,96,104,112,120,128,136,144,152,160,168,176,184,192,200,208,216,22
4,232,240,248
Totalhosts(2H):23=8
Validhostspersubnet(Totalhost2):82=6
Subnets

Subnet1

Subnet2ToSubnet31(Filledbyyou)

Subnet32

NetworkID

..........................................

248

Firsthost

..........................................

249

Lasthost

..........................................

254

BroadcastID

.........................................

255

/30
CIDR /30 has subnet mask 255.255.255.252 and 252 is 11111100 in binary. We used six host bits in
networkaddress.

N=6

H=2
Totalsubnets(2N):26=64
Blocksize(256subnetmask):256252=4
Validsubnets(Countblocksfrom0):
0,4,8,12,16,20,24,28,32,36,40,44,48,52,56,60,64,68,72,76,80,84,88,92,96,100,104,108,112,116,120,124,1
28,132,136,140,144,148,152,156,160,164,168,172,176,180,184,188,192,196,200,204,208,212,216,220,224
,228,232,236,240,244,248,252
Totalhosts(2H):22=4
Validhostspersubnet(Totalhost2):42=2
Subnets

Subnet1

Subnet2ToSubnet63(Filledbyyou)

Subnet64

NetworkID

..........................................

252

Firsthost

..........................................

253

Lasthost

..........................................

254

BroadcastID

.........................................

255

At the end of this long article I have a small word for you, that is practice. Believe me in exam you are
goingtofacemanyquestionsrelatedtosubnetting.Morepracticewillmakeyoumorecomfortableinexam.

MoreRelatedArticlesForYou
VLSMTutorialwithExamples
SubnettingTutorialWithExamples

<Prev

Copyright20102016.ComputerNetworkingNotes.com
Advertisewithus Writeforus ContactUs PrivacyPolicy Termsandconditions

Das könnte Ihnen auch gefallen