In the previous article, getallbyname obtained four IP addresses corresponding to www.csdn.net. Theoretically, entering one of the four IP addresses in the address bar of IE (or another Web browser, such as Firefox) may access www.csdn.net. For example, enter http: // 211.100.26.124. However, ie returns an error message. After you enter the other three IP addresses, the same error message is returned.
This error does not mean that the webpage does not find an error (HTTP status code: 404), but rejects the access error (HTTP status code: 403 ). When you enter a http://www.csdn.net in the address bar, you can still access this website. From the above indications, this is not a client issue, but a server limit.
There is a host field in the request header of the HTTP protocol (which will be detailed in the next chapter). Generally, when accessing the server through the http://www.csdn.net, the host value is www.csdn.net. For http: // 211.100.26.124, the host value is 211.100.26.124. Therefore, we can infer that the server www.csdn.net can detect the Host field to prevent clients from directly using IP addresses for access. There are many websites such as www.sina.com.cn and www.126.com. Some websites do not use IP addresses for access, but when using IP addresses to access the website, the IP addresses are relocated to the corresponding domain names. If you enter http: // 141.146.8.66, it will be relocated to ingress.
The Ping Command can also be used to obtain the IP address of a domain name. If the domain name is bound with an IP address, DNS returns an IP address at random. For example, enter the following command in the console:
ping www.csdn.net
Returned results:
Reply from 211.100.26.122: bytes=32 time=31ms TTL=48Reply from 211.100.26.122: bytes=32 time=35ms TTL=48
The IP address in the returned result is the three IP addresses that myinetaddress3 obtained in Test 1 in the previous article.