Senior Acquisitions Editor: Kenyon Brown Development Editor: Kim Wimpsett


Subnetting a Class C Address—The Fast Way!



Yüklə 22,5 Mb.
Pdf görüntüsü
səhifə19/69
tarix26.10.2019
ölçüsü22,5 Mb.
#29436
1   ...   15   16   17   18   19   20   21   22   ...   69
Todd Lammle CCNA Routing and Switching


Subnetting a Class C Address—The Fast Way!

When you’ve chosen a possible subnet mask for your network and need to

determine the number of subnets, valid hosts, and the broadcast

addresses of a subnet that mask will provide, all you need to do is answer

five simple questions:

How many subnets does the chosen subnet mask produce?

How many valid hosts per subnet are available?

What are the valid subnets?

What’s the broadcast address of each subnet?

What are the valid hosts in each subnet?

This is where you’ll be really glad you followed my advice and took the

time to memorize your powers of 2. If you didn’t, now would be a good

time… Just refer back to the sidebar “Understanding the Powers of 2”

earlier if you need to brush up. Here’s how you arrive at the answers to

those five big questions:

How many subnets? 2

x

= number of subnets. x is the number of

masked bits, or the 1s. For example, in 11000000, the number of 1s

gives us 2

2

subnets. So in this example, there are 4 subnets.



How many hosts per subnet? 2

y

– 2 = number of hosts per subnet. y

is the number of unmasked bits, or the 0s. For example, in 11000000,

the number of 0s gives us 2

6

– 2 hosts, or 62 hosts per subnet. You



need to subtract 2 for the subnet address and the broadcast address,

which are not valid hosts.



What are the valid subnets? 256 – subnet mask = block size, or

increment number. An example would be the 255.255.255.192 mask,

where the interesting octet is the fourth octet (interesting because that

is where our subnet numbers are). Just use this math: 256 – 192 = 64.

The block size of a 192 mask is always 64. Start counting at zero in

blocks of 64 until you reach the subnet mask value and these are your

subnets in the fourth octet: 0, 64, 128, 192. Easy, huh?

What’s the broadcast address for each subnet? Now here’s the really

easy part. Since we counted our subnets in the last section as 0, 64,

128, and 192, the broadcast address is always the number right before

the next subnet. For example, the 0 subnet has a broadcast address of

63 because the next subnet is 64. The 64 subnet has a broadcast

address of 127 because the next subnet is 128, and so on. Remember,

the broadcast address of the last subnet is always 255.

What are the valid hosts? Valid hosts are the numbers between the

subnets, omitting the all-0s and all-1s. For example, if 64 is the subnet

number and 127 is the broadcast address, then 65–126 is the valid

host range. Your valid range is always the group of numbers between

the subnet address and the broadcast address.

If you’re still confused, don’t worry because it really isn’t as hard as it

seems to be at first—just hang in there! To help lift any mental fog, try a

few of the practice examples next.



Subnetting_Practice_Examples:_Class_C_Addresses'>Subnetting Practice Examples: Class C Addresses

Here’s your opportunity to practice subnetting Class C addresses using

the method I just described. This is so cool. We’re going to start with the

first Class C subnet mask and work through every subnet that we can,

using a Class C address. When we’re done, I’ll show you how easy this is

with Class A and B networks too!



Practice Example #1C: 255.255.255.128 (/25)

Since 128 is 10000000 in binary, there is only 1 bit for subnetting and 7

bits for hosts. We’re going to subnet the Class C network address

192.168.10.0.



192.168.10.0 = Network address

255.255.255.128 = Subnet mask

Now, let’s answer our big five:

How many subnets? Since 128 is 1 bit on (10000000), the answer

would be 2

1

= 2.


How many hosts per subnet? We have 7 host bits off (10000000), so

the equation would be 2

7

– 2 = 126 hosts. Once you figure out the



block size of a mask, the amount of hosts is always the block size

minus 2. No need to do extra math if you don’t need to!



What are the valid subnets? 256 – 128 = 128. Remember, we’ll start

at zero and count in our block size, so our subnets are 0, 128. By just

counting your subnets when counting in your block size, you really

