The Linux hostname inexplicably became Bogon and resolved to change to localhost

Source: Internet
Author: User



Cause: The company network interface to do the interface authentication, the virtual machine bridge to the physical network card can not complete authentication network access, but can only say that the virtual machine network mode changed to NAT mode, after the completion of the SSH login, found that the host name has changed.


Before changing NAT mode
[[email protected] ~] #
[[email protected] ~] #
[[email protected] ~] #

After changing to NAT mode
[[email protected] ~] #
[[email protected] ~] #




Found the host name into a bogon, very angry, look very uncomfortable, try to change back.



View several related files


[[email protected] ~]# vi /etc/sysconfig/network

NETWORKING=yes
HOSTNAME=localhost.localdomain

[[email protected] ~]# vi /etc/hosts

127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6


Host names in network and hosts are normal, localhost


[[email protected] ~]# hostname bogon


Directly using hostname to find or return bogon, not localhost in the file, view DNS file


[[email protected] ~]# cat /etc/resolv.conf
; generated by /sbin/dhclient-script
search localdomain
nameserver 192.168.13.2


Found a row of search localdomain, should be the problem caused by this line of configuration, resolv.conf configuration is automatically issued by the VMware 8 network card, so change the configuration here is useless, prepare the curve to salvation



The configuration instructions for this block are to parse the IP address of the host after the configuration file is loaded, and the returned domain domain name is echoed to the command line as the hostname, attempting to resolve the native IP


[[email protected] ~]# nslookup 192.168.13.128
Server:        192.168.13.2
Address:    192.168.13.2#53

Non-authoritative answer:
128.13.168.192.in-addr.arpa    name = bogon.

Authoritative answers can be found from:

[[email protected] ~]#


Sure enough, the IP address of this machine is resolved in order to Bogon, then the problem is that if the search Localdomain is configured in resolv.conf, the host name obtained here takes precedence over the configuration in the hosts and network files.



To solve this problem, the simplest solution is to let its resolution without DNS, using the Hosts file, directly to the native IP address to the localhost can be


127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.13.128  localhost


Restart the server, log in and see the host name back to normal.



The Linux hostname inexplicably became Bogon and resolved to change to localhost


Related Article

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.