Clicky

How to Subnet a Network

A properly designed subnet can do wonders for the security and performance of a network. The main idea in subnetting is to divide a network into smaller pieces, which we call subnets. Actually implementing a subnet is typically more difficult than simply using the default subnet mask of 255.255.255.0. This usually means that temporary or smaller networks do not need to be subnetted.

Security sees benefit since the IP addresses of the host computers on each subnet are masked by the network address- which means they are invisible to the outside world. We call this network address translation, or NAT. This same technique helps conserve IP addresses, since all hosts on the subnet essentially just use the network IP address during communication.

A Basic Review on Subnetting

If you’re a little rusty on the basics of subnetting, don’t worry. We’ll cover everything you need to know from beginning to end. First thing first: we need to learn about the IP basics.

The current version of internet protocol, or IP, is IP version 4. This IP version allows four octets of data to represent an IP address. Each octet is considered to be a byte, so there are 8 bits in every octet. Note that in binary form you can see that there are 8 numbers, each one consisting of a bit. Finally, each octet is separated by a period, as shown below.

subnet

Each IP address is usually represented in decimal form, as seen above as “192.168.2.1”. However, each IP address is actually used by computers in binary form. You may have noticed a huge flaw in IP version 4: the amount of unique IP addresses is limited! To be exact, only 4,294,967,296 unique IP addresses can be created. This may seem like a large number but keep in mind every single device in the world needs a unique IP address to communicate with one another while online.

The IP version 6 protocol was created for when the transition is needed. Most computers don’t use IPv6 just yet, but in the future it will inevitably be used. (In case you were wondering, IPv6 will support 2^128 unique IP addresses… egad!)

Classes

There are three main types of classifications of IP addresses in IPv4: class A, class B, and class C. There are class D and class E types, but those are for multicasting and private uses, respectively. Each class differs by the number of network and host octets it has. Each network octet is for classifying which network a host is on. More network octets will mean more networks! Likewise, each host octet specifies a host that can be assigned to the network. More host octets means more computers per network.

Each class has a certain range that the first octet can be assigned to. This lets us know to what network class any IP belongs to with ease. Review the diagram below to see a visual diagram.

how to subnet

Now the bad news: you must memorize each range for each class if you hope to pass most network exams. Don’t worry! It’s actually easy- just memorize how we get the numbers, not the numbers themselves! All you have to do is remember n^8 (read as “n” to the eighth power), and how many network portions each class has. Review the diagram below.

subnetting a network

One final note before we move on. Notice how we didn’t use the IP address 127 for the class A network- that’s because this is loopback address. We use this for testing configurations on the IP network. Also take note that there are reserved IP addresses, such as those for private networks. These IP addresses will not connect to the internet, which is handy if you just want computers to be connected with each other- and not the whole world.

Subnet Masks

A subnet mask is what we use to assign different amounts of networks and hosts to an IP network. It essentially divides the IP address into two parts: the network and host. This is a trading game- the more hosts you have, the fewer networks you will have. And yet the more networks you have, the fewer hosts you will have. Review the class A default subnet masks as shown below.

class a subnet

The class B network will need to recognize two network portions, and two host portions. This can be seen in the below diagram.

class b subnet

Lastly, we have the class C subnet. It is the most commonly used subnet, so pay special attention to it in the upcoming lecture. You can see a diagram of the default subnet below.

class c subnet

We’ve laid Down the Foundation, Let’s Build the House!

We just reviewed the basics of IP addresses and subnet masks. The bad news is, we usually don’t use the default subnet mask at all when we subnet a network! The good news is, learning how to subnet isn’t too hard. It will, however, take some practice.

An Example of Subnetting a Class C Network

Subnetting varies in difficulty, depending on which class you are subnetting. More often than not, you will need to create a subnet for a class C network. A class C network allows for many networks to be created, but not as many hosts. In fact, you can create a hefty 2,097,152 networks- but only 254 hosts per network are allowed.

Let’s say we are subnetting a school’s network. We need 5 separate networks that have 30 computers on each subnet.

