Linux problem log - host name became bogon

Linux problem log - host name became bogon

Abstract: This paper records the reason for the hostname becomes bogon and solutions.

To reproduce the problem

After a host name to log into the bogon, it is bogon Thereafter each time you log Linux system.

1 Connecting to 192.168.35.128:22...
2 Connection established.
3 To escape to local shell, press 'Ctrl+Alt+]'.
4 
5 Last login: Mon Nov 18 17:24:49 2019 from 192.168.35.1
6 [root@bogon ~]# 

Solution

Modify the hosts file (after the restart problem solving)

Modify the hosts file in the etc directory, add the host address corresponding to the host name:

Reboot the system, the problem is solved:

1 Connecting to 192.168.35.128:22...
2 Connection established.
3 To escape to local shell, press 'Ctrl+Alt+]'.
4 
5 Last login: Mon Nov 18 17:35:02 2019 from 192.168.35.1
6 [root@localhost ~]# 

Modify the host name (the problem still exists after the restart)

In CentOS 7 modify the host name is more convenient, single command:

1 [root@bogon ~]# hostnamectl set-hostname localhost
2 [root@bogon ~]# 

However, this approach does not work, or restart time:

1 Connecting to 192.168.35.128:22...
2 Connection established.
3 To escape to local shell, press 'Ctrl+Alt+]'.
4 
5 Last login: Mon Nov 18 17:24:49 2019 from 192.168.35.1
6 [root@bogon ~]# 

Problem Description

Investigation process

When problems arise, first check the network configuration file:

1 [root@bogon ~]# cat /etc/sysconfig/network
2 # Created by anaconda
3 [root@bogon ~]# 

And we did not find any problems, and then view the hosts configuration file:

1 [root@bogon ~]# cat /etc/hosts
2 127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
3 ::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
4 
5 [root@bogon ~]# 

There is no problem, the host name of the hosts is localhost, and then look after resolving host names:

1 [root@bogon ~]# hostname
2 bogon
3 [root@bogon ~]# 

Discovery became bogon, so the judge may be a problem with DNS, see the DNS configuration file:

1 [root@bogon ~]# cat /etc/resolv.conf
2 # Generated by NetworkManager
3 search localdomain
4 nameserver 192.168.35.2
5 [root@bogon ~]# 

It found that more than a line  Search localdomain  , should be the cause of this line configuration.

Use nslookup command to see the situation resolved to the native address:

1 [root@bogon ~]# nslookup 192.168.35.128
2 128.35.168.192.in-addr.arpa    name = bogon.
3 
4 Authoritative answers can be found from:
5 
6 [root@bogon ~]# 

I found to resolve the name is bogon, then that is a problem, if configured in resolv.conf  Search localdomain  , then the host name is obtained here in preference to hosts and network configuration files.

The reason

That information through the online query, bogon is the address that should not appear in the internet routing table.

Linux in the initialization system will first determine the host name, if the host name is localhost or localhost.localdomain, will obtain the host IP address and perform reverse DNS resolution, resolves to assign the result to HOSTNAME. The problem is that some DNS server will retain the private address and IP address so that should not appear on the network address resolved to bogon, which led to the discovery of the host address when logging into a bogon.

Modify the hosts file to resolve the local address directly to localhost, no longer through the DNS server, it will not be resolved to bogon.

In addition to modifying the hosts file, you can also replace a DNS server, the primary DNS arbitrarily change an address to save your settings, then back to the original IP, save the settings, and then log off the current user, log on again. But this way I have not tried, uncertain Can.

Guess you like

Origin www.cnblogs.com/shamao/p/11883914.html