don’t need to do steps 1 and 2. We can see we have two subnets, and in

the step before this one, just remember that the amount of hosts is

always the block size minus 2, and in this example, that gives us 2

subnets, each with 126 hosts.

What’s the broadcast address for each subnet? The number right

before the value of the next subnet is all host bits turned on and

equals the broadcast address. For the zero subnet, the next subnet is

128, so the broadcast of the 0 subnet is 127.



What are the valid hosts? These are the numbers between the subnet

and broadcast address. The easiest way to find the hosts is to write out

the subnet address and the broadcast address, which makes valid

hosts completely obvious. The following table shows the 0 and 128

subnets, the valid host ranges of each, and the broadcast address of

both subnets:



Subnet

0

128

First host

1

129


Last host

126 254


Broadcast 127 255

Looking at a Class C /25, it’s pretty clear that there are two subnets. But

so what—why is this significant? Well actually, it’s not because that’s not

the right question. What you really want to know is what you would do

with this information!


I know this isn’t exactly everyone’s favorite pastime, but what we’re about

to do is really important, so bear with me; we’re going to talk about

subnetting—period. The key to understanding subnetting is to

understand the very reason you need to do it, and I’m going to

demonstrate this by going through the process of building a physical

network.


Okay—because we added that router shown in

Figure 4.3

, in order for the

hosts on our internetwork to communicate, they must now have a logical

network addressing scheme. We could use IPv6, but IPv4 is still the most

popular for now. It’s also what we’re studying at the moment, so that’s

what we’re going with.

FIGURE 4.3

Implementing a Class C /25 logical network

Looking at

Figure 4.3

, you can see that there are two physical networks,

so we’re going to implement a logical addressing scheme that allows for

two logical networks. As always, it’s a really good idea to look ahead and

consider likely short- and long-term growth scenarios, but for this

example in this book, a /25 gets it done.

Figure 4.3

shows us that both subnets have been assigned to a router

interface, which creates our broadcast domains and assigns our subnets.

Use the command

show ip route

to see the routing table on a router.

Notice that instead of one large broadcast domain, there are now two

smaller broadcast domains, providing for up to 126 hosts in each. The

C

in



the router output translates to “directly connected network,” and we can

see we have two of those with two broadcast domains and that we created

and implemented them. So congratulations—you did it! You have

successfully subnetted a network and applied it to a network design. Nice!

Let’s do it again.

Practice Example #2C: 255.255.255.192 (/26)

This time, we’re going to subnet the network address 192.168.10.0 using

the subnet mask 255.255.255.192.

192.168.10.0 = Network address

255.255.255.192 = Subnet mask

Now, let’s answer the big five:



How many subnets? Since 192 is 2 bits on (11000000), the answer

would be 2

2

= 4 subnets.



How many hosts per subnet? We have 6 host bits off (11000000),

giving us 2

6

– 2 = 62 hosts. The amount of hosts is always the block



size minus 2.

What are the valid subnets? 256 – 192 = 64. Remember to start at

zero and count in our block size. This means our subnets are 0, 64,

128, and 192. We can see we have a block size of 64, so we have 4

subnets, each with 62 hosts.



What’s the broadcast address for each subnet? The number right

before the value of the next subnet is all host bits turned on and

equals the broadcast address. For the zero subnet, the next subnet is

64, so the broadcast address for the zero subnet is 63.



What are the valid hosts? These are the numbers between the subnet

and broadcast address. As I said, the easiest way to find the hosts is to

write out the subnet address and the broadcast address, which clearly

delimits our valid hosts. The following table shows the 0, 64, 128, and

192 subnets, the valid host ranges of each, and the broadcast address

of each subnet:



The subnets (do this first)

0 64 128 192

Our first host (perform host addressing last) 1

65 129 193

Our last host

62 126 190 254


The broadcast address (do this second)

63 127 191 255

Again, before getting into the next example, you can see that we can now

subnet a /26 as long as we can count in increments of 64. And what are

you going to do with this fascinating information? Implement it! We’ll

use


Figure 4.4

to practice a /26 network implementation.



FIGURE 4.4

Implementing a class C /26 (with three networks)

