Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Brief introduction of DNS static Mapping in SylixOS

2025-02-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

1. Brief introduction of DNS function

DNS (Domain Name System, Domain name system) is a distributed database on the Internet that maps domain names and IP addresses to each other. Users can access the Internet through domain names without having to remember IP addresses. The process of obtaining the corresponding IP address through a domain name is called domain name resolution. Each domain name corresponds to one IP address, but one IP address can correspond to multiple domain names.

2. DNS static mapping in SylixOS

There are two ways to map hostnames to IP addresses:

1) static mapping, host-to-IP address mapping is configured on each device, and each device maintains its own mapping table independently, and is only used by this device.

2) dynamic mapping, establish a domain name resolution system (DNS), only configure the mapping of domain name to IP address on special DNS server. For devices on the network that need to use a domain name, you first need to query the IP address corresponding to the domain name from the DNS server. There are two ways to implement the static mapping of host name to IP address in SylixOS. One is to record the static address mapping table in the "/ etc/hosts" file, and the other is to store the static address mapping information in the hash table maintained by the system in the form of tshell command.

2. 1 / etc/hosts file

In the network component initialization function halNetInit, the function API_NetInit is called to initialize the network system. During the process of registering network components with the operating system kernel, the system calls the function _ _ netCfgFileInit to initialize the "/ etc/hosts" file. The information saved in the "/ etc/hosts" file is "127.0.0.1 localhost" by default, as shown in figure 2.1.

Figure 2.1 / etc/hosts file contents

Add the address mapping information "192.168.2.55 testip" to the "/ etc/hosts" file, then test the static address resolution using the "ping testip" command, and find that the testip address is successfully resolved to the IP address 192.168.2.55, as shown in figure 2.2.

Figure 2.2 static address resolution succeeded

Delete the address mapping information for testip in the "/ etc/hosts" file, use the "ping testip" command again to test the static address resolution, and find that the address resolution failed, as shown in figure 2.3.

Figure 2.3 address resolution failed

2.2 hosttable command

During the registration of network components with the operating system kernel, the system calls the function _ _ inetHostTableInit to initialize the local address translation table and adds a tshell command named "hosttable". Use the hosttable command to view the address mapping information saved in the local dynamic host domain name table, use the "- s" option to add an address mapping information, and then use the ping command to test the results of static address resolution, as shown in figure 2.4.

Figure 2.4 hosttable command add information

Use the "- d" option to delete an address mapping information, while using the ping command to test the results of static address resolution, and find that address resolution fails at this time, as shown in figure 2.5.

Figure 2.5 hosttable command add information

3. Analysis of DNS static address resolution process in SylixOS

The function _ _ inetHostTableGetItem is called in the SylixOS network protocol stack to query the local dynamic host domain name table. The process of querying the local dynamic host domain name table by the function _ _ inetHostTableGetItem can be divided into three parts.

1. The local host address "sylixos" is defined in the query local host address SylixOS. If the queried host name is "sylixos", the output parameter sends the parsed IP address, that is, 127.0.0.1, and the function returns success. Use the "ping sylixos" command to test, and the results are shown in figure 3.1.

Figure 2.6 Local hostname sylixos

two。 Query the address mapping information saved in the / etc/hosts file. If the host name is not "sylixos", the function _ _ inetHostTableGetItem will open the "/ etc/hosts" file and query the domain name table of the local host. If the same host name is queried, the output parameter will send the corresponding IP address, and the function returns successfully.

3. Query the address mapping information in the hash table added by the hosttable command if the corresponding host name is not found in the "/ etc/hosts" file, the function _ _ inetHostTableGetItem then traverses the address mapping information in the hash table added by the hosttable command. If the same host name is queried, the output parameter sends out the corresponding IP address, and the function returns successfully; if the corresponding host domain name information is not found, the function _ _ inetHostTableGetItem returns failure.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report