What is Subnet and Why Subnet is Required?

5 minute read

When I was learning Azure Infrastructure, I had big question in my mind what is subnet and why do I need Subnet in my network? If you share my question then here is the article for you! Everything you must know about subnet as a beginner.

What is Subnetting?

Sub + Network = Subnet.

You company has one Network that runs your company. You want to break the Network in to small pieces called as Sub Network which is Subnet.

You buy whole one pizza. However, you eat them in slices, so it is easier to you eat. So you divide you pizza into slices.

You have one whole network you divide them in smaller network. So that you can manage them easily and organize them better.

Why do we need to Subnet a Network?

There are 3 main reasons, why you want to subnet a network:

  1. Security ๐Ÿ‘ฎ
  2. Organization ๐Ÿ›๏ธ
  3. Performance ๐Ÿƒ

๐Ÿ‘ฎ Security

You have secure, high confidential data in network that you donโ€™t want them to be shared to anyone. It could be your top secrete company project. Your company employees personal records etc. Therefore, your network security is very important. And Subnetting to your network brings security to your Network.

๐Ÿ›๏ธ Organization

You can take each subnet and assign to different department of your company. For example, you distribute your subnet among IT department, HR department, Sales team etc.

๐Ÿƒ Performance

Since Subnet is small therefore, it give better performance.

How do we connect multiple subnets to each other? Answer is via router.


A router is a network device that connects different networks together. Each network is signified by itโ€™s network id or area code. You can use router to connect your subnets as well. Each subnet want to communicate to other subnet must go through the Router. . Router acts as a gateway and it has default gateway number for each subnet. So each host within the subnet must send packet to the default gateway in order to communicate to other subnet or the internet.

You can enforce policies and rules to restrict some subnet to communicate to other subnet in Router. For example, suppose you want Infrastructure Team subnet to restrict to communicate to Human Resource subnet you can do in your Router. So Router is a Single point of administration.

In this diagram, Ken & Jim can communicate to each other since they are in same subnet. Ken, Jim are also called as host. However, If Ken in left side subnet wants to send some data to Ora who is in right side subnet. Then Ken has to go through his default gateway which is the router. Router defines the default gateway for Ken and Jim is Similarly for Ora, the default gateway is So the packet will go from Ken to default Gateway then it will flow to the Ora device via her default gateway. Therefore, all communication across the subnet is happening via the router. Which is also connect to the Internet with the public facing IP address

Some time Router also has its own default gateway see below diagram.

ISP (Internet Service Provider) or Data Center has big router with lots of cable.


Host is a device with specified IP address within the network. It could be your smart phone with IP ( Or your family memberโ€™s iPad or laptop with unique IP address.

Subnet Mask

Every device has an IP address with two pieces: the client or host address and the server or network address. IP addresses are either configured by a DHCP server or manually configured (static IP addresses). The subnet mask splits the IP address into the host and network addresses, thereby defining which part of the IP address belongs to the device and which part belongs to the network.

IP Address and Subnet Mask

A 32-bit IP address uniquely identifies a single device on an IP network. The 32 binary bits are divided into the host and network sections by the subnet mask but they are also broken into four 8-bit octets.

IP Address Classes and Subnet Mask

Class A, B, and C networks have natural masks, or default subnet masks:

  • Class A:
  • Class B:
  • Class C:

You can determine the number and type of IP addresses any given local network requires based on its default subnet mask.

What is IP Mask?

You might use โ€œIP/Maskโ€ as a shorthand to define both the IP address and sub mask at once. In this situation, the IP address is followed by the number of bits in the mask.

For example,

  • equivalent to IP address: with subnet mask of
  • equivalent to IP address: with a subnet mask of

Subnet Mask Cheat Sheet

ย  Addresses Hosts Netmask Amount of a Class C
/ 30 4 2 1 / 64
/ 29 8 6 1 / 32
/ 28 16 14 1 / 16
/ 27 32 30 1 / 8
/ 26 64 62 1 / 4
/ 25 128 126 1 / 2
/ 24 256 254 1
/ 23 512 510 2
/ 22 1024 1022 4
/ 21 2048 2046 8
/ 20 4096 4094 16
/ 19 8192 8190 32
/ 18 16384 16382 64
/ 17 32768 32766 128
/ 16 65536 65534 256


Thanks for reading my article till end. I hope you learned something special today. If you enjoyed this article then please share to your friends and if you have suggestions or thoughts to share with me then please write in the comment box.

Become full stack developer ๐Ÿ’ป

I teach at Fullstack Master. If you want to become Software Developer and grow your carrier as new Software Engineer or Lead Developer/Architect. Consider subscribing to our full stack development training programs. You will learn Angular, RxJS, JavaScript, System Architecture and much more with lots of hands on coding. We have All-Access Monthly membership plans and you will get unlimited access to all of our video courses, slides, download source code & Monthly video calls.

  • Please subscribe to All-Access Membership PRO plan to access current and future angular, node.js and related courses.
  • Please subscribe to All-Access Membership ELITE plan to get everything from PRO plan. Additionally, you will get access to a monthly live Q&A video call with Rupesh and you can ask doubts/questions and get more help, tips and tricks.

Your bright future is awaiting for you so visit today FullstackMaster and allow me to help you to board on your dream software company as a new Software Developer, Architect or Lead Engineer role.

๐Ÿ’– Say ๐Ÿ‘‹ to me!
Rupesh Tiwari
Founder of Fullstack Master
Email: rupesh.tiwari.info@gmail.com
Website: RupeshTiwari.com