What is IP Address and Subnet Mask?
The Internet communicates based on the TCP/IP protocol. When configuring TCP/IP protocol, each device needs three settings:
1. ip address 2. subnet mask 3. default gateway
To configure TCP/IP correctly, you must understand these and how to divide subnets Mask. Be focused, this article will spend you about 15mins.
The composition of IP address: Networks and hosts
The ip address is also called InternetProtocolAddress, is composed of 4 bytes of data, and each byte is composed of 8 bits, so each ip address has 32 bits. The ip address is assigned to each device running in the TCP/IP network, including switches, routers, computers, printers, etc., each of which has an independent ip address. For example, 11000000 01010001 11111110 10000010, after converting the binary address to decimal, it becomes a standard ip address type: 192.168.254.130
IP address types
IP addresses are divided into classes A, B, C, D, and E. The last two are special addresses that have nothing to do with users. The following will introduce Type A, Type B, and Type C ip addresses.
Note: The address (0.0.0.0) whose byte is 0 corresponds to the existing host. Therefore, the ip address (255.255.255.255) whose every byte in the ip address is 1 is the broadcast address of the existing subnet.
Class A address:
The first bit of category A must be 0.
Address range: 1.0.0.0-126.255.255.255
Default subnet mask: 255.0.0.0 or 0xFF000000 (hexadecimal) Generally used for large networks.
Class B address:
The first 2 bits of the Class B address are fixed at 10.
Address range: 128.0.0.1-191.255.255.254
The default subnet mask: 255.255.0.0 or 0xFFFF0000 (hexadecimal) Generally used in medium-scale networks.
Class C address:
The first 3 bits are fixed at 110.
Address range: 192.0.0.0-223.255.255.255
Subnet mask: 255.255.255.0 or 0xFFFFFF00 (hexadecimal) Generally used in small networks.
What is Subnet mask?
To make the TCP/IP wide area network work efficiently, the router that transmits the data packet between the local area networks does not know the exact location of the destination host of the data packet. The router only knows which local area network the host is a member of, and uses the information stored in its routing table to determine how to send the packet to the target host's network.
Accordingly, we can use the subnet mask to segment existing ip addresses into network addresses and host addresses. Therefore, it is possible to determine which subnet the host is on.
The subnet mask also consists of 8 bytes, 32 bits. The 1 part of the subnet mask is represented as the network address, and the 0 part is the host address.
Assuming that 255.255.255.128 is the subnet mask of the ip 192.168.254.130 in this example:
11000000 01010001 11111110 10000010 (ip address 192.168.254.130)
111111111 111111111 11111111 10000000 (subnet mask 255.255.255.128)
AND ( && ) the two, the address obtained is the network address
11000000 01010001 1111110 1000000 (The network address is 192.168.254.128)
Invert the subnet mask and then perform the AND operation( && ) with the ip address to obtain the host address:
11000000 01010001 11111110 10000010 (ip address 192.168.254.130)
00000000 00000000 0000001 011111111 (reverse the subnet mask)
Calculation results:
0000000 0000000 0000000 00000010 (The host address is 0.0.0.2)
In this case, the data packet reaches the subnet 192.168.254.128, and the destination address is 192.168.254.130.
However, in reality, we will not use binary or decimal data to represent the subnet mask. We will use a method called CIDR: (Classless Inter-Domain Routing). We need to understand this kind of network representation.
The format is as: 192.168.10.2/28. The first number is our network address, the following 28 means using 28 bits to represent the network bits, and 32-28=4 bits to represent the host bits.
Through CIDR, we can clarify two pieces of information:
Network address: 192.168.10.2
Subnet mask: 255.255.255.240
Why are we Subnetting?
Subnetting can further reduce network traffic. If there is no reliable router, network traffic may cause the entire network to stop, but with a router, most of the traffic will stay in the local network, and only packets destined for external networks will traverse the router. The router adds broadcast domains. Hence the more broadcast domains there are, the smaller the subnet domains each broadcast is divided into, and the smaller the network traffic for each network segmentation.
The subnet division can be regarded as insufficient network bit, so find the host bit to borrow. Taking the above example, 192.168.10.2 is a class C address, and its subnet mask should be 255.255.255.0, but it is actually 255.255.255.240, and the last byte becomes 11110000. Here is the network bit borrowed 4 bits from the host. Then the subnet mask creates 2^4 subnets, and 4 is the borrowed bits. The number of hosts contained in each subnet is 2^4 -2, where 4 is the number of hosts that have not been borrowed. 2 is the address when the host bits are all 1 and all 0.
Summary
What is the network address and host address of ip address 192.168.65.127/26? How many subnets are there? How many hosts are there in each subnet?
If you don't understand how to calculate, come to contact QSFPTEK customer service staff to get the answer. QSFPTEK has a team of technical engineers to serve our users. See you in the next blog.
Note: Part of the content reference: https://en.wikipedia.org/wiki/IP_address