How IP addresses are represented
The IP address has 32 bits, consisting of 4 8-bit binary digits, separated by dots, each 8 bits, such as 11000000.10101000.00000010.00010100.
Because of the inconvenient memory and poor readability of the binary, the binary is usually converted to decimal notation, such as 196.168.2.21.
Therefore, an IP address is usually represented by a decimal number of 3 points, called dotted decimal.
Classification of IP addresses
Each IP address consists of two parts: a network ID and a host ID. Where the network ID identifies the different networks on which the computer or network device resides, and the host ID identifies a specific host in the network.
The network ID of the IP address is distributed uniformly by the IANA (Network address assignment machine) to ensure the uniqueness of the IP address. The IANA divides IP addresses into a, B, C, D, e total of 5 classes, and specifies the length of each category network ID and host ID, as shown in.
Class A
← ———————— 24-bit ————————— →
Class B
← ————— 16-bit ————— →
Internet |
Internet |
Host |
Host |
Class C
←-24 bit-→
Internet |
Internet |
Internet |
Host |
Currently the most used IP addresses on the Internet are Class A, B, and C, and the IANA assigns a, B, C network address to the specific needs of the organization, and the specific host ID is assigned by the organization or organisation at its discretion.
1. Class A Address
The Class A address specifies the 11th 8-bit Identity network ID, and the remaining 3 8-bit identity host ID. The valid network range for Class A addresses is 1~126. There are only 126 class A networks worldwide, and each class A network can hold up to 2 of the 24-time units. Therefore, Class A addresses are intended for use in large networks.
2. Class B Address
The class B address specifies that the first 2 8 bits identify the network ID, and the second 2 8 bits identify the host ID. The valid network range for Class A addresses is 10000000.00000000~10111111.11111111, where the 1th 8-bit conversion to decimal is 128~191. The number of hosts in each Class B network can be 2 16-2. Therefore, Class B addresses are intended for use in medium-sized networks.
3. Class C Address
The Class C address specifies the first 3 8 bits as the network ID, and the last 8 bits as the host ID. The valid network range for Class A addresses is 11000000.00000000.00000000~11011111.11111111.11111111, where the 1th 8-bit conversion to decimal is 192~223. Each class C address has a maximum number of hosts of 2 for a 8- -2.c class address that is only used for networks with fewer hosts.
4. Class D Address
Class D addresses are used for multicast communication and cannot be used as node addresses on the Internet. His 1th 8-bit range is 224~239.
5. Class E Address
The E-class address is used with the address of scientific research, nor is it available as a node address on the Internet. Its 1th 8-bit range is 240~254.
In addition, there are some special IP addresses.
0.0.0.0: Represents this machine.
127.0.0.1: Represents a native loopback address and is typically used to ping this address on this computer to check that the TCP/IP protocol is installed correctly.
255.255.255.255: Represents the current subnet, which is typically used to broadcast information to the current subnet.
Subnet mask
In the network, different host communication is divided into the following two kinds of situations.
(1) The two hosts of the same network segment communicate with each other. For example, a company has applied for a class C IP address with a network ID of 192.168.1. In addition, the company assigns two computers to the host ID 2 and 3,192.168.1.2 and 192.168.1.3 exchange information belonging to the same network segment of the host to communicate.
(2) Communication between two hosts of different network segments. For example, 192.168.1.3 and 10.1.1.3 communication.
The computer that is communicating needs to obtain the network part of the remote host IP address to differentiate the different situations of host communication, thus choosing different paths of data transmission, which requires the subnet mask. As with IP addresses, the subnet mask is made up of 32 bits, using dotted decimal notation. When assigning an IP address to a host, it also gives the subnet mask it uses. The default subnet mask is typically used for Class A, B, and C for 3 types of addresses.
Subnet mask for Class A address: 255.0.0.0.
Subnet mask for Class B addresses: 255.255.0.0.
Subnet mask for Class C addresses: 255.255.255.0.
With the subnet mask, the IP address and subnet mask to do the corresponding operation, the result is the IP address of the network ID.
DNS Server domain name resolution
Why DNS is required
As mentioned in the previous section: IP addresses are uniquely positioned on a single computer, which means that we can only find a host in a network by IP address. So why do we get the resources from this remote Web server by simply entering a URL when surfing the Internet? Doesn't he have an IP address?
The answer is, of course, negative. People want to memorize names instead of boring numbers, so a system is needed to map a name to its IP address. DNS (domain Name System) is now widely used to map domain names (such as taobao.com) to IP addresses.
DNS uses a tree structure. As a simple example, in the postal system, each destination address includes the country, province, region and street, through this hierarchical address structure, the Post Office can find the recipient easily, and can avoid the conflict. DNS uses a similar approach. For example,. com is a top-level domain, similar to a country in a post office system. Find different levels of DNS servers that can be queried in turn to get the IP address of the destination host.
DNS server's domain name resolution principle
How does a DNS server resolve a domain name? Enter the domain name www.taobao.com in Internet Explorer, and the host will know its IP address before making a request to www.taobao.com. The host invokes the domain name resolver, sends information to the set DNS server, requests the IP address of www.taobao.com, and if the local DNS server does not store the appropriate information, it sends the information to the root DNS server to obtain the IP of the. com DNS server, and then to the. com The DNS server sends a query request to obtain the IP address of the Taobao.com DNS server and eventually obtains the www.taobao.com IP address.
Gateway: A computer or router can act as a gateway when a computer in the network wants to access another network segment's computer or the Internet exit.
Detection of the network
Network Detection commands
After setting the IP address, there may be a network connection failure, how to detect it? Here we need to use a few classic DOS commands.
First, use the ipconfig command to view information such as the IP address, subnet mask, default gateway, and so on, to determine whether the TCP/IP properties are set correctly.
Then, use the ping command to test whether the network is unobstructed and detect the cause of the failure.
Syntax: Ping destination IP address
For example, ping the native loopback address to detect if the IP settings are correct and enter the code as follows:
C:\>ping 127.0.0.1
Pinging 127.0.0.1 with 32 bytes of data:
Reply from 127.0.0.1: Byte =32 time <1ms ttl=128
Reply from 127.0.0.1: Byte =32 time <1ms ttl=128
Reply from 127.0.0.1: Byte =32 time <1ms ttl=128
Reply from 127.0.0.1: Byte =32 time <1ms ttl=128
Ping Statistics for 127.0.0.1:
Packet: Sent = 4, received = 4, lost = 0 (0% missing),
Estimated time to round trip (in milliseconds):
Shortest = 0ms, longest = 0ms, average = 0ms
Alternatively, you can ping a remote computer to test whether it can communicate properly with the remote host by pinging the IP address of the default gateway to verify that the connection is unobstructed.
Finally, the fault is eliminated according to the test results. For example, modify the IP address, check the network cable, network card is loose or poor contact and so on.
s1/Software Technology Foundation/07-Network related configuration