About cannot get host info reported in disconf ContOS

Source: Internet
Author: User

About cannot get host info reported in disconf ContOS

I found the problem of cannot get host info reported by deploying disconf in linux. I found it through the disconf source code on github:

Row 45th: InetAddress. getLocalHost (); it is found that this method is very difficult on linux.

InetAddress. getLocalHost returns an incorrect IP address. Why does this function return an incorrect address, because the principle of this function is to obtain the hostname of the local machine, and then parse the hostname to obtain the IP address. If the host name is directed to an incorrect IP address in the/etc/hosts file of the Local Machine, InetAddress. getLocalHost will return the wrong IP address. Of course, if your hostname is resolved by DNS, it may happen that the information on DNS is also wrong, and it is also a tragic ending.

Solution:

View host names using hostname

Modify/etc/hosts: add a line: [local IP address] [host name]
Done.

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.