The /26 mask provides four subnetworks, and we need a subnet for each

router interface. With this mask, in this example, we actually have room

with a spare subnet to add to another router interface in the future.

Always plan for growth if possible!



Practice Example #3C: 255.255.255.224 (/27)

This time, we’ll subnet the network address 192.168.10.0 and subnet

mask 255.255.255.224.

192.168.10.0 = Network address

255.255.255.224 = Subnet mask



How many subnets? 224 is 11100000, so our equation would be 2

3

=



8.

How many hosts? 2

5

– 2 = 30.



What are the valid subnets? 256 – 224 = 32. We just start at zero and

count to the subnet mask value in blocks (increments) of 32: 0, 32, 64,

96, 128, 160, 192, and 224.

What’s the broadcast address for each subnet (always the number

right before the next subnet)?

What are the valid hosts (the numbers between the subnet number

and the broadcast address)?

To answer the last two questions, first just write out the subnets, then

write out the broadcast addresses—the number right before the next

subnet. Last, fill in the host addresses. The following table gives you all

the subnets for the 255.255.255.224 Class C subnet mask:

The subnet address 0 32 64 96 128 160 192 224

The first valid host

1

33 65 97 129 161 193 225



The last valid host

30 62 94 126 158 190 222 254

The broadcast address 31 63 95 127 159 191 223 255

In practice example #3C, we’re using a 255.255.255.224 (/27) network,

which provides eight subnets as shown previously. We can take these

subnets and implement them as shown in

Figure 4.5

using any of the

subnets available.


FIGURE 4.5

Implementing a Class C /27 logical network

Notice that used six of the eight subnets available for my network design.

The lightning bolt symbol in the figure represents a wide area network

(WAN) such as a T1 or other serial connection through an ISP or telco. In

other words, something you don’t own, but it’s still a subnet just like any

LAN connection on a router. As usual, I used the first valid host in each

subnet as the router’s interface address. This is just a rule of thumb; you

can use any address in the valid host range as long as you remember what

address you configured so you can set the default gateways on your hosts

to the router address.

Practice Example #4C: 255.255.255.240 (/28)


Let’s practice another one:

192.168.10.0 = Network address

255.255.255.240 = Subnet mask

Subnets? 240 is 11110000 in binary. 2

4

= 16.



Hosts? 4 host bits, or 2

4

– 2 = 14.



Valid subnets? 256 – 240 = 16. Start at 0: 0 + 16 = 16. 16 + 16 = 32. 32

+ 16 = 48. 48 + 16 = 64. 64 + 16 = 80. 80 + 16 = 96. 96 + 16 = 112. 112

+ 16 = 128. 128 + 16 = 144. 144 + 16 = 160. 160 + 16 = 176. 176 + 16 =

192. 192 + 16 = 208. 208 + 16 = 224. 224 + 16 = 240.



Broadcast address for each subnet?

Valid hosts?

To answer the last two questions, check out the following table. It gives

you the subnets, valid hosts, and broadcast addresses for each subnet.

First, find the address of each subnet using the block size (increment).

Second, find the broadcast address of each subnet increment, which is

always the number right before the next valid subnet, and then just fill in

the host addresses. The following table shows the available subnets,

hosts, and broadcast addresses provided from a Class C 255.255.255.240

mask.

Cisco has figured out that most people cannot count in 16s and



therefore have a hard time finding valid subnets, hosts, and broadcast

addresses with the Class C 255.255.255.240 mask. You’d be wise to

study this mask.

Practice Example #5C: 255.255.255.248 (/29)

Let’s keep practicing:

192.168.10.0 = Network address


255.255.255.248 = Subnet mask

Subnets? 248 in binary = 11111000. 2

5

= 32.



Hosts? 2

3

– 2 = 6.



Valid subnets? 256 – 248 = 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, 224, 232, 240, and 248.

Broadcast address for each subnet?

Valid hosts?

Take a look at the following table. It shows some of the subnets (first four

and last four only), valid hosts, and broadcast addresses for the Class C

255.255.255.248 mask:



Subnet

0 8 16 24 … 224 232 240 248

First host 1 9 17 25 … 225 233 241 249

