Web server IP address / DNS server
Check the IP address of the Web server from the DNS server
IP Address Basics
When creating an HTTP message, ask the OS to send it and send it to the Web server of the access destination. Since the browser itself does not have a function to send HTTP messages, ask the OS to send it instead. At that time, it is necessary to look up the IP address from the domain name of the server described in the URL. When sending a request to the OS, it is supposed to deliver the message with the IP address, not the domain name of the destination Web server. So the next step after creating an HTTP message is to look up the IP address from the domain name.
Basic idea of TCP / IP
For the explanation of IP address, the basic idea of TCP / IP is necessary first. The Internet and internal LAN are based on the concept of TCP / IP. As shown in the figure below, TCP / IP thinks that the whole network has been completed by connecting a small network called a subnet with a router. Here, we think that a subnet is one in which several computers are connected to a device called a hub. Considering it as one unit, we call it a subnet. And if you connect it with a router, the entire network will be completed.
- Illustration of TCP / IP network
Assign an address number that is also called an address on the network, such as “O O-chome x X address” to one computer. Assigning the number that answers “chome” to the subnet and assigning the number corresponding to “address” to the computer is the address on the network.
The number corresponding to this “chome” is called a network number, and the number corresponding to “address” is called a host number. These addresses are called IP addresses.
When sending a message to the access destination server, we decide where the access destination is based on this IP address and carry the message. If you send a message but send a message, the hub in the subnet carries the message and delivers it to the nearest router from the sender. Based on the IP address, the router looks at the router that delivers the message next, judges it, judges it, sends out a transmission instruction so as to deliver it, and then the hub in the subnet will deliver the message to that router again. By repeating this we will finally reach the router to the other party.
Actual IP address
The actual IP address is 32 bit digital data. It is expressed in decimal notation with 8 bits (= 1 byte) separated by dots. Although the format of this notation is the IP address that can be normally seen, in this state, it is not known where it is a network number or a host number. In the IP address rule, the network number and the host number together are only 32 bits and their breakdown is not distinguished. When building a network, users can decide its breakdown on their own. So add information representing the breakdown to the IP address as necessary.
Information added to an IP address is called a net mask.
- Figure 1: IP address structure
- Figure 2: IP address notation method
The netmask is digital data for 32 bits which is the same as the IP address in the above figure 1, with 1 on the left side and 0 on the right side. Then, the net mask “0” indicates the host number, and “1” indicates the network number. This netmask is expressed as 8 bits each separated by dots in the same way as the IP address and the one shown on the right side of the IP address is shown in (b) of FIG. 2 above. However, since this notation is prolonged, The number of bits (excluding the portion of “0”) of the portion denoted by “1” in the network number of the net mask in the upper figure in FIG. 1, with 24 bits × 3 = 24 bits as the decimal number 24, on the right side of the IP address Fig. 2 (c) above shows the results shown in Fig. Both have different notation methods, meaning does not change.
Also, when the bit value of the host number part is all 0, the IP address does not represent individual equipment but represents the subnet itself. ((D) in the above figure 2 (d)) Also, when the host number part is all 1, it represents a broadcast that sends packets to all the devices on the subnet.
- Host number of IP address
- All “0”: Indicates the subnet itself.
- All “1”: “Broadcast” to send packets to all the devices on the subnet.
Use of domain name and IP address properly
Since the TCP / IP network is to specify the communication partner with this IP address, it is impossible to deliver the message to the other party unless you know the IP address. So, when asking the OS to send a message, it is necessary to check the IP address.
In the column describing the URL, not the server name but the IP address can be written correctly, but since the IP address is a numeric string, it is hard for the user to memorize. Therefore, it is better to be able to write with an easy-to-understand server name.
Assuming that communication is performed using a domain name instead of an IP address, there are only 4 bytes (= 32 bits) of IP address, but the domain name has several tens of bytes and a maximum of 255 bytes. In other words, you have to handle character data of tens to 255 bytes. Then, the addition of the router increased more than handling the IP address. There is a big addition to the operation of carrying data. As a result, the data transmission efficiency decreases and the network speed slows down. For this reason, it is established that humans are using domain names and routers use IP addresses.
Therefore, the mechanism of DNS knows the IP address if domain name is known. It is said that it is responsible for the reverse operation
DNS(Domein Name System)
Although it is common to use DNS to link a server name (domain name) with an IP address, it is possible to register various information in association with a name, such as linking a mail address and a mail server I will.
Provide IP address by function of Soket library
To find out the IP address, please tell the nearest DNS server IP address of “www.lab.glasscom.com” server. Just ask. In response, the DNS server will tell you the IP address.
Contacting the DNS server means sending a request message to the DNS server and receiving a response message for it. This means that the DNS server acts as a client, and what is equivalent to this DNS client is called a DNS resolver (simply a resolver).
To check the IP address using the DNS mechanism is called name resolution (literal translation and name resolution).
Resolver and Soket library
The entity of the resolver is a componentized program contained in the Socket library. A library is a collection of a large number of programs that are made into parts so that they can be used from various applications. In other words, because we already have the parts of the program already assembled and gathered together to create the application, we can simplify the programming work itself and standardize the program. Since various other effects can be expected, utilization of the library is spreading in all fields of software, and various libraries exist indeed.
Here, the Soket library is a type of library that is a collection of parts for calling network functions built into the OS from applications. Resolver is one of the program parts built into it.
- Soket library: Programs for invoking network functions embedded in each OS
- Resolver (DNS resolver): It is a program embedded in the Soket library and has a role of checking the IP address by querying the DNS server.
Follow the DNS server with a resolver
Programs contained in the Soket library are partized and can be easily called up and used from applications. Call this resolver by using this program. If you call the resolver, the resolver sends a request message to the DNS server, and the IP address is stored in the returning response message. The resolver will pick this out and write it in the specified memory area from the browser. You can check the IP address.
When the browser sends a message to the Web server, it only retrieves the IP address from this memory area, passes it to the OS along with the HTTP request message, and requests transmission.
- When looking up the IP address from the domain name, the browser uses the resolver in the Soket library
Resolver internal movement
- Program flow when the resolver called by the application operates
When the network application calls the resolver, its control moves inside the resolver. When the application program reaches the part where the application program calls the resolver, when the line is executed, the operation of the application temporarily stops there (① in the upper figure), the resolver inside the Soket runs the operation requested by the application for the first time I will. (② above)
The “control transfer” of a program means that by calling another program during the execution of the program, the calling program pauses its operation and the calling program shifts to execution.
When control is transferred to the resolver, a request message is created there in the DNS server. According to the specification of DNS, it creates data for inquiring about the IP address of “www.lab.glass.com” and sends it to the DNS server (above figure ③)
In actual message transmission operation, the resolver calls the protocol stack built in the OS, not the execution of itself, and requests execution. Unlike resolvers and browsers, this has the ability to send and receive data to and from the network. When the resolver calls the protocol stack, control is transferred there and this time, the action of sending the message is executed and the message is sent to the DNS server through the LAN adapter.
- Request message to the DNS server: HTTP describes the message in text, but the DNS message is binary data.
- Protocol stack: Network control software embedded in the OS, also called “protocol driver” or “TCP / IP software”
Since the DNS server that received the message is registered in the Web server to which the message is accessed, it returns the response of the message to the response message and sends it back to the client. The response message that arrives at the client side is passed to the resolver via the protocol stack (⑦ ⑧) It extracts the IP address from it and passes it to the application. Then, store the IP address in the specified memory area.
After the series of actions by which this resolver examines and passes IP addresses, control of the program returns to the application (browser). This allows the application to retrieve the IP address stored in the memory area when needed.
When sending a message to the DNS server, you need the IP address of the DNS server, but this is already set in the computer as one of the TCP / IP setting items, so you do not need to look it up again . The method of setting this TCP / IP differs depending on the type of OS, but for Mac, it can be set on the screen shown below. The resolver sends a request message to the IP address of the individually configured DNS server. I will take a view.
- The internal structure of the computer has such a multilayered structure, and there are many programs for each layer, and each role is responsible for each role. The work to which the upper layer is requested is executed while requesting execution to that layer and lower layers.