First we calculate how many usable subnets we need. Next we will need to determine how many hosts are required. Both of these values can be calculated with the following equations:

Two Important Equations to Remember:


  • 1. Usable Subnets = (2^n) – 2 , where N = power of bits assigned
  • 2. Usable Hosts = (2^n) – 2 , where N = power of bits remaining

Let’s start with usable subnets. Review the diagram below for a visual example.

subnet practice

If you are wondering what the “-2” part of the equation is for, this is how we account for the two addresses in each subnet we can’t use. We will review what these addresses are for more specifically later on. For now, let’s find out what our usable hosts are!

subnet solutions

Alright Already! What’s My Subnet Mask?!

Getting your subnet mask at this point is incredibly easy. Simply take all of your network bits, and add them up. Look at the diagram below for a visual guide.

subnet mask

That’s it! You’re done. You have successfully created a subnet mask that can be used on the school’s network. Keep in mind that every computer must have the subnet mask set in order for them to be on the same network. Also note that since we are using a class C network, the first three octets will always be 255. When subnetting other classes, be sure to keep the network portions in mind.

Closing Comments

Subnetting may not be fun, but it is required for students to know on networking exams. That means you should stay away from subnet calculators until you have grasped the full concept of how to do it yourself. These calculators should only be used as a time saving tool, not a learning tool or way to cheat on homework.

With enough practice, subnetting will become much easier. Class A and Class B networks are a bit trickier, but follow the same example as shown above and it should be quite easy to accomplish.