Last host 6 14 22 30 … 230 238 246 254

Broadcast 7 15 23 31 … 231 239 247 255

If you try to configure a router interface with the address

192.168.10.6 255.255.255.248 and receive the following error, It

means that

ip subnet-zero

is not enabled:

Bad mask /29 for address 192.168.10.6

You must be able to subnet to see that the address used in this

example is in the zero subnet!



Practice Example #6C: 255.255.255.252 (/30)

Okay—just one more:

192.168.10.0 = Network address

255.255.255.252 = Subnet mask



Subnets? 64.

Hosts? 2.

Valid subnets? 0, 4, 8, 12, etc., all the way to 252.

Broadcast address for each subnet? (Always the number right before

the next subnet.)

Valid hosts? (The numbers between the subnet number and the

broadcast address.)

The following table shows you the subnet, valid host, and broadcast

address of the first four and last four subnets in the 255.255.255.252

Class C subnet:

Subnet

0 4 8 12 … 240 244 248 252

First host 1 5 9 13 … 241 245 249 253

Last host 2 6 10 14 … 242 246 250 254

Broadcast 3 7 11 15 … 243 247 251 255



Should We Really Use This Mask That Provides Only

Two Hosts?

You are the network administrator for Acme Corporation in San

Francisco, with dozens of WAN links connecting to your corporate

office. Right now your network is a classful network, which means

that the same subnet mask is on each host and router interface.

You’ve read about classless routing, where you can have different

sized masks, but don’t know what to use on your point-to-point WAN

links. Is the 255.255.255.252 (/30) a helpful mask in this situation?

Yes, this is a very helpful mask in wide area networks and of course

with any type of point-to-point link!

If you were to use the 255.255.255.0 mask in this situation, then each

network would have 254 hosts. But you use only 2 addresses with a

WAN or point-to-point link, which is a waste of 252 hosts per subnet!

If you use the 255.255.255.252 mask, then each subnet has only 2

hosts, and you don’t want to waste precious addresses. This is a really

important subject, one that we’ll address in a lot more detail in the

section on VLSM network design in the next chapter!


Subnetting in Your Head: Class C Addresses

It really is possible to subnet in your head? Yes, and it’s not all that hard

either—take the following example:

192.168.10.50 = Node address

255.255.255.224 = Subnet mask

First, determine the subnet and broadcast address of the network in

which the previous IP address resides. You can do this by answering

question 3 of the big 5 questions: 256 – 224 = 32. 0, 32, 64, and so on.

The address of 50 falls between the two subnets of 32 and 64 and must be

part of the 192.168.10.32 subnet. The next subnet is 64, so the broadcast

address of the 32 subnet is 63. Don’t forget that the broadcast address of

a subnet is always the number right before the next subnet. The valid host

range equals the numbers between the subnet and broadcast address, or

33–62. This is too easy!

Let’s try another one. We’ll subnet another Class C address:

192.168.10.50 = Node address

255.255.255.240 = Subnet mask

What is the subnet and broadcast address of the network of which the

previous IP address is a member? 256 – 240 = 16. Now just count by our

increments of 16 until we pass the host address: 0, 16, 32, 48, 64. Bingo—

the host address is between the 48 and 64 subnets. The subnet is

192.168.10.48, and the broadcast address is 63 because the next subnet is

64. The valid host range equals the numbers between the subnet number

and the broadcast address, or 49–62.

Let’s do a couple more to make sure you have this down.

You have a node address of 192.168.10.174 with a mask of

255.255.255.240. What is the valid host range?

The mask is 240, so we’d do a 256 – 240 = 16. This is our block size. Just

keep adding 16 until we pass the host address of 174, starting at zero, of

course: 0, 16, 32, 48, 64, 80, 96, 112, 128, 144, 160, 176. The host address

of 174 is between 160 and 176, so the subnet is 160. The broadcast

address is 175; the valid host range is 161–174. That was a tough one!

One more—just for fun. This one is the easiest of all Class C subnetting:


192.168.10.17 = Node address

255.255.255.252 = Subnet mask

What is the subnet and broadcast address of the subnet in which the

