What are IP addresses, subnet masks, routes, and gateways

Source: Internet
Author: User

What are IP addresses, subnet masks, routes, and gateways? Often friends ask me, indeed these terms are often seen by us, today to the people to talk about the meaning of these terms:

1.IP Address:

The IP address has a 32-bit connection address, consisting of 4 8-bit fields, a 8-bit field called a 8-bit group, and each 8-bit group is separated by a dot to identify

TCP/IP host. Each IP address contains two parts: the network ID and the host ID, the network ID identifies all host hosts on the same physical network, the host ID identifies each host on the network, and each computer running TCP/IP requires a unique IP address.

The Intenet committee defines five types of addresses to accommodate different sizes of networks. The address type defines which bits are used by the network ID, and it also defines the possible number of networks and the number of host hosts per network.

2. Subnet mask (Subnet mask)

Subnets allow you to divide a single large network into multiple physical networks and connect them together with routers. The subnet mask is used to mask part of the IP address, allowing TCP/IP to differentiate between network ID and host ID. When the TCP/IP host is communicating, the subnet mask is used to determine whether a host is on a local network or a remote network.

The default subnet mask is used for TCP/IP networks that do not fall into subnets, all bits corresponding to the network ID are set to 1, the decimal number for each 8-bit group is 255, and all bits corresponding to the host ID are 0.

The number of bits used for the subnet mask determines the number of possible subnets and the number of host hosts per subnet, the more the number of subnets in the subnet mask, the more subnets, but also fewer hosts.

Example: If the Class A address subnet number is 14, then the required number of bits is at least 4, the bits used for the subnet are:
11111111, 11110000, 00000000, 00000000,
The subnet mask is 255.240.0.0, and the number of host hosts per subnet is 2^20-2=1,048 and 574.

3. Routing and Gateways

A TCP/IP network is connected by a gateway (gateways) or router (routers). When IP is ready to send a packet, it inserts the local (source) IP address and the destination address of the packet into the IP header, and checks if the destination network ID is consistent with the source host's network ID, and if so, the packet is sent directly to the destination computer on the local network, and if it is inconsistent, check the routing table for static routes. If no routing information is found, the packet is forwarded to the default gateway.

The default gateway connects to a computer on the local subnet and other networks, knows the network ID of other networks on the Internet, and knows how to get there, so it can forward packets to other gateways until they are eventually forwarded to a gateway connected to a direct and qualified destination, a process known as routing. Now everyone knows the meaning of these things, I hope to have some help ...
The subnet mask is the basic knowledge that every network management must master, and only if it is mastered, can we really understand the TCP/IP protocol settings. Below we will explain what is the subnet mask in a more comprehensible way.

Structure of the IP address

To understand what a subnet mask is, you cannot understand the composition of the IP address. The internet is made up of many small networks, with many hosts on each network, which makes up a hierarchical structure. IP address is designed to take into account the level of address allocation characteristics, each IP address is divided into two parts of the network number and host number, in order to facilitate IP address addressing operations.

What is the network number and host number of the IP address? If you do not specify, you do not know which bits are the network number, which is the host number, which needs to be implemented through the subnet mask.


What is a subnet mask

The subnet mask cannot exist alone, it must be used in conjunction with an IP address. The subnet mask has only one function, which is to divide an IP address into two parts: network address and host address.

The subnet mask setting must follow certain rules. The same as the IP address, the length of the subnet mask is also 32 bits, the left is the network bit, with the binary number "1", the right is the host bit, the binary number "0" is represented. The accompanying figure shows the binary control of the IP address "192.168.1.1" and the subnet mask as "255.255.255.0". Among them, "1" has 24, representing the corresponding IP address to the left 24 bits is the network number; "0" has 8, representing the corresponding IP address to the right of the 8-bit is the host number. In this way, the subnet mask determines which of the 32-bit binary digits of an IP address are the network number and which are the host numbers. This is very important for the network with TCP/IP protocol, only through the subnet mask, it can indicate the relationship between the subnet of one host and other subnets, and make the network work properly.

Common subnet Masks

There are hundreds of subnet masks, only the most commonly used two-seed netmask, which are "255.255.255.0" and "255.255.0.0", respectively.

1. The subnet mask is a network of "255.255.255.0": the last digit can be changed arbitrarily within the 0~255 range, so 256 IP addresses can be provided. However, the actual number of IP addresses available is 256-2, or 254, because the host number cannot be all "0" or all "1".

2. The subnet mask is a network of "255.255.0.0": the next two digits can be arbitrarily varied within the 0~255 range, providing 2,552 IP addresses. However, the actual number of IP addresses available is 2552-2, or 65,023.

The subnet mask setting for the IP address is not arbitrary. If the subnet mask is set too large, that is, the subnet range is enlarged, then, according to the subnet path rule, it is likely to be sent to the local machine is not in the same subnet of the destination machine data, because of the wrong judgment and think that the destination machine is in the same subnet, then the packet will be in the network loop, until the timeout and So that the data does not reach the destination machine correctly, causing the network transmission error, if the subnet mask is set too small, then the communication between the machines belonging to the same subnet as cross-subnet transmission, the packet is given to the default gateway processing, which will inevitably increase the burden of the default gateway, resulting in network efficiency degradation. Therefore, the subnet mask should be set based on the size of the network.

If a network of no more than 254 computers, the use of "255.255.255.0" as a subnet mask, and now most of the local area network will not exceed this number, so "255.255.255.0" is the most commonly used IP address subnet mask , I see the largest school campus network with more than 1500 computers, this size of the local area network can use "255.255.0.0".

Default Subnet mask

In Windows Server, if you assign an IP address to a network card, a default subnet mask is automatically populated. This is the subnet mask that Windows Server automatically generates in order to save user input time. For example, the local area network most commonly used IP address "192.168.x.x" The default subnet mask is "255.255.255.0". In general, the IP address is available using the default subnet mask.
Because the network number for the network segment, such as 192.168.0.1~, is represented by zero. 192.168.0.255 This segment network number is 192.168.0.0 and 192.168.0.255 for this network segment broadcast address, so this network segment has two address can not use this is when the mask is 255.255.255.0, if the mask is 255.255.255.224 When it's 11111111.11111111.11111111.11100000, this time a network of C-class addresses (192.168.0.0) will be divided into 8 segments but only 6 can be used because the first 192.168.0.0 is the whole 192.168.0.0. The network number of a network segment and 192.168.0.255 is the broadcast address so the first network segment and the last network segment can not be used, divided into 8 network segments is 0-31,32-63,64-95 .... 224-255, but as said above, 0-31 and 224-255 is not possible because there is 192.168.0.0 network number and broadcast address of this network segment, and the rest can be so in 192.168.0.32-192.168.0.63 this network segment 192.168.0.32 for the network number 192.168.0.63 for the broadcast ground This is the net mask to do network number results, This can be divided into more network segments in the mask of 255.255.255.224 these two addresses 192.168.0.20 and 192.168.0.50 is not accessible to each other (in the absence of a router) because it is not a network segment, do not know I said so many people understand, understand the subnet mask is very simple as long as Be familiar with binary.

The subnet mask is the basic knowledge that every network management must master, and only if it is mastered, can we really understand the TCP/IP protocol settings. Below we will explain what is the subnet mask in a more comprehensible way.

  Structure of the IP address

To understand what a subnet mask is, you cannot understand the composition of the IP address. The internet is made up of many small networks

What are IP addresses, subnet masks, routes, and gateways

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.