Discusses the relationship between IP address and subnet mask and the meaning of Gateway and DNS

Source: Internet
Author: User

You must know something about the IP address, right? We know that the TCP/IP protocol that is widely used in the Internet is to differentiate between different hosts by using IPs. If you've ever had a TCP/IP protocol set up, then you're bound to encounter the term subnet mask (Subnet mask), so do you know what a subnet mask is? What role does it have?

We know that the IP address is a 4-byte (total 32bit) number, divided into 4 segments, 8 bits per segment, and periods separated by a period. For ease of expression and recognition, the IP address is expressed in decimal form such as 210.52.207.2, each paragraph can represent the maximum number of decimal not more than 255. The IP address consists of two parts, the network number (Netgwork ID) and the host ID. The network number identifies a subnet on the internet, and the host number identifies a host in the subnet. The decomposition of the Internet address into two domains brings an important advantage: When an IP packet arrives from one network to another, the selection path can be based on the network instead of the host. This advantage is particularly noticeable in large networks because the routing table stores only network information rather than host information, which can greatly simplify the routing table. The IP address is divided into a, B, and C three classes based on the number of network and host numbers:

Class A IP address: a 7-bit (bit) to identify the network number, 24-bit identification of the host number, the first one is "0", that is, a class of address the value between 1~126. A Class A address is typically provided for large networks, with a total of only 126 possible class A networks, each of which can connect up to 16777214 hosts per Class A network.

Class B IP Address: Use 14 bits to identify the network number, 16 bits to identify the host number, and the preceding two bits are "10". The first paragraph of the Class B address is between 128~191, and the first and second paragraphs together represent the network number. Class B addresses are available for medium-sized networks, with around 16,000 class B networks worldwide, and each class B network can connect up to 65534 hosts.

Class C IP Address: Use 21 bits to identify the network number, 8 bits to identify the host number, the front three bits are "110". The first paragraph of the Class C address has a value between 192~223, the first, second, and third paragraphs together to represent the network number. The last segment identifies the host number on the network. Class C addresses are suitable for small networks such as campus networks, and each class C network can have up to 254 hosts.

From the above introduction we know that the IP address is the network number and host number to indicate the host on the network, only in a network number under the computer can be "direct" interoperability, different network number of the computer to be through the gateway to exchange. But such a division appears and is very inflexible in some cases. For this reason, the IP network is also allowed to be partitioned into smaller networks called subnets (Subnet), which creates a subnet mask. The function of the subnet mask is to determine whether any two IP addresses belong to the same subnet, when only the computer on the same subnet can be "directly" interoperable. So how do you determine the subnet mask?

Referring to the IP address sub-network number and host number, to divide a network into multiple subnets, so the network number will occupy the original master, for example, for a class C address, it uses 21 bits to identify the network number, to divide it into 2 subnets will need to occupy 1 bits of the original host identity bit. At this point the network number bit becomes 22 bits and the host label becomes 7 bits. Similarly borrowing 2 host bits can divide a class C network into 4 subnets ... How does the computer know if the network is divided into subnets? This can be seen from the subnet mask. The subnet mask is as 32bit as the IP address, and the subnet mask is determined by using "1" for all corresponding bits that identify the network number in the IP address, and the bits corresponding to the host number are "0". such as a class C IP address divided into 2 subnets with 22 bits to identify the network number, its subnet mask is: 11111111 11111111 11111111 10000000 is 255.255.255.128. So we can see that the default subnet mask for Class A addresses is the 255.0.0.0,b class of 255.255.0.0,c class 255.255.255.0. The following table is the Class C address subnetting and related subnet masks:

Number of subnet-subnet-netmask hosts available hosts

1 255.255.255.128 128 126

2 255.255.255.192 64 62

3 255.255.255.224 32 30

4 255.255.255.240 16 14

5 255.255.255.248 8 6

6 255.255.255.252 4 2

You may notice that the table above is divided by the number of hosts and the number of hosts available two, which is why? Because, when all host bits of the address are "0", the address is a line (or subnet) address and a broadcast address when all host bits are "1".

We can also use a variable-length mask (VLSM), which means that a network can be configured with a different mask. This is done to make it easier to divide a network into multiple subnets. In the absence of VLSM, a network can use only one subnet mask, which limits the number of hosts in the given subnet number condition. For example, you are assigned a class C address that has a network number of 192.168.10.0, and you now need to divide it into three subnets, one of which has 100 hosts, and two hosts for the rest of the seven subnets. We know that a class C address has 254 available addresses, so how do you choose a subnet mask? From the table above, we find that this problem cannot be solved when we use a subnet mask in all subnets. At this point vlsm comes in handy, we can use the 255.255.255.128 mask on the subnet of 100 hosts, which can use 192.168.10.0 to 192.168.10.127 128 IP addresses, where the host number is 126. We'll take the rest of the 192.168.10.128 to 192.168.10.255. The 128 IP addresses are divided into two subnets with a subnet mask of 255.255.255.192. The address of one of the subnets is from 192.168.10.128 to 192.168.10.191, and the address of the other subnet is from 192.168.10.192 to 192.168.10.255. The subnet mask for 255.255.255.192 has 62 available host addresses for each subnet, which is required. It can be seen that the reasonable use of the subnet mask can make the IP address easier to manage and control.
The 
 Gateway is one of the "gateways" to a network connected to another network. In an Internet network, a gateway is an intermediary device that connects an intranet to other networks on the Internet, also known as a "router." The gateway address is a channel address that can be understood as the transmission of Intranet and Internet network information. According to different classification standards, there are many kinds of gateways. The gateway in the TCP/IP protocol is the most common, and here we refer to the "gateway" refers to the TCP/IP protocol gateway. 

So what exactly is a gateway? A gateway is essentially an IP address of a network to another network. For example, network A and network B, network A's IP address range is "192.168.1.1~192." 168.1.254 ", the subnet mask is 255.255.255.0; The IP address range for Network B is" 192.168.2.1~192.168.2.254 "and the subnet mask is 255.255.255.0. In the absence of a router, TCP/IP communication between the two networks is not possible, even if the two network connections on the same switch (or hub), the TCP/IP protocol will determine the subnet mask (255.255.255.0) on the two network hosts in a different network. To achieve communication between the two networks, you must pass through the gateway. If the host in Network a discovers that the destination host for the packet is not on the local network, forwards the packet to its own gateway, which is then forwarded by the gateway to Network B's gateway, and the gateway of Network B is forwarded to a host on network B. The same is true of network B's process of forwarding packets to network A.

Therefore, only if the IP address of the gateway is set, the TCP/IP protocol can communicate with each other on different networks. So which IP address is the IP address of the machine? The IP address of the gateway is the IP address of the device with routing capabilities, a router with routing capabilities, a server with a routing protocol enabled (essentially a router), and a proxy server (also equivalent to a router).
We all know that when we are on the Internet, the usual input is the URL, in fact, this is a domain name, and our computer network computers can only use IP address to identify each other. Again, we go to a Web server to request a Web page, we can enter the URL in the browser or the corresponding IP address, for example, we want to on the Sina network, we can enter the URL in the address bar of IE, can also enter the IP address, but this kind of IP address we can't remember or say is difficult to remember, So with the domain name, such a domain name will make it easy for us to remember.
Therefore, DNS is equivalent to a yellow page, providing services for forwarding and fast query IP.

Discusses the relationship between the IP address and the subnet mask and the meaning of the gateway, DNS

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.