Transcript for:
Exploring Network Subnetting Basics

Hello friends, welcome to ITK Funday, your own channel where we make IT interesting for everyone. So continuing from our previous video where we understood IP addressing in depth and in detail, we will now cover what is network subnetting which is a very very key fundamental of our networking concepts and in this video we will understand Again, we will start with a quick recap of IPv4 basics, but still I would recommend you go and check that video because we have gone in depth into every aspect of IP address. But in this particular video, we will touch base on some fundamentals which will be important for us to understand subnetting. After that, We will understand subnetting with a very very layman perspective with a real life example and then we will start with some basic fundamental blocks of subnetting like subnet mask, network id, host id, again what is cider range and all those concepts and at the end we will take a simple example to understand it in totality. So let's get started. Please subscribe to my channel and hit the bell icon. So friends, let's do a quick recap of what we learned in our previous video. Again, this will be a very, very quick recap. So I would highly recommend that if you're new to this concept, go and check that video in detail. So an IPv4 address is a 32 bit logical address wherein you have dotted decimal notation to give give a unique identity to a device over the network. So every network device would have an IP address with which it would be identified uniquely over the network. these are divided into 8 bits and you know every every particular set is called as a octet. Okay, so we have four octets. So 8 into 4 we have 32 bit logical address. Now this particular IP address will have two components. One would be your network bits another would be your host bits. Now how it will vary we will understand but understand that every IP address is a combination of some network bits and some host bits. So if you have 32 bits, you can have 16 bits of network and 16 bits given to the host and like that so always remember that your network bits are always denoted by one and your host bits are always denoted by zero when you are doing subnetting you will come to know about this when we'll go into more detail again your ip address is categorized into five different classes class a class b class c class d and class e And we are not discussing class D and E. If you want to know more, you can watch that video. But for now, these are the three primary IP address classes which are used today. And these are the ranges for the same. So class A ranges from 0 to 126. Class B is from 128 to 191. And class C is from 192 to 223. So just by looking the IP address of any kind, you can identify that which particular class it belongs to. So based on your IP address classes, you identify that how much bits are given to the network and how many bits are given to the host. It is predefined. So for a class A, it is mandatory to give the first octet or your first eight bits to the network and rest are for the host. So 8, 8, 8, these three are given to the host. And in class B, we have first two octets. So 16 bits. and 8 you can see here okay one octet is 8 bits so 8 and 8 16 for the network 16 for the host in class c you have you have first three octets which are eight eight eight 24 bits given to the network and only one particular octet or eight bits given to the host so based on your need you decide whether you need a class a class b or class c uh ip address range Again, we have gone into more detail in our last video. So go check that out if you want to know more, but this is good enough to have a basic understanding of how you know these IP address classes are defined. Now we this is this is pretty much about IPv4. Now we will go to subnetting and we'll try to understand it from a layman perspective taking a real life example. And then we will touch base upon some of these concepts when we'll go into the core of networking fundamentals. So let's take an interesting example. So let's start by an interesting real life example. So let's take an example of this Eurorail. Eurorail is a famous railway service in Europe which helps passengers travel Europe going across country. So suppose this is one of those trains where we have four different coaches and every particular coach is reserved for a specific country. So coach A is for Spain, coach B is for France, coach C is for Germany and coach D is for Italy. by default we have hundred seats built into these coaches and you cannot have more than hundred passengers obviously because you have only hundred seats available but just suppose just before the journey the bookings opens and a booking for Spain goes hundred full and for France also it goes full for Germany it gets overbooked so it goes to 150 and for Italy it is only partially utilized and and it goes to take for example 10. Okay, so now there is a problem because we have more passengers going in Germany. Okay, but they cannot accommodate that because Germany has only 100 seats available and those all are filled. But then the service would lose on to those 50 passengers wherein in Italy we are losing anyways because out of 190 seats are anyways going as vacant. Okay, so a general phenomena what we see is that the passengers are not allowed to go in. is that these 50 passengers can be accommodated into compartment D for Italy. And how it will be done? Because understand that by default the railway rule says that every compartment should have at least 20 seats reserved at any time, at any condition for that particular country. So, 20, 20, 20, 20 should always be reserved. But in this case, in Italy, we have only 10 bookings. And even if we add 10 more, it goes to your 20 reserved quota. So we still have 10 more seats available here. And here we only need 50 to be adjusted. So even if we, if we take 100 for Italy, okay. And in that we minus the 20 reserved seats. So we are left with 80. 80 seats are still available. So what will be done? these 50 passengers will be adjusted into this and still it will have 30 seats left which is fine because now everyone has been adjusted. So what would be the new setup? New setup would be that obviously for Spain compartment A we have 100 which is not a problem. For compartment B France we have 100 that's not a problem. For compartment C also now we have for Germany we have 100 and for compartment D Now we will have 50 which were moved from here to here plus the existing 10. So it will go to 60. You are understanding my point, right? So what it did? What the railway service did? Railway service adjusted some of the passengers from this particular compartment to this compartment to allow more utilization of seats and reduce the wastage of resources because unnecessarily you know Italy coach was anyways going most mostly empty this is the exact way subnetting works so now subnetting what exactly does which which we will understand is it helps you utilize your network network bandwidth more intelligently so as we just now saw that we have already predefined network and host bits for your class a class B and class C But suppose you have a requirement wherein you do not require so many networks to go waste or so many hosts to go waste. In that case, you divide one particular network into multiple sub networks based on your usage. And that is precisely what is subnetting. So friends in a typical class A, class B and class C IP address ranges, we already have predefined number of bits dedicated to network which you see in red and rest are you can see in blue are for the host. So as you can see for class A we have eight bits dedicated to the network and rest 24 are dedicated to host which results in around 16 million hosts. In class B we have 16, for network and 16 for your host which results in 64000 hosts and for class C we have 24 dedicated to network and only 8 bits given to the host and that results in 256 hosts now you might be wondering how I am coming to this calculation so friends always remember this power of 2 in decimal and while working with IP addresses or overall networking you will find it very handy So whenever you want to calculate any, you know, any decimal number based on your binary number, then you can use this power of two. We will see this how. Okay. So just understand that if you get any requirement for around 500 computers, suppose you have to put 500 computers in your office into your particular network address. Now obviously. class C you will first go for but in class C you have only 256 you know hosts available so the only option which is left for you is to switch to class B but then the range is so high you know there are 64,000 hosts there and you just need 250 more odd hosts to be adjusted and for that you will waste so many you know host bits or the you know host IDs which can be utilized more efficiently so suppose there is a network connection coming from internet and going to your router okay and this router has this particular ip address which is coming in and now it has to you know it has to distribute it into multiple subnets so it can divide that using subnetting okay else you know this whole network this whole network will might not be utilized fully so you can divide it into five different subnets just remember like in our one of our very famous videos on networking we took example of a school So in a school we can have one particular maybe you know network coming in okay and then it could be divided into five different classes okay so based on that based on your utilization you can have one network coming from your internet or any any other uh outside network to your router and then your router based on your subnetting what subnetting you have done will distribute it internally so for outside world it is still the network to go into it is still the IP address to go into but internally this particular IP address has been you know has been facilitating so many different multiple subnets so that in that way you utilize your network bandwidth very intelligently and that's why submitting becomes so very important. So now let's understand some basic terminologies which we use and what does exactly it exactly means in in the world of submitting. So subnet mask is nothing it has no it is not an entity to be recognized on the network it is a term which is used to denote or to specify in an in an IP address how many bits are given to the network and how many are given to the host. So take for example your class A IP address okay so what would be the subnet mask for this so you have to simply see you know the number of bits given to the network okay so how many bits are given to the network all the eight bits okay all the eight bits means if you add all these eight bits okay based on the power of two table it will come on to 255 so any octet will not have a maximum value more than 255 okay i have told that in the previous video also so what would be the subnet mask for this particular ip address it would be 255.0.0.0 okay Similarly for class B, it would be 255.255.0.0 and for class C, it will be 255.255.255.0. Okay, so it is class A, B and C. So just by looking at your IP address and your subnet mask, you can very clearly identify that which particular Bits are given to the network and which are given to the host. So now what we learned about subnetting subnetting is is always done from left to right. Okay. So what your network admin will do suppose take for example this class C IP address. Okay. Now, it already has 24 bits given to the network. But when we will do subnetting, we will creep into the host bits, okay, we will creep into the host bit and maybe take maybe take, you know, maybe these many bits. Okay, I'm just doing it like this just to make you understand. Okay. So now what has happened? All these will become one. Okay, all these will become one. So we already had 24 and we took three bits, three bits from this particular octet and how you will take it, it will be based on your subnetting needs, how many subnets you want to create, which we will see with an example, but just understand that suppose you took three bits from this. So now what happens 24 plus three, so you have now 27 bits, 27 bits given to the network. So in that case, now what will be your subnet mask? So now with this concept coming in, another concept comes into picture which is CIDR range. What is a CIDR range? CIDR range is classless inter domain routing. That means that regardless of any class, simply by looking at your CIDR notation, you can simply identify which bit of your IP address is network and which bit is for host. So suppose in this particular example, suppose if we take any particular class C IP address, then it will be denoted by slash notation and then the total number of bits. So take for example, if we take any IP address of a class C, so if you take 202.201.150.10, so you remember the range, right? So this falls into class C range in that class C range in the cider notation how you will write it you will simply add a slash and then it will be 27 you already had 24 by default class C has 24 and then you have creeped in sorry I'm using this word but you are actually taking some bits and doing that utilizing that for the network so these three bits will get added and then your cider notation will be 27 So regardless of any class or any IP, okay, regardless of any class, suppose if I just take a random IP, okay, so if I take 15.10.65.40, okay, and if I put slash 15, okay, if I put simply slash 15, that means that for this particular IP address, regardless of its class, 15 bits have been, you know, given to the network. So now I hope you are understanding and if you now look deep, this is class A IP address. By default class A has only 8 bits given to the network, but we have given 15 more. That means we have taken 7 bits, 7 bits from here. So how many? 1, 2, 3, 4, 5, 6, 7. And I always said it is always left to right. Okay, so it will be like this. So if I rub this, Okay, it will be 1 1 1 1 1 1 1 1 1 2 3 4 5 6 7. So now this is denoting this particular IP address. Okay, so this is the way your subnet mask or your CIDR range is helpful to understand how many bits are given to the network and how many bits are given to the host. Now the third concept is your network ID. What is a network ID? So every subnet will always have its first IP starting IP as your network IP or network ID. So suppose if you divide a network into five different subnetworks, then every subnetwork will have a unique network ID with which it will connect to the network. So suppose a router wants to connect to a subnet, then it will remember its network ID or it will derive its network ID. based on the IP address of the device. Okay, so that we will see how it is derived. But just understand that network ID is your first ID of your subnet range. Okay. Now the fourth concept is your broadcast ID. So your broadcast ID is your last ID, your last IP address of your subnet range. And this particular broadcast ID is utilized to talk to your subnet. So to all your host within that particular network. Okay, so broadcast the word broadcast means broadcasting it to an open audience. So suppose if you have a range from suppose just for example, if you have a range of 1 to 10, okay, then 1 would be your network ID and 10 would be your broadcast ID and in between those 9 would be your actual host. So in this way, we have your subnet mask, which denotes which particular bits are network and which particular bits are your host. CIDR does the same thing with slash notation which makes it more easy. And then you have your network ID and your broadcast ID. Now let's take an example and understand that if we simply have one particular IP with a CIDR range, how we can understand what is its subnet mask, what is its network ID, what is its broadcast ID. Okay. So, let's understand that. Guys, let's take an example and understand it in more detail. So suppose we have an IP address with a CIDR notation 205.150.65.26. Now just by looking at this IP address and this CIDR notation, we have to identify what will be its subnet mask, what will be its network ID, its broadcast ID, how many number of subnets we can have, how many number of hosts we can have, all these things. So Let's take it by example and we'll go step by step. But before that, we have to understand two important formulas which we will understand with the help of this example. So first of all, just focus on this. Whenever you get this kind of a CIDR notation, just see it is 26. So what it is denoting that by default, you have 32 bits in an IP address. If you see you know this, this looks like a class C IP address. So by default, you have 24 predefined. and then after 24 you have two more so instead of like just if I have to add it here so instead of three like here we'll just make it two okay and this will become zero this will be zero and these two will still be one okay and your network range will be till here okay so what you have done you have increased your network from 24 to 26 bits now this is this is clear now based on this what would be your subnet mask How you derive your subnet mask? So your subnet mask you already know that by default you have for class C subnet mask 255.255.255. Now ideally it is a zero in a normal case when we have a normal IP range but now we are doing subnetting. So what we are doing we are borrowing some of the bits from your host octet and giving it to the network. So how many bits we have taken from here to so how you will calculate your subnet ID, you have to just add these two bits and see what is the what is the total. So if you if you take, you know the power of two concept into this, then this is two to the power seven, and plus the next one is two to the power six, which is 128 plus 64. See 128 and 64. Okay, and always remember it starts with 0. So 0 1 2 3 4 5 6 7. So what is the total total comes out to be 192. So what would be your subnet mask with mine with a slash 26 sider notation, your subnet mask will be 192. This is your subnet mask. Now, the next question is what is your network ID? What is your network ID? Okay, so for that, there is a binary operation which you have to do which is called as logical and operation what is a logical and operation whenever you have an IP address and when you derive your subnet mask, you have to do an and operation here. So in binary and means so if you have to take and operation understand and operation so it is 1 into 1. Okay, 1 into 0 0 into 1 or 0 into 0 Okay, these can be the four combinations So in this case, it will be 1 in this case It will be 0 in this case what you have to do You have to convert your IP address into binary and you have to also convert your subnet mask into Binary and then do a and operation Okay, and then whatever will be the binary output you will have to calculate it back to decimal and then that will be your network Id but it is it can be very very difficult task. So a quick quick thing to do in this case is if you open your Windows laptop and just go to run calculator open a calculator and there is a setting like if you go into file There are some advanced mode of calculator, which maybe I'll give you a demo in this video somewhere So in that you can simply do an and operation just by adding up these bits. Okay, just based on your decimal numbers only. So in this case, if I use a calculator, and I do an operation, I am pretty sure the network output would be 205.150.65.0. Because anything multiplied so in this case this particular bit is all ones okay so this won't change this is constant okay because all these are ones okay so this won't change this too if you Simply do it through decimal also it is coming as 0 because anything divided multiplied by 0 would be 0 So that's why your network ID is 205 dot 150 dot 65 dot 0 Now the next question which comes to our mind is how we will know that how many subnets we can create from this particular You know subnet by looking at this subnet mask How many number of subnets are possible and how many number of hosts are? possible within those subnets. Okay, so for that there is a formula. So what is that formula? So in order to calculate number of subnets, it is two to the power n okay and for number of hosts. It is 2 to the power n minus 2, wherein n is your bits. So in this particular case, if we take the SIDAR example of 26, you have your first two bits of your last octet as I showed you here given to your network. So what would be the formula? As per the formula, you have to give two bits here. So what would be that? 2 to the power 2 and that would be 4. So four subnets are possible. Just by looking into this CIDR range, we have derived so much information. Now, how many number of hosts? So if you have given the two bits to the network, res 6 still belongs to the host. So you will do 2 to the power 6 minus 2. So as per the power of 2 table, 2 to the power 6 is 64 minus 2. So it would be 64 minus 2. That would be 62 hosts. So now just by starting with an IP address in a CIDR range, we derived the subnet mask, we derived the network ID, we derived the number of subnets and number of hosts. Now one thing is remaining, what would be the broadcast IP? Okay, what would be the broadcast IP? So now just by looking at how many number of hosts we can accommodate, we can start. So what is your starting IP address, your starting IP address is 205. And let me just Let me just run this. I hope now you have the power of two in your mind. So let me rub this out. So now, now we have so just by looking at this example, what we have derived, we have derived the subnet mask, we have not derived the network ID doing the AND operation between your IP and your subnet mask. And then after that, we have derived number of subnets possible. with this particular range and number of hosts. So, 4 subnets and 62 hosts. So, just looking by example if you see this, now what is remaining? Now, the one thing which is remaining is your broadcast IP. Okay, so one thing which is still remaining is your broadcast IP. So what will be your broadcast ID as I told you in any subnet your first IP is your network. Your last IP is your broadcast and the middle ones are your host. Okay, always remember that. So how many hosts you have you can accommodate here 62. Okay, so what would be your broadcast IP so your first IP started with 205 150.65.0 this is your network. Okay, now, If we talk about a host range, so host range which a host range how it will start Just take that example. Okay, so host range would be 205 dot 150 dot 65 Dot 1 from here. It will start and it will go that dot dot and then it will go till dot 62 Because you can only have 62 hosts in one particular You know subnet so guys just by looking at your network ID Which starts with dot zero and looking your host range which starts from one end and that 62 dot 62 because you can only have 62 hosts by default It's very very evident that after all these three the last IP would be your broadcast IP So what what it would be it would be 205 dot 150 dot 65 dot 63 so this would be your broadcast IP after you know after counting your network and your host IPs the last one would be your 63 and then you can continue in this manner and you can create four different you know networks from it so your next network address will start from dot 64 and then it can go so you will have four different blocks of subnets which can be dedicated and which can be clearly utilized. Okay. Now, this is the way just by looking at the example and IP address example and a cider range. You can derive so many details but there can be another question which can be asked. Now friends, let's take another example to identify that how we can get another kind of queries in subnetting. So suppose I have been given this IP address with slash 24 notation which is standard notation for our class C IP address. So its subnet mask would be 255.255.255.0. But now I have been asked that you create 10 subnets. 10 subnets. out of this particular IP address just by looking into this particular IP address you derive 10 subnets out of it. So now how you will do it though. So the mechanism would flip a bit but I will try to explain it. So as as the question says create 10 subnets. Okay, so we clearly know that we clearly know that we need 10 subnets. So as we remember the formula for creating the subnet was to the power n. Okay, so in this case, we have to remember the power of two table okay, and try to see where 10 fits into that. So if we take two to the power one, it's two two to the power two, it's four, two to the power three, it's eight, and two to the power four is 16. Right? So we have two to the power one, two to the power two, two to the power three and two to the power four. So in order to create 10 subnets, You cannot use until up till here you have to use this particular subnet. Okay, so what it is it is using four bits. So in this case instead of you know our previous example, we have to now go and we have to now take more space into this particular octet. So now we are saying that we need four bits. Okay, so one two three four. Okay. So what will be your cider range now if you have to get 10 subnet. So if you have to derive it again, so it would be 205.150.65.0 slash now 24 was by default. Now for creating four subnets, you have to encroach into your host get some more out of that. So in that you will have 28. because what you have done out of your 8 bits you have taken 4 bits. Okay, those 4 bits you have taken and now your cider range has become 8. Okay. So in this way what you have done just by getting the example 10 subnets. You have to create you simply took that and you you know, you maintain that now the next I next thing would be to get the network ID in this case. Also you have to get your subnet mask. Okay, so your subnet sorry for this mistake. So in this case your subnet mask would be slash 28. So what it would be? So let me show you the subnet mask. So actually the subnet mask would be 255.255.255. Now the first four bits you have to add. Okay, so first four bits we have to always go from left to right. Okay, so from here you have to add those bits So it will be 128 plus 64 plus 32 plus 16 Why because it is true to the power 7 2 to the power 6 2 to the power 5 2 to the power 4 So 1 2 3 4 bits. Okay, so if you add this so if you add this it comes to 240 So now instead of your initial subnet mask, which was like this because it was slash 24 now you will have the new subnet mask which will be 255.255.255.240 because you have now derived that you need 10 subnets and for 10 subnets to be accommodated you need 4 bits from your host octet. Okay? Now you got this far now what you have to do you have to understand that what would be your network ID so for that again the again the same formula applies you have to take this particular subnet mask put it in here and do the logical and operation okay after doing that logical and operation whatever will be the outcome would be your network ID so in this case what will be your network ID your network ID would be 205 dot 150 dot 65.0 again the logical and operation regardless of what you take for now if you do an and operation maybe on a calculator or just converting it into a binary then it will result into this particular ip address which will be your network id now the next part is we already knew from the Meaning that we need 10 subnets. That's why we took four bits out of this particular octet. Now, how many are remaining that will decide how many hosts I can have. So I told you the number of networks is two to the power n, which denotes your network bits, and then network number of host is two to the power n minus two. So in this case, your number of host bits are four because you have already taken four from here. So in this case, your you know, your this particular number of hosts would be Q 2 to the 4 to the 8 to the 16. So 16 minus 2. So you can have 14 hosts. Okay, 14 hosts you can have. And here again, we have already covered but just for just for understanding purpose, we will have we can have maximum of 16 subnets but the actual question was we only need 10 subnets so that's fine but we have to accommodate that with this so now we have 14 hosts here okay now based on your number your subnet number of subnets and then number of hosts and your network id is already there now you can derive your broadcast id so your broadcast id will be you just calculate this okay so your first id ip address is 205 dot 150 dot 65 dot zero. After that you will add 14 hosts. So it will start from so host range. host range will start from 205 dot 150 dot 65 dot one and it will go till 14 right So, in that case, what will be your broadcast IP your broadcast IP will be the last IP. So that would be I hope you guessed it. If I have made this tutorial in a better way. So it is 205.150.65.15. Okay let me write it clearly. It is 205.150.65.15. Okay, so this is your broadcast IP after giving 14 to the host 1 to the 1 to the network. So friends, I hope with these two examples, you are able to understand subnetting to a better detail and going forward. If you want to learn more you can explore subnetting to a wider detail. It has various you know various levels so once you start your journey you will find various different scenarios which you can learn as you go forward but this particular video would give you a good starting point at least i hope so so just to quickly recap we started with ipv4 basics then we went into a layman example and understood how subnetting works and then we understood the basic fundamentals of subnetting what is you know network id host id subnet mask and then eventually We understood how we take it and derive subnet mask broadcast ID, network ID, host range, everything taking examples. So I hope you like this video. If you did, please hit the thumbs up. Let me know in the comment section below what you would want to learn next. And yes, if you have not yet subscribed to this channel, please subscribe because we make IT interesting for everyone. So until then, thank you so much and keep hustling. Bye for now.