What is Subnet and Why Subnet is Required?
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:
- Security ๐ฎ
- Organization ๐๏ธ
- 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.
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 192.0.2.1
. Similarly for Ora
, the default gateway is 198.51.100.1
. 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 203.0.113.42
.
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
Host is a device with specified IP address within the network. It could be your smart phone with IP (192.0.2.104). 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: 255.0.0.0
- Class B: 255.255.0.0
- Class C: 255.255.255.0
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,
- 10.0.1.1/24 equivalent to IP address: 10.0.1.1 with subnet mask of 255.255.255.0.
- 216.202.192.66/22 equivalent to IP address: 216.202.196.66 with a subnet mask of 255.255.252.0
Subnet Mask Cheat Sheet
ย | Addresses | Hosts | Netmask | Amount of a Class C |
---|---|---|---|---|
/ 30 | 4 | 2 | 255.255.255.252 | 1 / 64 |
/ 29 | 8 | 6 | 255.255.255.248 | 1 / 32 |
/ 28 | 16 | 14 | 255.255.255.240 | 1 / 16 |
/ 27 | 32 | 30 | 255.255.255.224 | 1 / 8 |
/ 26 | 64 | 62 | 255.255.255.192 | 1 / 4 |
/ 25 | 128 | 126 | 255.255.255.128 | 1 / 2 |
/ 24 | 256 | 254 | 255.255.255.0 | 1 |
/ 23 | 512 | 510 | 255.255.254.0 | 2 |
/ 22 | 1024 | 1022 | 255.255.252.0 | 4 |
/ 21 | 2048 | 2046 | 255.255.248.0 | 8 |
/ 20 | 4096 | 4094 | 255.255.240.0 | 16 |
/ 19 | 8192 | 8190 | 255.255.224.0 | 32 |
/ 18 | 16384 | 16382 | 255.255.192.0 | 64 |
/ 17 | 32768 | 32766 | 255.255.128.0 | 128 |
/ 16 | 65536 | 65534 | 255.255.0.0 | 256 |
References
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.
Rupesh Tiwari
Founder of Fullstack Master
Email: rupesh.tiwari.info@gmail.com
Website: RupeshTiwari.com
Comments