Upcoming SlideShare
×

# How to become the binary and subnetting artist

3,846 views

Published on

Published in: Technology
5 Likes
Statistics
Notes
• Full Name
Comment goes here.

Are you sure you want to Yes No
• Be the first to comment

Views
Total views
3,846
On SlideShare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
554
0
Likes
5
Embeds 0
No embeds

No notes for slide

### How to become the binary and subnetting artist

1. 1. Purchased by TEE KIAN HONG, kian_hong2000@yahoo.com #2499490-
4. 4. How to Become the Binary and Subnetting Artist www.renemolenaar.nl Page 3 of 90 Index Introduction ..............................................................................................................1 1. Binary Basics .........................................................................................................4 2. Welcome to Subnetting ...........................................................................................6 3. Subnetting: The beginning.....................................................................................12 4. Subnetting: The Fast Way .....................................................................................30 5. Classless Inter-Domain Routing..............................................................................38 6. Variable length subnet mask (VLSM).......................................................................40 7. Summarization.....................................................................................................46 8. Hexadecimal calculations.......................................................................................50 9. Tackling miscellaneous subnetting questions............................................................52 10. Create your own cheat sheet................................................................................55 11. Final Thoughts....................................................................................................56 Appendix A – Answers to exercises.............................................................................57 Purchased by TEE KIAN HONG, kian_hong2000@yahoo.com #2499490-
5. 5. How to Become the Binary and Subnetting Artist www.renemolenaar.nl Page 4 of 90 1. Binary Basics Before we start calculating subnets and talk about IP addressing, let’s first check out some basics of binary calculations. We are all used to work with decimal numbers where we count from 1 till 10. This is easy because we have 10 fingers so we don’t have to count off the top of our head. In the binary system, we only work with 0 or 1. 0 = Off 1 = On Bits 128 64 32 16 8 4 2 1 The bit on the far left side is called the most significant bit (MSB) because this bit has the highest value. The bit on the far right side is called the least significant bit (LSB) because this one has the lowest value. So how do we convert decimal numbers into binary? Let me show you an example: If we want the decimal number “0” in binary this means we leave all the bits “off”. Bits 128 64 32 16 8 4 2 1 0 0 0 0 0 0 0 0 0 Let’s take the number 178 and turn it into binary, just start at the left and see which bits “fit in” to make this number. 128 + 32 + 16 + 2 = 178. Bits 128 64 32 16 8 4 2 1 178 1 0 1 1 0 0 1 0 Just one more! Let’s turn 255 into binary. 128 + 64 + 32 + 16 + 8 + 4 + 2 +1 = 255 Bits 128 64 32 16 8 4 2 1 255 1 1 1 1 1 1 1 1 As you can see 255 is the highest decimal number you can create when you have 8 bits to play with. IMPORTANT: As you can see, whenever you add a bit, the decimal value doubles. For example: 2,4,8,16,32,64,128,256,512,1024,2048 and so on. This is called the “powers of 2”. HINT: This is a good moment to create your own “cheat sheet” . Take a piece of paper and write down the 8 bits for yourself. Purchased by TEE KIAN HONG, kian_hong2000@yahoo.com #2499490-
6. 6. How to Become the Binary and Subnetting Artist www.renemolenaar.nl Page 5 of 90 Exercise 1: See if you can solve the following decimal to binary calculations: Bits 128 64 32 16 8 4 2 1 12 54 187 192 44 147 Now try to do it the other way around and calculate from binary to decimal: Bits 128 64 32 16 8 4 2 1 1 1 0 0 1 0 1 0 0 0 1 1 1 0 0 1 0 1 0 1 0 1 0 1 1 1 1 1 0 0 1 1 0 0 1 0 0 0 0 1 1 0 0 0 0 1 1 1 The appendix of this book will show you the answers. Purchased by TEE KIAN HONG, kian_hong2000@yahoo.com #2499490-
10. 10. How to Become the Binary and Subnetting Artist www.renemolenaar.nl Page 9 of 90 Class A: Back to our network addresses, let’s take a look at Class A. The first bit always has to be a 0. This leaves us 7 bits to “play” with. The lowest value you can create by changing all bits to “0” is 0. By changing all 7 bits to “1” you get 127. Bits 128 64 32 16 8 4 2 1 0 0 0 0 0 0 0 0 0 127 0 1 1 1 1 1 1 1 64 + 32 + 16 + 8 + 4 + 2 + 1 = 127. As you can see the Class A range is between 0. and 127. Class B: For a class B network the first bit has to be a 1. The second bit has to be a 0. Bits 128 64 32 16 8 4 2 1 128 1 0 0 0 0 0 0 0 191 1 0 1 1 1 1 1 1 128 + 32 + 16 + 8 + 4 + 2 +1 = 191 As you can see class B networks always start with 128. and the last network is 191. Class C: For a class C network the first bit has to be a 1, the second bit a 1 and the third a 0. Bits 128 64 32 16 8 4 2 1 192 1 1 0 0 0 0 0 0 223 1 1 0 1 1 1 1 1 128 + 64 = 192 128 + 64 + 16 + 8 + 4 + 2 + 1 = 223 As you can see Class B networks start at 192. and the last network is 223. Class D and E: There is also a class D for multicast traffic which starts at 224. and ends at 239. Class E is for “research usage”. We are not going to use these classes for our binary calculations. Purchased by TEE KIAN HONG, kian_hong2000@yahoo.com #2499490-
30. 30. How to Become the Binary and Subnetting Artist www.renemolenaar.nl Page 29 of 90 Broadcast address: The broadcast address has all host bits set to 1 so the broadcast address we get is: 10.23.255.255 Network 10 23 255 255 00001010 00010111 11111111 11111111 Alright so that’s subnetting a Class A network! I showed you how to do all of this in binary and by now you should have a good understanding how it works “under the engine”. In the next chapter I’ll show you how to do subnetting a whole lot faster, and even off the top of your head! Purchased by TEE KIAN HONG, kian_hong2000@yahoo.com #2499490-
31. 31. How to Become the Binary and Subnetting Artist www.renemolenaar.nl Page 30 of 90 4. Subnetting: The Fast Way You have probably seen enough binary numbers now, so let’s work some more with decimal numbers. We can do subnetting just by working with decimal numbers. As you have seen in the binary examples, the rule of “powers of 2” is very useful. By taking an extra bit the decimal value doubles every time: - For every host bit you borrow the number of subnets you can create doubles. - Every host bit left doubles the size of the subnet. Instead of thinking/working in binary, we’ll start thinking in “blocks”. Take this 192.168.1.0 network with subnet mask 255.255.255.0 as an example: We know because the subnet mask is 255.255.255.0 we have 8 bits left, and with 8 bits the highest “number” we can create is 256. 128 + 64 + 32 + 16 + 8 + 4 + 2 + 1 = 255. Don’t forget about the 0! The 0 is being used so the highest value you can create is 256. Visualize this as a block: “256” We want to subnet our 192.168.1.0 network, so we’ll chop our “block” in 2 pieces. When we chop this block in 2, this is what we get: “128” “128” So now we created 2 subnets out of our Class C network, the next questions are: - What are the network addresses? - What are the broadcast addresses? - What is the subnet mask? - What are the usable host IP addresses? The network addresses we can write down, they are both blocks of “128”, we’ll start at 192.168.1.0 and the 2nd subnet will be 192.168.1.128. From .0 - .127 = “128”. Purchased by TEE KIAN HONG, kian_hong2000@yahoo.com #2499490-
37. 37. How to Become the Binary and Subnetting Artist www.renemolenaar.nl Page 36 of 90 We start with our block of “256” but now we are playing with the 2nd octet: “256” Let’s chop it into 4 blocks: “64” “64” “64” “64” Let’s write down the networks, all “blocks” of 64: Subnet #1: Network: 10.0.0.0 Subnet #2: Network: 10.64.0.0 Subnet #3: Network: 10.128.0.0 Subnet #4: Network: 10.192.0.0 Step 2, write down the broadcast addresses: Subnet #1: Network: 10.0.0.0 Broadcast: 10.63.255.255 Subnet #2: Network: 10.64.0.0 Broadcast: 10.63.255.255 Subnet #3: Network: 10.128.0.0 Broadcast: 10.191.255.255 Subnet #4: Network: 10.192.0.0 Broadcast: 10.255.255.255 So what will the subnet mask become? 256 – 64 = 192. That will make 255.192.0.0 Purchased by TEE KIAN HONG, kian_hong2000@yahoo.com #2499490-
39. 39. How to Become the Binary and Subnetting Artist www.renemolenaar.nl Page 38 of 90 5. Classless Inter-Domain Routing Once upon a time when the IP addressing scheme was invented, the people who developed this thought it would be enough to have 3 different classes as we have seen so far, class A,B and C networks. There were only 3 subnet masks: Class A 255.0.0.0 16,777,216 Class B 255.255.0.0 65,536 Class C 255.255.255.0 256 These networks are also known as “classful networks”. When the internet started growing rapidly in the beginning of the 90’s this caused some problems. There were only 16.000 class B networks available which are used by a lot of medium sized companies, imagine they only needed 1000 IP addresses this would mean about 15.000 IP addresses would be wasted. A class C would be too small because you only have 256 IP addresses, and taking a couple of class C networks is no scalable option. The solution to this problem is Classless Inter-Domain Routing, in other words we stop working with the classful networks and start working with classless networks. Classless networks means we don’t use the Class A,B or C networks anymore but are free to use any subnet mask we like, and most often you will see this in a bit-notation. For example: 192.168.1.0 255.255.255.0 Is the same as 192.168.1.0 /24 Instead of writing down the full subnet mask we only specify how many bits the subnet mask is. 172.16.1.0 255.255.0.0 Is the same as: 172.16.1.0 /16 10.0.0.0 255.0.0.0 Is the same as: 10.0.0.0 /8 One more: 172.16.1.64 255.255.255.192 Purchased by TEE KIAN HONG, kian_hong2000@yahoo.com #2499490-
40. 40. How to Become the Binary and Subnetting Artist www.renemolenaar.nl Page 39 of 90 Is the same as: 172.16.64 /26 Here’s a little overview with the CIDR notation and the full subnet mask: 255.0.0.0 /8 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 255.255.128.0 /17 255.255.192.0 /18 255.255.224.0 /19 225.225.240.0 /20 255.255.248.0 /21 255.255.252.0 /22 255.255.254.0 /23 255.255.255.0 /24 255.255.128.0 /25 255.255.192.0 /26 255.255.224.0 /27 255.255.240.0 /28 255.255.248.0 /29 255.255.252.0 /30 Do you see the pattern here? The numbers are the same, it’s just a different octet you are playing with. For example take a look at /11 or /19. 255.224.0.0 or 255.255.224.0. Or for example /18 or /26. 255.255.192.0 and 255.255.255.192. HINT: Expand your own cheat sheet by adding the CIDR notation and the subnet masks. I would also recommend that you write down the size of the subnet mask behind it. For example take the /26 mask. You know the subnet mask is 255.255.255.192. 256 – 192 = 64. So the size of the subnets is “64”. I believe the CIDR notation is easier then writing down the complete subnet mask, saves some time. Unfortunately on most operating systems and network equipment you still have to configure the full subnet mask instead of the CIDR notation. Purchased by TEE KIAN HONG, kian_hong2000@yahoo.com #2499490-
44. 44. How to Become the Binary and Subnetting Artist www.renemolenaar.nl Page 43 of 90 First host: 192.168.1.97 Last host: 192.168.1.112 Broadcast: 192.168.1.113 Subnet #4: Network: 192.168.1.112 First host: 192.168.1.113 Last host: 192.168.1.114 Broadcast: 192.168.1.115 Here we go, we just subnetted our 192.168.1.0 by using VLSM. Let’s try another example but this time we use a Class B 172.16.0.0 network and different requirements: - One subnet for 340 hosts. - One subnet for 250 hosts. - One subnet for 31 hosts. - One subnet for 20 hosts. - One subnet for 8 hosts. To solve this question first we need to determine the “block” that we require: - To fit in 340 hosts we need 2x 256, or a block of “512”. - To fit in 250 hosts we need a block of 256. - To fit in 31 hosts we need a block 64. - To fit in 20 hosts we need a block of 32. - To fit in 8 hosts we need a block 16. Pitfall: because of the network and broadcast address, in a block of 32 you only have 30 usable host IP addresses. That’s why we need a block of 64 to fit in 31 hosts. Let’s write down the subnets and network addresses: Subnet #1: Network: 172.16.0.0 Subnet #2: Network: 172.16.2.0 Subnet #3: Network: 172.16.3.0 Subnet #4: Network: 172.16.3.64 Subnet #5: Network: 172.16.3.96 Subnet #6: Network: 172.16.3.112 (this is where the Free space starts) Now we need to find the broadcast addresses: Subnet #1: Network: 172.16.0.0 Broadcast: 172.16.1.255 Purchased by TEE KIAN HONG, kian_hong2000@yahoo.com #2499490-
47. 47. How to Become the Binary and Subnetting Artist www.renemolenaar.nl Page 46 of 90 c. One subnet that’s fits 7 hosts. d. Write down the network/broadcast addresses and the host IP addresses. The appendix of this book will show you the answers. If you made it this far and tackled all the different subnetting questions…good job! You have seen how to solve these questions in binary, decimal and by using CIDR and VLSM. 7. Summarization When you are into networking and routing in particular, you are probably familiar with the concept of summarization. In the picture below we see 2 routers, router A has the following networks configured: 192.168.0.0 / 24 192.168.1.0 / 24 192.168.2.0 / 24 192.168.3.0 / 24 When we configure a routing protocol, all 4 networks will be advertised and seen in the routing table of Router B: Router B routing table: D 192.168.0.0/24 via 192.168.12.1, 00:00:02, FastEthernet0/0 D 192.168.1.0/24 via 192.168.12.1, 00:00:02, FastEthernet0/0 D 192.168.2.0/24 via 192.168.12.1, 00:00:02, FastEthernet0/0 D 192.168.3.0/24 via 192.168.12.1, 00:00:02, FastEthernet0/0 Purchased by TEE KIAN HONG, kian_hong2000@yahoo.com #2499490-
48. 48. How to Become the Binary and Subnetting Artist www.renemolenaar.nl Page 47 of 90 By configuring summarization we can make sure the routing table on Router B will become smaller and have only a single entry, check out the following picture and routing table: Router B routing table: D 192.168.0.0/22 via 192.168.12.1, 00:00:02, FastEthernet0/0 As you can see there is only a single entry in router B’s routing table, which is a summary of the 4 networks on Router A. There’s a whole lot to talk about summarization which is outside the scope of this book, but the skills needed to create good summaries are the same as for subnetting. If we want to create a summary for these networks: 192.168.0.0 / 24 subnet mask 255.255.255.0 192.168.1.0 / 24 subnet mask 255.255.255.0 192.168.2.0 / 24 subnet mask 255.255.255.0 192.168.3.0 / 24 subnet mask 255.255.255.0 We need to think about the CIDR notation / subnet mask we choose for this summary, so what numbers matches these 4 networks? As you can see we have 4 networks, or when we speak in ‘blocks’ it’s a block of 4. Take 256 – 4 = 252. The subnet mask will be 255.255.252.0 This is also called ‘supernetting’. Purchased by TEE KIAN HONG, kian_hong2000@yahoo.com #2499490-
50. 50. How to Become the Binary and Subnetting Artist www.renemolenaar.nl Page 49 of 90 Exercise 8: See if you can create the following summaries: 1. Combine the following networks into a single summary: a. 192.168.1.0 / 24 b. 192.168.2.0 / 24 2. Now try this one: a. 172.16.0.0 / 16 b. 172.16.1.0 / 16 c. 172.16.2.0 / 16 d. 172.16.3.0 / 16 3. Last one: a. 10.0.0.0 / 8 b. 11.0.0.0 / 8 c. 12.0.0.0 / 8 d. 13.0.0.0 / 8 e. 14.0.0.0 / 8 f. 15.0.0.0 / 8 g. 16.0.0.0 / 8 h. 17.0.0.0 / 8 The appendix of this book will show you the answers. Purchased by TEE KIAN HONG, kian_hong2000@yahoo.com #2499490-
51. 51. How to Become the Binary and Subnetting Artist www.renemolenaar.nl Page 50 of 90 8. Hexadecimal calculations In the networking universe you sometimes have to calculate from binary to hexadecimal, or from decimal to hexadecimal and the other way around. Mac addresses and IPv6 are a good example of this. In the decimal system we count from 1-10, in the hexadecimal system we count from 1 – F. Check out this example: Decimal Hexadecimal 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 1 2 3 4 5 6 7 8 9 A B C D E F That’s not so bad right? Now if you want to calculate from binary to hexadecimal there’s a trick you need to master. Let’s say you have the decimal number “128” in binary: 128 64 32 16 8 4 2 1 128 1 1 1 1 1 1 1 1 If you want to convert this to hexadecimal you need to cut the 8 bits in 2 parts of 4-bits (4 bits is also known as a “nibble”). 1111 1111 Now take a single nibble, and convert it into decimal: 8 4 2 1 15 1 1 1 1 Do the same for the next nibble: Purchased by TEE KIAN HONG, kian_hong2000@yahoo.com #2499490-
53. 53. How to Become the Binary and Subnetting Artist www.renemolenaar.nl Page 52 of 90 9. Tackling miscellaneous subnetting questions This will be the final chapter, right now you have seen all the different tools needed to become a true binary and subnetting calculations artist. In this chapter I will show you some of the common subnetting questions you might encounter and how to tackle them. Hint: The cheat sheet you created so far is a great tool to solve these kind of questions. Subnetting Question #1: You have the IP address 192.168.1.22 / 27 and are wondering what kind of IP address this is, a network address? Broadcast address? Or perhaps a valid host IP address? Let’s find out: a) First we need to find out what subnet mask the /27 is. /24 = 255.255.255.0 /25 = 255.255.255.128 /26 = 255.255.255.192 /27 = 255.255.255.224 b) Now we know the subnet mask we need to find out how big this subnet is: 256 – subnet mask = size of subnet. 256 – 224 = 32. So the size of this subnet is “32”. c) Now we can write down the subnets: Subnet #1: Network 192.168.1.0 Subnet #2: Network 192.168.1.32 Subnet #3: Network 192.168.1.64 Purchased by TEE KIAN HONG, kian_hong2000@yahoo.com #2499490-
56. 56. How to Become the Binary and Subnetting Artist www.renemolenaar.nl Page 55 of 90 10. Create your own cheat sheet If you are practicing on the binary and subnetting questions it’s easy to have a cheat sheet. It’s even better if you know how to create one yourself, so let’s take a look how to do this: 1) Write down 8 bits: 128 64 32 16 8 4 2 1 2) Now write down the CIDR notations and the subnet masks behind it. Write down everything from /16 to /30. For example, you know that a /24 is 255.255.255.0. If you take a /26 you are borrowing 2 host-bits: 128 64 32 16 8 4 2 1 1 1 0 0 0 0 0 0 128+64 = 192. So the subnet mask is 255.255.255.192 3) Now you have the CIDR notations and the subnet masks, it’s time to write down the size of the subnets. Remember this formula: 256 – subnet mask = size of subnet. For example, take the /26 CIDR notation with subnet mask 255.255.255.192. 256 – 192 = 64. So the size of the subnet mask is “64”. Write down all of them from /16 to /30. That’s it! If you get any questions on subnetting you can see in the blink of an eye what the CIDR notation is, the subnet mask and how big the subnet size is. This will save time because you don’t have to do the calculations over and over again. Purchased by TEE KIAN HONG, kian_hong2000@yahoo.com #2499490-
58. 58. How to Become the Binary and Subnetting Artist www.renemolenaar.nl Page 57 of 90 Appendix A – Answers to exercises Exercise 1: See if you can solve the following decimal to binary calculations: To solve this question just take the decimal number and start at the MSB (most significant bit) and see if it “fits in”. To convert the decimal number 12 to binary, 128 is too big, 64 as well, 32 also, 16 is too big so we put a “0” here. 8 fits and when we add 4 we already have 12. Bits 128 64 32 16 8 4 2 1 12 0 0 0 0 1 1 0 0 54 0 0 1 1 0 1 1 0 187 1 0 1 1 1 0 1 1 192 1 1 0 0 0 0 0 0 44 0 0 1 0 1 1 0 0 147 1 0 0 1 0 0 1 1 Now try to do it the other way around and calculate from binary to decimal: You need to add all the bits with a “1” to get the decimal value, for example the first one: 128 + 64 + 8 + 2 = 202 Bits 128 64 32 16 8 4 2 1 202 1 1 0 0 1 0 1 0 57 0 0 1 1 1 0 0 1 85 0 1 0 1 0 1 0 1 243 1 1 1 1 0 0 1 1 33 0 0 1 0 0 0 0 1 135 1 0 0 0 0 1 1 1 Purchased by TEE KIAN HONG, kian_hong2000@yahoo.com #2499490-