Subnetting IP4 - WordPress.com

advertisement
Subnetting IP4
ICND/CCNA Prep
What is subnetting and why do I care?
• Basically, subnetting is the process of taking one network and dividing it into
smaller networks. For example, if we have a 172.16.0.0/16 network, this gives us
65,536 (2^16) possible hosts on the network. But, we could divide this up into
two networks with 32,768 hosts each. More on this in a bit…
• For your ICND and CCNA exams, you need to be able to do this in your head, very
quickly. I assure you that while you may not get exam questions that ask you to
directly subnet at network (like we did above), you will be given information
about a network and have to figure out what’s wrong with it – and that will
require that you can subnet quickly.
Baby Steps: Counting in Binary.
• The first thing you need to do is be able to count in binary and know your powers
of two (up to 2^8). See, an IP address looks like this:
172.16.22.44
But in binary it looks like this:
10101100.00010000.00010110.00101100
• So how did we get there? The first thing is to look at these octets (each portion
of the IP separated by a “.”) as individual numbers. Don’t worry, we’ll put it all
together later. First though, our powers of 2:
2^0 = 1 2^1 = 2 2^2 = 4 2^3 = 8 2^4 = 16 2^5 = 32 2^6 = 64 2^7 = 128
More on the powers of 2
• So right now we know:
2^0 = 1 2^1 = 2 2^2 = 4 2^3 = 8 2^4 = 16 2^5 = 32 2^6 = 64 2^7 = 128
• The first section of our IP address 172.16.22.44 is “172”. Our binary representation
of that was 10101100. Let’s tear that apart:
Powers of 2:
172 in Binary:
Result:
Sum of Results:
2^7 2^6 2^5 2^4 2^3 2^2 2^1 2^0
1
0
1
0
1
1
0
0
128 0 32 0 8
4
0
0
128+32+8+4 = 172
More on the powers of 2
• If you’re like me, you’re already sick of this, but you need to know it, so let’s tear
down the rest of that address (172.16.22.44). On the previous slide, we did 172 –
now let’s do the rest:
16
Powers of 2:
16 in Binary:
Result:
22
Powers of 2:
16 in Binary:
Result:
44
Powers of 2:
16 in Binary:
Result:
2^7 2^6 2^5 2^4 2^3 2^2 2^1 2^0
0
0
0
1
0 0
0
0
0
0
0
16 0
0
0
0
2^7 2^6 2^5 2^4 2^3 2^2 2^1 2^0
0
0
0
1 0
1
1
0
0
0
0
16 0
4
2
0
2^7 2^6 2^5 2^4 2^3 2^2 2^1 2^0
0
0
1
0
1
1
0
0
0
0
32
0 8 4
0
0
Result
16
Result
16+4+2
22
Result
32+8+4
44
Recap on powers of 2
• Powers of two are key in subnetting. The good news is, you only need to know the first 8
(2^0 through 2^7), and they are 1, 2, 4, 8, 16, 32, 64, and 128
• Now, a bit of practice of what we’ve done so far:
• Powers of 2:
• 2^4 =
16 = 2^
2^0 =
• 128 = 2^
32 = 2^
2^6 =
Convert to Binary
Convert to an IP Address
172.16.1.1 =
10.1.0.177 =
224.0.0.5 =
1.199.63.17 =
11000000.00111111.00000010.11111101 =
00000011.01100010.10000001.10101011 =
00100001.01010101.10101010.00000000 =
11100101.00110011.11111111.00010000 =
Back to subnetting
• Ok, we can count by twos now – good game. Now that those basics are out of
the way, let’s see how we can take a network address – which could have been
assigned to us from a network administrator or an ISP – and divide into multiple,
smaller networks, a.k.a sub-networks, a.k.a. “subnet it.”
• Example:
We’re given the classful (c-class) network address of 192.168.10.0/24 and need to subnet
it. First, we need to recognize that we can’t make the “network” that has already been
given to us (by whomever) bigger, we can only make it smaller. That means that the /24
(known as CIDR notation), which defines the network portion of the address that was
assigned to you, is “fixed” when looking to the left. That /24 means the first 24 bits
(192.168.10) are unchangeable. However, we have the last 8 bits that we can play with. I
know that’s wordy – for now, just accept that the 192.168.10 part won’t be changed,
ever…
Subnetting
• We have our 192.168.10.0/24 network. We know the 192.168.10 part is locked. We
also know that this is denoted by the /24, meaning the first 24 bits (the first 3
octects – remember, in binary those are groups of eight 1s and 0s and 3x8=24)
will never change. But now we’re the network admin, and we want to dish out
network addresses to two junior admins. How do we do this? Simple, we steal 1
more bit, this turns our /24 into a /25. Remember, the first 24 (to the left) are
locked, but we can play with the stuff to the right….
• ….let’s look at this in binary:
• 192.168.10.0/24 = 11000000.10101000.00001010.00000000
First 24 bits, locked
Last 8 bits.
We can play with these.
Subnetting
• From out last slide:
• 192.168.10.0/24 = 11000000.10101000.00001010.00000000
First 24 bits, locked
Last 8 bits.
We can play with these.
• Let’s turn this into two networks. To do that, we’re going to steal 1 bit from the last 8 bits.
This gives us 2 networks (2^1 – told you powers of 2 were important)
• The one bit we’re stealing from the last octet does three things:
• 1) It means we’re using a /25 mask now (24 + the 1 we’re stealing)
• 2) It defines our network boundary. Remember your powers of two – the far left bit we’re stealing
is in the 2^7th spot – which is 128. That means our networks are 192.168.10.0 (if our 25th bit is a 0)
and 192.168.10.128 (if our 25th bit is a 1)
• 3) It defines our subnet mask. More on this later, but a /25 gives us a mask of 255.255.255.128
Subnetting
• Remember, our possible network addresses are now 192.168.10.0 (if our 25th bit is a 0) and
192.168.10.128 (if our 25th bit is a 1):
Decimal: 192.168.10.0
Binary:
192.168.10.128
11000000.10101000.00001010.00000000 11000000.10101000.00001010.10000000
First 24 bits - locked
First 24 bits - locked
25th bit that we stole
To make 2 networks
Available for Hosts
25th bit that we stole
To make 2 networks
Available for Hosts
Subnetting
• Given:
Decimal: 192.168.10.0
Binary:
192.168.10.128
11000000.10101000.00001010.00000000 11000000.10101000.00001010.10000000
First 24 bits - locked
First 24 bits - locked
25th bit that we stole
To make 2 networks
25th bit that we stole
To make 2 networks
Available for Hosts
Available for Hosts
Network Definitions:
Network Address
Host Range
Broadcast Address
Network 1
192.168.10.0
192.168.10.0-126
192.168.10.127
Network 2
192.168.10.128
192.168.10.129-254
192.168.10.255
A Step Further
• Using our original network, 192.168.10.0/24, what do we do if we need 3
networks? Remember back on slide 9 how we “stole” 1 bit to give us two /25
networks (we stole 1, and 2^1 is 2 …so we have two networks)? We’re going to
do the same thing. If we steal 2 bits, we have 2^2 available networks – so 4. We
need 3, so this works and has the added benefit of giving us one more for
growth.
• Look back at slide 9 – we stole 1 bit, which could have a value of 1 or 0, making
our networks 192.168.10.0 or 192.168.10.128 (because the value of the far left bit in
any octet is 128), now we’re borrowing 2 bits, which looks like this:
• 11000000.10101000.00001010.00000000
First 24 bits - locked
25th and 26th bit that we stole
To make 2 networks
Available for Hosts
A Step Further
• 11000000.10101000.00001010.00000000
First 24 bits - locked
25th and 26th bit that we stole
To make 2 networks
Available for Hosts
• So, when we borrowed just 1 bit, the network boundaries were in 128 bit blocks (2^7).
When we borrow 2 bits, the blocks are 64 (2^6). We have four networks, because each of
our two borrowed bits can be either a 1 or 0 – this gives us the combinations of 00, 01, 10,
and 11 – which makes the binary above look like one of these 4 combinations (with their
decimal equivalents:
11000000.10101000.00001010.00000000
192.168.10.0
11000000.10101000.00001010.01000000
192.168.10.64
11000000.10101000.00001010.10000000
192.168.10.128
11000000.10101000.00001010.110000000
192.168.10.192
A Step Further
• So, given this information from the last slide:
11000000.10101000.00001010.00000000
192.168.10.0
11000000.10101000.00001010.01000000
192.168.10.64
11000000.10101000.00001010.10000000
192.168.10.128
11000000.10101000.00001010.110000000
192.168.10.192
We have the networks:
Network 1
Network Address
192.168.10.0
Host Range
192.168.10.0-62
Broadcast
192.168.10.63
Network 2
192.168.10.64
192.168.10.64-126
192.168.10.127
Network 3
192.168.10.128
192.168.10.129-190
192.168.10.191
Network 4
192.168.10.192
192.168.10.193-254
192.168.10.255
A Class B Example
• Everything we’ve done so far as been with a class C address. They’re easier to learn on.
Let’s take a look at this class be address and subnet the heck out of it:
• 172.32.0.0/22
Whoa, wait up, what’s this /22 stuff you’re giving me? No worries, brah, I got you covered. First,
convert to binary:
10101100.00100000.00000000.00000000
First 22 bits - locked
Last 10 bits – we can play with
Let’s say we want to turn this into 4 networks. Easy enough by now, right? We just steal the last
two bits of the 3rd octet. Work it out on paper. Those last two placeholders in the 3rd octet have a
value of 2 and 1 (2^1, and 2^0). Remember, each bit can have a value of 1 or 0. So, our potential
networks are:
Network Address
Host Range
Broadcast
Network 1
172.16.0.0
172.16.0.0-254
172.16.0.255
Network 2
172.16.1.0
172.16.1.0-254
172.16.1.255
Network 3
172.16.2.0
172.16.2.0-254
172.16.2.255
Network 4
172.16.3.0
172.16.3.0-254
172.16.3.255
Note: With your new /24 networks, your subnet mask is now 255.255.255.0 - /22 was 255.255.252.0
A Harder Class B Example
• Your network assignment from your ISP was: 172.64.0.0/12
10101100.01000000.00000000.00000000
First 12 bits - locked
Last 20 bits – we can play with
You need 7 networks. 2^3 is 8, so that works just fine. So we’re going to steal 3 bits to play
with. Now, in binary, we have something that looks like this:
10101100.01000000.00000000.00000000
First 12 bits - locked
Last 17 bits for hosts
Next 3 bits, for subnetting
Let’s continue this on the next page…
A Harder Class B Example
• 10101100.01000000.00000000.00000000
First 12 bits - locked
Last 17 bits for hosts
Next 3 bits, for subnetting
• What are our networks in this example? The rightmost bit in the 3 bits that we’re
subnetting has a value of 2 – in that second octet, that zero is in the 2^1 place – which
makes our second network look like this (the first one is the original network we were
given):
10101100.01000010.00000000.00000000
In decimal, this is 172.64.0.0
A Harder Class B Example
• 10101100.01000000.00000000.00000000
First 12 bits - locked
Last 17 bits for hosts
Next 3 bits, for subnetting
The other networks are 172.66.0.0, 172.68.0.0, 172.70.0.0, 172.72.0.0, 172.74.0.0,
172.76.0.0. These are our 8 networks (again, remember the first one is still
172.62.0.0). Here’s what that looks like
172.62.0.0
172.64.0.0
172.66.0.0
172.68.0.0
172.70.0.0
172.72.0.0
172.74.0.0
172.76.0.0
10101100.01000000.00000000.00000000
10101100.01000010.00000000.00000000
10101100.01000100.00000000.00000000
10101100.01000110.00000000.00000000
10101100.01001000.00000000.00000000
10101100.01001010.00000000.00000000
10101100.01001100.00000000.00000000
10101100.01001110.00000000.00000000
Summary and Tips
• Subnetting is important. At very least you’ll need it to pass your CCENT/CCNA exam(s). If
you ever setup a new network, office, or branch office in the real world, you’ll need it then
as well.
• Know your powers of 2 up to 2^7
• Be able to convert from binary to decimal and back. You should know that 11100000 is 224,
and that 177 is 10110001
• Practice. A lot. Consult the internet and search for subnetting practice. There’s tons of
material out there that can keep you sharp with this stuff.
• If you’re given an IP address and subnet mask, you should be able to quickly calculate the
network ID. If you have a network ID and netmask, you should be able to list the
broadcast address and range of usable IP addresses. It shouldn’t take you more than 10
seconds to do this.
• You should practice to the point where you’re so sick of subnetting that by the time you
walk into the exam, that you never want to see it again.
Download