previous IP address resides? 256 – 252 = 0 (always start at zero unless

told otherwise). 0, 4, 8, 12, 16, 20, etc. You’ve got it! The host address is

between the 16 and 20 subnets. The subnet is 192.168.10.16, and the

broadcast address is 19. The valid host range is 17–18.

Now that you’re all over Class C subnetting, let’s move on to Class B

subnetting. But before we do, let’s go through a quick review.

What Do We Know?

Okay—here’s where you can really apply what you’ve learned so far and

begin committing it all to memory. This is a very cool section that I’ve

been using in my classes for years. It will really help you nail down

subnetting for good!

When you see a subnet mask or slash notation (CIDR), you should know

the following:

/25 What do we know about a /25?

128 mask


1 bit on and 7 bits off (10000000)

Block size of 128

Subnets 0 and 128

2 subnets, each with 126 hosts



/26 What do we know about a /26?

192 mask


2 bits on and 6 bits off (11000000)

Block size of 64

Subnets 0, 64, 128, 192

4 subnets, each with 62 hosts



/27 What do we know about a /27?

224 mask


3 bits on and 5 bits off (11100000)

Block size of 32

Subnets 0, 32, 64, 96, 128, 160, 192, 224

8 subnets, each with 30 hosts



/28 What do we know about a /28?

240 mask


4 bits on and 4 bits off

Block size of 16

Subnets 0, 16, 32, 48, 64, 80, 96, 112, 128, 144, 160, 176, 192, 208,

224, 240


16 subnets, each with 14 hosts

/29 What do we know about a /29?

248 mask


5 bits on and 3 bits off

Block size of 8

Subnets 0, 8, 16, 24, 32, 40, 48, etc.

32 subnets, each with 6 hosts



/30 What do we know about a /30?

252 mask


6 bits on and 2 bits off

Block size of 4

Subnets 0, 4, 8, 12, 16, 20, 24, etc.

64 subnets, each with 2 hosts

Table 4.3

puts all of the previous information into one compact little

table. You should practice writing this table out on scratch paper, and if

you can do it, write it down before you start your exam!

Table 4.3

What do you know?



CIDR

Notation

Mask Bits

Block

Size

Subnets

Hosts

/25


128

1 bit on


and 7

bits off


128

0 and 128

2 subnets,

each with

126 hosts

/26


192

2 bits on

and 6

bits off


64

0, 64, 128, 192

4 subnets,

each with

62 hosts

/27


224

3 bits on

and 5

bits off


32

0, 32, 64, 96, 128, 160,

192, 224

8 subnets,

each with

30 hosts


/28

240


4 bits

on and


4 bits

off


16

0, 16, 32, 48, 64, 80, 96,

112, 128, 144, 160, 176,

192, 208, 224, 240

16 subnets,

each with

14 hosts

/29


248

5 bits on

and 3

bits off


8

0, 8, 16, 24, 32, 40, 48,

etc.

32 subnets,



each with 6

hosts


/30

252


6 bits

on and


2 bits

off


4

0, 4, 8, 12, 16, 20, 24, etc. 64

subnets,

each with 2

hosts

Regardless of whether you have a Class A, Class B, or Class C address, the



/30 mask will provide you with only two hosts, ever. As suggested by

Cisco, this mask is suited almost exclusively for use on point-to-point

links.

If you can memorize this “What Do We Know?” section, you’ll be much



better off in your day-to-day job and in your studies. Try saying it out

loud, which helps you memorize things—yes, your significant other

and/or coworkers will think you’ve lost it, but they probably already do if

you’re in the networking field anyway. And if you’re not yet in the

networking field but are studying all this to break into it, get used to it!

It’s also helpful to write these on some type of flashcards and have people

test your skill. You’d be amazed at how fast you can get subnetting down

if you memorize block sizes as well as this “What Do We Know?” section.



Yüklə 22,5 Mb.

Dostları ilə paylaş:
1   ...   15   16   17   18   19   20   21   22   ...   69




Verilənlər bazası müəlliflik hüququ ilə müdafiə olunur ©azkurs.org 2024
rəhbərliyinə müraciət

gir | qeydiyyatdan keç
    Ana səhifə


yükləyin