Home > Operation and Maintenance > Linux Operation and Maintenance > What to do if modifying the hosts file in Linux does not work

What to do if modifying the hosts file in Linux does not work

Release: 2020-01-10 13:21:39
Original
4570 people have browsed it

What to do if modifying the hosts file in Linux does not work

1. Linux often does not take effect after modifying the hostName of the local alias /etc/hosts. Solution

Linux often fails to take effect after modifying the hostName of the local alias /etc/hosts. It takes effect,

For example, the content of our /etc/hosts is as follows:

#192.68.1.10 message.xxx.com
192.68.1.11 message.xxx.com
Copy after login

But ping message.xxx.com still points to 192.68.1.10.

Generally there are 2 solutions:

1). Restart, this is the most direct, reliable and stable method. If it is sometimes inconvenient to restart, you can use the second one. method.

2). Modify the /etc/sysconfig/network file and change HOSTNAME to the corresponding alias, as follows:

NETWORKING=yes
HOSTNAME=host1
Copy after login

Restart the network service after modification

service network restart ( The essence is /etc/init.d/network)

3). If it still doesn’t work after restarting the server, it should be caused by the local dns cache.

Check whether nscd is enabled: ps -ef|grep nscd

Close the Linux nscd cache service directly:

/etc/init.d/nscd stop
Copy after login

Related recommendations: "linux tutorial

The above is the detailed content of What to do if modifying the hosts file in Linux does not work. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template