-: Alright, now that we got those computer mathematics 2 2
under our belt, let's dive into the concept of subnetting. 3 3
Subnetting is where we can take a large network 4 4
and we split it up into smaller networks. 5 5
When we do this, this is all about logical IP addressing. 6 6
The default classful subnet mask 7 7
is rarely going to be the optimal subnet for our subnet size. 8 8
So, instead, we use subnet masks to modify the subnets 9 9
and create networks that are much better in scope. 10 10
For instance, let's say I gave you a network 11 11
of 10 dot something dot something dot something, 12 12
this is a class A address, that means 13 13
there are 16.7 million IP addresses in that range. 14 14
You may have a large network, 15 15
but your network is probably not 16.7 million clients. 16 16
So, we would want to create subnets 17 17
that allow us to borrow bits from the original host portion 18 18
and then we can add them into the network portion 19 19
to make smaller networks for us. 20 20
So, for example, if I had a network like 10.0.0.0/8, 21 21
that is a classful class A subnet, 22 22
and it has 16.7 million hosts. 23 23
But I probably need something like 24 24
a couple of hundred hosts, maybe 256 of them. 25 25
Well, if I wanted to do that, 26 26
I might use the class C subnet mask of slash 24 27 27
and use that, instead. 28 28
By using 10.0.0.0/24, 29 29
that's going to give me 256 IPs in that subnet, 30 30
and that means, those other 16 million 31 31
can be used by other people. 32 32
Then, maybe I'm going to create a second subnet, 33 33
like 10.0.1.0/24, and then I can create a third subnet 34 34
with 10.0.2.0/24, and now I've used three subnets 35 35
of 256 IPs each, and I still have millions of leftover IPs 36 36
that I can subnet out later. 37 37
This is why it's really important to use subnets, 38 38
because it's an efficient use of the IP addresses you have, 39 39
instead of just using the classful default. 40 40
Even in your home network, 41 41
if you're using a class C address 42 42
of something like 192.168.1.0/24, 43 43
this gives you 256 possibilities, 44 44
but you probably only have five or 10 devices 45 45
on your home network. 46 46
Now, by doing subnets, this is going to allow us 47 47
to create additional VLANs in subnets 48 48
and allow separation of our networks for better security 49 49
and giving us better bandwidth control. 50 50
Here on the screen you can see a chart 51 51
that has the addresses for the class A, B, and C subnets 52 52
and their default masks, 53 53
which should be a review for you at this point. 54 54
Now, on the right side, you're going to see 55 55
the assignable number of IP addresses, 56 56
which is for class A, of 16.7 million addresses, 57 57
for class B, 65,000 plus IP addresses, 58 58
and class C, 254 usable IP addresses, 59 59
that is a lot of IP addresses. 60 60
Now, we may want to start nicking those down 61 61
into usable chunks, 62 62
and that is what we're going to use subnetting for. 63 63
If we're using private IPs, this really isn't a big deal, 64 64
because they don't cost me anything. 65 65
But with public IPs, every public IP I paid for, 66 66
and that's money out of my pocket, 67 67
and you want to minimize that 68 68
to only getting the ones you need. 69 69
For example, my ISP charges $5 per month for a static IP. 70 70
If I need one, that's $5, if I need 10, that's $50, 71 71
if I need 100, that's $500, 72 72
and so, that can add up pretty quickly, right? 73 73
By subnetting, it allows me to just get the things 74 74
that I need and the fewer IPs that I need. 75 75
Now, how do we do this? 76 76
Well, that's what we use a subnet mask for. 77 77
We talked about class A, class B, 78 78
and class C default subnet masks 79 79
back when we talked about it before, 80 80
and you'll see those on the screen in red. 81 81
They are the slash eight, slash 16, and slash 24. 82 82
Now, when you convert those to binary, 83 83
you can see that they're filled by all the octets 84 84
with either all ones or all zeros, making them classful. 85 85
Now, the ones on the bottom of the screen, 86 86
from 25 down to slash 30, are going to be smaller subnets. 87 87
These are called classless subnets 88 88
because they're going to use different things 89 89
besides all ones or all zeros in that octet. 90 90
Now, as you can see, we're borrowing bits 91 91
from the host portion and making all those zeros 92 92
and taking some of those by adding them over 93 93
into the network portion, as well. 94 94
And so, this borrowing is what we're doing with subnetting. 95 95
If you don't get it yet, don't worry, 96 96
we are going to dig deeper into it 97 97
as we continue through this lesson. 98 98
Now, let's take a look at some formulas 99 99
that we're going to need to understand for calculating 100 100
the number of subnets and the number of assignable hosts. 101 101
If I'm calculating the number of subnets, 102 102
the formula is two to the s power, 103 103
where s is the number of borrowed bits from the host. 104 104
So, when I start taking those zeros from the host 105 105
and turning them to ones to make them 106 106
be part of the network portion, 107 107
that is the s that we're talking about here. 108 108
For instance, if I'm using a slash 25 as my network, 109 109
I'm borrowing one bit from the host space 110 110
and putting it into the network space. 111 111
Now, this would make it two to the one 112 112
and that would give me two, and so that tells me 113 113
I can have two subnets by using a slash 25. 114 114
Now, if I'm looking at the number 115 115
of assignable IP addresses, 116 116
this is going to be two to the number of host bits minus two. 117 117
So, in my case of a slash 25 network, 118 118
there are 32 total bits in the address. 119 119
I have 25 of those being assigned for the network portion, 120 120
leaving me with seven host bits. 121 121
So, if I take two to the seventh and then I minus two, 122 122
I get 128 minus two, or 126 available. 123 123
Now, why do I have to have that minus two there? 124 124
This is a concept that a lot of students miss, 125 125
so, really pay attention to it. 126 126
Every network out there has to have two IP addresses 127 127
to be a network. 128 128
The first is known as the network ID, 129 129
and it's the first IP in the range for that network. 130 130
And the other one is a broadcast ID, 131 131
which is the last IP in the network. 132 132
So, no matter what network you choose, 133 133
you always have to sacrifice the first one and the last one. 134 134
The first one is your network ID or network name, 135 135
and your last one is your broadcast. 136 136
Now, anytime you calculate this number of usable IPs, 137 137
it's always going to be the number minus two, 138 138
because you have to take away the network name 139 139
and the broadcast name. 140 140
Let's take a look at classful versus subnetted networks. 141 141
A classful network, if you remember, 142 142
are the ones like slash eight, slash 16, slash 24. 143 143
And if I use the example of 192.168.1.0/24, 144 144
this is a classical class C network, 145 145
there is one network here because it is two to the zero, 146 146
because I borrowed zero bits, because slash 24 is classful. 147 147
This means that there is two to the eight 148 148
minus two assignable IPs, which gives me 256 IPs, 149 149
minus two, one for the broadcast, one for the network, 150 150
and that gives me 254 usable IPs. 151 151
As you can see here on the screen, 152 152
we have all the network bits, all 24 of them, 153 153
and therefore, it is classful. 154 154
Now, we have eight bits of the host, 155 155
and let's say that I wanted to make a smaller subnet. 156 156
How can I do that? 157 157
Well, I could borrow two bits from the host 158 158
and create a subnet, 159 159
this would make it a slash 26, for instance. 160 160
So, if I borrow those two host bits, 161 161
now it becomes two to the s or two to the second power, 162 162
which gives me four networks, 163 163
four subnets that I've created. 164 164
So, if I consider those four networks, 165 165
how many IPs can I have in each one 166 166
of those four networks I just created? 167 167
Well, in the original slash 24, 168 168
I had 256 hosts total or IPs total. 169 169
Now, I borrowed those two host bits 170 170
and gave them to the network. 171 171
And so, now I have two to the six power, 172 172
that's going to give me 64 IPs per subnet. 173 173
So, if I have 64 plus 64 plus 64 plus 64 that equals two 56. 174 174
So, I took that one big network, that slash 24, 175 175
and I turned it into four smaller networks, 176 176
those slash 26s. 177 177
But remember, each of those, I have to give away two IPs, 178 178
the first one and the last one, 179 179
the first one is the network name, 180 180
the last one is the broadcast. 181 181
So, I only have 62 usable IPs that I can assign 182 182
to a server or a laptop or a phone or something like that. 183 183
And so, for each of these four networks I've created, 184 184
I now have 62 usable IPs and I have four of those 185 185
that were made up out of that original slash 24 network. 186 186
Now, if you look at the blue at the bottom of this, 187 187
you can see my original 256 possible IPs, 188 188
which does include my broadcast and my network. 189 189
If I submit that down, I'm going to have four subnets 190 190
or two to the second power. 191 191
Now, I'm going to have 62 possible IPs, 192 192
because each one was two to the sixth minus two, 193 193
because I take away the first and the last 194 194
for the network name and the broadcast. 195 195
In our case, this is going to give us the four subnets 196 196
as their name of 192.168.1.0, 192.168.1.64, 197 197
192.168.1.128, and 192.168.1.192, 198 198
those are my four network names. 199 199
Now, for the broadcast, 200 200
it's going to be the last IP of each subnet, 201 201
so, that's going to be the ones ending in dot 63, 202 202
dot 27, dot 191 and dot 255. 203 203
So, hopefully now you're starting to see how these subnets 204 204
start to work together. 205 205
If we wanted to calculate those IPs, 206 206
we're going to do that based on those subnet masks. 207 207
So, when we take those 32 bits, 208 208
which is the total number of bits 209 209
minus whatever our slash or CIDR notation is, 210 210
in this case 26, 211 211
we get that there are six host bits remaining, 212 212
that would be two to the sixth minus two, 213 213
which is 64 minus two or 62 usable, assignable IPs. 214 214
Now, I'm hoping that all of this 215 215
is starting to come together as we've gone through it. 216 216
Subnetting is a very complex topic 217 217
that a lot of students struggle with. 218 218
I want you to keep practicing it 219 219
and keep working through the problems, 220 220
because I guarantee on test day, you're going 221 221
to get some questions on subnetting. 222 222
Now, some of these questions might ask you 223 223
just to do the problem, 224 224
but most of them are going to be more about troubleshooting. 225 225
There's going to be some computers that aren't talking 226 226
to another, and when you start looking at their IP addresses 227 227
and their subnet masks, you're going to notice 228 228
they're not on the same subnet, 229 229
and if there's no router there, 230 230
data won't go from one subnet to another, 231 231
and so, this is an important concept. 232 232
Now, let's talk about how we list out these subnets. 233 233
Let's keep going with our example of the 192.168.1.0/26 234 234
and those four subnets we created of 62 usable IPs each. 235 235
Now, where does each network begin and end? 236 236
We kind of already went over this by saying 237 237
it was the dot zero, the dot 64, the dot 128, and the dot 192 238 238
as our beginning of each network. 239 239
Now, where did I come up with those? 240 240
Well, I started with the original IP, of 192.168.1.0. 241 241
Now, zero is my first IP 242 242
and it is going to be the name of that network. 243 243
Each subnet we said was 64 IPs in length, 244 244
so, if I take zero plus 64, I get dot 64, 245 245
if I add another 64, I get dot 128, 246 246
if I had another 64, I get dot 192. 247 247
Now, how do I find the last IP for each of these? 248 248
Well, that's going to be my broadcast address. 249 249
All I need to do is add dot 63 to each of these numbers, 250 250
because there's 64 IPs, the first one is used for the name, 251 251
the last one, the plus 63 gets me to that broadcast ID, 252 252
and so, I get 63, 127, 191 and 255, 253 253
that's going to be the beginning and ending of each subnet. 254 254
It goes from zero to 63, 64 to 127, 128 to 191, 255 255
and 192 to 255, and everything in between those, 256 256
for instance, I might have something like 32 257 257
is going to be a usable IP. 258 258
Those are things we're going to assign to clients 259 259
and servers and tablets and laptops 260 260
and desktops and all those things. 261 261
Now, when we do all of these, 262 262
we're going to write them out 263 263
with what's known as the slash notation. 264 264
So, we'd write 192.168.1.0/192.168.1.127, 265 265
that's pretty long to write that out 266 266
for each of the four subnets, so instead, 267 267
we have this shorthand notation called a CIDR notation, 268 268
and this stands for the Classless Inter-Domain Routing. 269 269
Instead of advertising multiple individual routes, 270 270
we summarize all of those as a single route. 271 271
We do this through CIDR notation, and in this case, 272 272
we had the slash 26. 273 273
So, I can consolidate all those underneath them 274 274
by doing a summary of the continuous networks 275 275
using route aggregation. 276 276
When I do this, and I look at the slash 26, 277 277
I noticed that the first 26 bits are all equivalent, 278 278
they're all the same for the subnet mask. 279 279
So, by consolidating those, 280 280
this allows me to put all those networks together 281 281
in one slash notation and simply write them down this way. 282 282
Next, we have a Variable-Length Subnet Mask or VLSM, 283 283
this allows subnets of various sizes to be used. 284 284
Everything I've done so far has been equal. 285 285
I took a big chunk of 256 IPs and broke them up 286 286
into four equal 64-bit chunks, but we don't have to do that, 287 287
I could actually break it up and have a 16 chunk 288 288
and a 32 chunk and a 64 chunk, and that way, I can do that 289 289
to what's right for my network. 290 290
Now, this is going to require a routing protocol 291 291
that supports this, but all modern routing protocols do, 292 292
including things like RIP, OSPF, IS-IS, EIGRP, and BGP. 293 293
Now, we haven't talked much about routing protocols yet, 294 294
but we will in the next section of this course 295 295
when we talk about routing. 296 296
Basically, Variable-Length Subnet Masking 297 297
is a subnetting of subnets. 298 298
Without VLSM, all subnets would have to be the same size 299 299
as you see here on the screen, 300 300
but by using VLSM, 301 301
I can break them up into whatever chunks I want. 302 302
And I'm going to give you the key to subnetting here. 303 303
When you look at this chart, 304 304
this is your subnetting exam tip. 305 305
Write this down in your notes. 306 306
Now, the one I want you to memorize here, 307 307
is this small chart off to the right. 308 308
You can do all the math on test day 309 309
and spend a lot of time trying to do two to the s, 310 310
and two to h minus two, 311 311
or you can memorize this small chart on the right. 312 312
If you notice, it's going to start with slash 24, 313 313
and you have that as your subnet as a classful class C, 314 314
you have 256 IPs, you know this, 315 315
because we've talked about this a lot, right? 316 316
Now, if I add one to the CIDR notation, it becomes slash 25, 317 317
I increase the number of networks, 318 318
by adding one, I borrowed a bit, 319 319
that's going to give me two subnets, 320 320
and that's going to take my 256 IPs 321 321
and divide it by two, giving me 128. 322 322
Notice, I'm always going to have 256 IPs 323 323
as I go from slash 24 downward all the way down to slash 30. 324 324
So, every time my CIDR notation goes up by one, 325 325
my number of networks goes up by one 326 326
and my number of IPs gets divided by two. 327 327
If you can remember this chart on the right, 328 328
this is going to help you on test day, 329 329
get through a lot of the questions on subnetting 330 330
and it's really nice and easy. 331 331
Now, the good thing is for Network+, 332 332
they're not going to give you a lot of difficult subnets. 333 333
Almost all of the ones you're going to get 334 334
are going to be slashed 24 or higher, 335 335
the most are going to give you something like a slash 23 maybe, 336 336
or a splash 22, but that's rare. 337 337
Generally it's going to be slashed 25, 26, 27, 28, 29, and 30, 338 338
that is the most common. 339 339
So, if they ask you something like, you have a slash 28, 340 340
how many subnets are created? 341 341
It's pretty easy, you look at this chart and go, 342 342
"Oh, the answer is 16." 343 343
And if I go from 24 up to 28, I keep doubling it 344 344
and I double it to get to 25, 345 345
I double it again to get to 26, 346 346
double it again to get to 27, 347 347
double it again to get to 16, right? 348 348
And that is where I get to slash 28 is 16, 349 349
because I went two, four, eight, 16, and there we go. 350 350
Now, you might ask, how many IPs you'd have in each subnet 351 351
if you had a slash 30? 352 352
Well, for a slash 30, 353 353
that's what we use for point to point connections, 354 354
and there's going to be four IPs, 355 355
but only two of those are usable, 356 356
because again, our first one is always the name 357 357
of the network and the last one is always the broadcast. 358 358
So, you have four IPs, two of which are usable. 359 359
And if you remember this chart, you're going to be able 360 360
to do great on subnetting on the exam. 361 361
Now, before the test, 362 362
I want you to take lots of practice subnetting problems, 363 363
especially in your class C range. 364 364
Everything from slash 24 to slash 30 365 365
is really fair game for the Network+ exam. 366 366
Memorizing these slash notations and the CIDR 367 367
is going to help you answer any question they throw at you. 368 368
But as we go through this section, 369 369
I'm going to show you a shortcut 370 370
that you can do just using your hands, as well, 371 371
and you're going to really like this, 372 372
but having this chart memorized 373 373
is going to help with that, as well. 374 374
Now, for the exam, something you may see is they might 375 375
have you do a variable-length subnetting problem. 376 376
Now, if they do a VLSM problem for you, 377 377
it might be they gave you an IP address with 256 IPs 378 378
because they're going to be a slash 24 379 379
and then, they might say, 380 380
"Hey, you have an it department that needs X number of IPs, 381 381
you have HR department that needs X amount of IPs, 382 382
you have a sales department that needs Y amount of IPs." 383 383
And you'll have to go through and do the slash notations 384 384
for each one based on the number of IPs they give you. 385 385
That is a totally fair question on the exam 386 386
and how you'd put this subnetting stuff to work 387 387
in the real world.