There Are 80 Responses So Far. »

  1. […] NAT and so on. Check this web site out for a very visual way of illustrating what subnet is about: http://learn-networking.com/network-design/how-to-subnet-a-network Share and Enjoy: These icons link to social bookmarking sites where readers can share and […]

  2. i think this article was a great. easy to follow

  3. I have to say….thanks….this article is much more clear and efficient…now I have learn how to make a subnet…!!!yeap!

  4. I have searched the net and I should say I have not come across an article like this which is so easy to understand and learn the concepts.
    cheers

  5. thanks for the lovely article and I want to add that
    the amount of IPv6 is 34,028,236,692,093,846,346,337,460,743,177 Unique Ip Address

  6. This is a very well written article.Easy to follow.I am happy that I came across this.Thank you.

  7. Now this is a true, efficient, user-friendly, easy and simple way to teach subnetting. I search the whole internet almost but this tutorial is awsome. I appreciate you of publishing these tutorials here. Thanks a ton !!

  8. HI,
    very nice work,
    u really have a smooth way to deliver information, thanks for the clear efforts ur making.
    allow me to mention a small note here regarding the use of (N) and (n) , i think replacing N with 2 in the tables would be less confusing while using (N and M) or N and (32-N) in the equation will make it more rational..
    all my respect.
    and thanks again.

  9. This tutorial should be put in a place of honor. The best!!!

  10. Thank you, I now have a better understanding of subnet masks.

    Chris.

  11. Thanx very much!

    For sure its a long time since i was looking for this but today you change ma brain.

    I really like the way you deliver information/skills, it seems to me very tough to study it in my class n get the concept of subnetting. But today am sure i may even taught someone n get the real meaning of subnetting.

    If u don mind can u please give us some more example by using other classes A & B? Am sure you can

    Once again thank you very much!! God bless you

  12. The artical gives good information in systematic manner.It will be bit easier to understand with digramatic representation

  13. I am totally confused with my first networking course. Unfortunately my exams tomoro, n I foudn this website today…:p if I pass the exam..I will join this community for future:D

  14. Hey.. Thank you for sharing this superb article.. I have come across many sites.. but couldn’t get the idea of subnetting..

    But finally when I came across this, my cheek started to smile a bit.. from nervousness..

    Superb Article ………….
    Smiling ever!!

  15. its interesting to see this article ……….how it produces better knowledge who are all in doubt regarding the concept subnetting

  16. I can’t believe that people can actually sit to make things easier for their fellow humans like this free. The material is the best I have ever seen on subnet. Continue with the good work.

  17. i am cheerful to find this information because it greatly hepled me to understand the lecture i took from my ccna class yesterday , i am really thankful for this infromation

  18. This is really hard worked, labored, very useful article.

    Thanks a lot to the administrator. I liked the article and included the link of this article on my site http://www.psexam.com/websites/others/2.html

  19. IPv6 blows my mind… Here’s some back-of-the-envelope calculations I’ve made about it:

    -If every person had a trillion devices, each with their own unique IP address, and there were a trillion people on the planet, and there were a trillion such worlds, we would still be using only a fraction of the possible IP addresses.

    -There are enough IP address to assign every single atom in over 6 trillion kilograms of carbon a unique address.

    -Hussam’s number isn’t right. The actual number of unique IP addresses is (taking the 2^128 number to be correct):
    340,282,366,920,938,463,463,374,607,431,768,211,456

    Note that MS Calculator can’t display the number of digits necessary for this, and Hussam wrote what it showed.

  20. Well organized and useful! I wish to point out a pair of unnecessary ambiguities that could be removed to make the presentation even clearer:

    “Powers of N” are really powers of 2. Perhaps N is used here for historical reasons? If not, I would replace it with 2.

    If keeping “Powers of N” please do not re-use N as a generic variable, such as in the formula 2^n – 2. Any other letter (e.g. x) would work here.

    Thanks

  21. Thoroughly good article, clean cut and precise. However, comments like “Subnetting may not be fun, but it is required for students to know on networking exams. That means you should stay away from subnet calculators until you have grasped the full concept of how to do it yourself.”
    Although I completely understand the need for students to understand how to subnet, it is fickle to say the above. What benefit is it to not use a calculator. If your stuck in the situation where you need to create subnets then the quickest and easiest solution is to use the calculator. Its good to know manually how to do it but when was the last time you sat a maths exam without a calculator ?

  22. Great article ,Thanks for this. But you have shown class C IP blog only on the your examples. Anyway, all of them easy already.

  23. im pretty sure that you can contary to as you mention use all ones or zeros for the subnet portion in a network so there is no need to subtract two when calculating. you can’t use all ones in the host portion though. cant tell you the rfc. well written. great way of plotting it out.

  24. Explanation is too good… easy to understand. Thanks keep up the good work. :-)

  25. You know, I am speechless. I searched allll over the web for the right explaination. Man you did a great job. It went straight to the point. Now I can do this with confidence. Thank you very much.

  26. i totally found this enlightening. thanx. God bless

  27. hi i liked the contents of this article.they are very satisfactory.!!!!!!!!!!

  28. Love it
    This subnetting explanation was package in the most simple way yet so easy to understand. I wish I could get more info like this..

    Thanks for the good work.

  29. Hi, Thanks for the tutorial

  30. Hi, thanks for the tutorial, it really helped me.

  31. Sorry for being a dumb…
    I am confuse on the example problem:

    Number of Subnets Needed: 5
    What power of 2 allows five networks?

    ——————————————-
    Power of N: N7 N6 N5 N4 N3 N2 N1 N0
    ——————————————-
    >>>>Equals: 128 64 32 16 8 4 2 1
    ——————————————-

    Since 1 + 2 + 4 = 7, we can use N3 (This is where I got confused)???
    You said we can use N3 but the one you’ve encircled is N2 = 4
    and 1 + 2 + 4 is on N2 N1 and N0 and not N3.

    Usable Subnets = 2^3 – 2 (On this part it appears you’ve used N3)
    Usable Subnets = 8-2 = 6

    I know that 8 > 5, the reason why you used 1+2+4
    What power of 2 allows five networks? -> In between 8 – 4

    Crap I’ve answered my question…

    I think this is still worth posting for future confused like me to be enlightened.. Lol :)

  32. Very good!!! This is the best tutorial I have read on the internet.

    Subnetting… DONE!!!

  33. I have the same problem!

  34. i am also little confused,

    Since usable Subnets = 2^3 – 2, what if i want 7 subnets?

    thank you

  35. Are IP adresses different from subnet masks? So would a device have an IP address ‘192…’ and ALSO a subnet ‘255…’?

  36. so you have 5 groups of 30 , how do you specify which of the 5 groups that a computer/host is in?? Is it via the mask? can you
    have a mask that is like this in the last octet? 11001111 ?

  37. i need that you may send me more information on subneting since i realise the impacts and knowledge that move to the sucess in my assignment best regard kennick

  38. thanks for describing subnet in detail

  39. Its a good article. It should be further extended to Subnet address and Broad cast address. That also involves a simple technique, which I am sure, author of this article is already expert.
    God bless you.

  40. You explanation is the most helpful I have found, thank you very much for explaining so clearly.

  41. Good!

  42. nice explanation but u need more example!pls add more

  43. Very nicely you have explained basics about subnet masking and IP addressing. However it would be nice if you include examples for each class of networks.

  44. simply superb…..!

  45. Very nice explanation,please add some more Examples about prefix, sub netting and subnet mask

    thanks

  46. hey thanks, but can you please explain some more in the class b, i would really appreciate if you could update on class b with examples too, thanks a lot.

  47. can you please put some light on the reasons of reducing two from 2^n while calculating usable subnets and hosts.

    Thank you

  48. Ive been a memeber of cisco systems for a good period of time and i feel delighted to see the above information still being provided to us world wide.

  49. Yeh ithink i can give a clear reason please just give me a sec

  50. there seems something obviously wrong here, or am I missing the blindingly obvious…the requirement is for 5 separate networks. The calculation is given as “Usable Subnets = (2^n) – 2 , where N = power of bits assigned”. The need to minus 2 is understandable when it comes to the usable hosts calculation (“Usable Hosts = (2^n) – 2 , where N = power of bits remaining”) because each host needs its own subnet address and broadcast address. But this doesn’t apply when it comes to usable hosts. 2^3 means 8 usable hosts and that’s what you get in this. The range of the final octet for each of the 8 usable hosts, including subnet address and broadcast address, is 0-31, 32-63, 64-95, 96-127, 128-159, 160-191, 192-223, 224-255. So if the school only implements 5 subnets, they have 3 in hand for future needs, not one.

  51. IP Subnet-Zero
    It’s this option, enabled by default on Cisco see http://www.itdojo.com/blog/2009/02/let-me-take-a-stab-at-this-ip-subnet-zero-thing/) that means that the formula specified in the article, “Usable Subnets = (2^n) – 2″, should actually read “Usable Subnets = 2^n”.
    Typos in my previous comment by the way: I said ‘this doesn’t apply when it comes to usable hosts’, meant to refer to usable subnets. Same goes for the following 2 references to hosts, sorry for confusion.

  52. It’s indeed the most clearly laid out guide to subnetting..but would second Eddy and Gary’s points that talking about N to the power of is unnecessarily confusing, because we are only ever raising the digit * 2 * to power of this or that. If you could update this to take into account IP Subnet Zero, change N to 2 and include some class A & B examples – would be perfect.

  53. The explanation on this subject is very good,but need to elaborate on the power of “N” just a bit morer.Thanks

  54. Brilliant, just brilliant, it is so simple when you know how. Thanks a million and best of luck to you…

  55. hello all
    i’m new at this, i just have one question, the company i work for run out of ip addresses! the current addresses 192.168.107.XXX
    they were talking about getting more ips ? so my question is can you buy more ip addresses? and if you change to another Ip class, do you have buy anything as far as ip addresses or just bigger router or switches?

  56. Hello there,I am so interested to much better about subnetting,could you please provide me with the easy method to do subnetting,esp.Class A subnetting,eg that of IP address 10.2.3.0,Subnet mask 255.255.254.128.

  57. Nothing more than introduction, does not tell you the nuts and bolts of how to apply the theory to a practical problem.

  58. I like it too, but I agree with monger, could there be an example in applying this to a real problem? that would be a great help. thanks for this. more power!

  59. The question for me is once the IP are subnetted what IP does one use for the associated router port itself since the IPs are all now tied to the various subnets. If I pull one from one of the subnets, then only hosts from that group seem to be able to access the router. Help!! I need an answer fairly soon.

  60. information successfully delivered! thanks and keep good stuff up!

  61. Great article, the simplicity of it is unbelievable if you compare it with other examples across the internet. Also its quite funny how some people see it to be really ‘complex’. I suggest with a good advisor and good practical practice it may just work out.

  62. My lecturer in Network Management class reffered us to this site for further understanding of subnetting. How grateful I am. The article is easy to follow and has cemented my understanding. Many thanks to the authoe. I pray that God may bless you abundantly.
    It also serves as an example of how we can help others by what we know. Lets not despise the gift of sharing.

  63. Thank you for making this article!

  64. this is best lecture about subneting. and thankyou for making this article!!

  65. I’ve got a project to figure out!!! I have a total of 81 devices (computers, laptops with printers, faxes, copying machines and so forth. A basement with 15, 1st.floor with 25 computers and 5 laptops. and the 2nd. floor with 43 computers.Can you help to configure the subnetting, the preferred class IP addresses and so forth.I’m new to this stuff. I got my computer about 2 yrs ago and just started going to school. I’m 59 yrs. old and trying to catch up with the rest of the world. Diagrams would help too!!! Visuals are so much better for me to understand. You can’t learn this stuff on the street. Wrong info could do me more harm than good. I sure would appreciate it!!! Prior to going to this school, I never even looked over someones shoulder to look at a computer. I wished I had of started back when they 1st. came out. Now i feel like I’m playing catch-up. Thanks so-o-o-o-o much!!!!!

  66. I kept reading and re-reading it.. i cant determine about the host and subnets? not making any sense

  67. Very useful and clear article about subnetting. Visual representation makes easy understanding.

  68. we don’t do the -2 when we’re divising the subnet part we just do it when we’re divising the host part cause the first address is the network address and the second one is the broadcast(testing)address so we have to minus this 2 adresses from the utilisable addresses that gives us 2^n-2 :)

  69. This is a great tutorial. Before seeing the method you use I kept getting mixed up. Thanks.

  70. @ Comment by Moulay on 4 March 2010:

    ….wow… i suppose you need to buy more IRQ’s too?

  71. I bet most beginners will be confused with ur subnet&host diagrams.

    great work and nice delivery though.
    Thanks.

  72. Nice tutorial, really enjoyed it and it gave me a much better understanding of subnetting.

  73. Nice well written and easy to follow article. Helped me a lot! Thank you.

  74. This was awesome!!! I went through the ccna course last year and haven’t used any of it since… I decided to go for my cert in a month or two and this was Incredibly helpful!

  75. One of the illustrations shows the range for class B as 128-192 and class C 192-224… is this correct or should the B range stop at 191?
    Thanks in advance

  76. Great article, it makes things much more simple I’m going to save it for future reference.

  77. i am totaly satisfied eith this article accept on one point where its written that we have two leave two subnets its wrong we have to leave to ip adress on every subnet as they are saved for subnet no and broadcast ip but if we tak about the the no of subnet it will be (2 to the power N) i know there is concept given by cicso that the network bit cant alawyz by high or low so we cant use the first and last subnet let take example 0-63 ,64-127,128-191,192-255 here first subnet(0-63)and last subnet (192-255) cant be used ,….. but now this is changed by cisco we can use them in subnet so the no of subnet must be 2 to the power N

  78. it was nice to fine this article, i appreciate the way it is narrated step by step. For sure the spirit of sharing will help us conquer ignorance. Dearly appreciated!!!

  79. The actual Class A, B, C ranges… don’t match your “easy way to remember” ranges.

  80. Great tutorial; would have been complete if subnet ip addresses were enumerated together with its corresponding hosts ip addresses.
    Thankfully, microsoft did just that. See this link http://technet.microsoft.com/en-us/library/cc958834

Comment on This Article