Get the App
SLTechnology News&Howtos  ›  Servers  › 

How to solve the problem that the linux modified hosts file does not take effect?

Shulou Source: shulou.com Published: 2022-06-03 06:03:29 09月21日 Update

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

Linux often does not take effect after modifying the hostName of the native alias / etc/hosts

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

# 192.68.1.10 message.xxx.com192.68.1.11 message.xxx.com

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

There are two general solutions:

1)。 Restart, which is the most direct, reliable and stable method, if sometimes it is not convenient to restart, you can use the second method.

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

NETWORKING=yesHOSTNAME=host1

Restart the network service after modification

Service network restart (essentially / etc/init.d/network)

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

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

Directly shut down the Linux nscd caching service:

/ etc/init.d/nscd stop

These are the details of what to do if linux modifies the hosts file. Please pay more attention to other related articles!

Tags: Aliases native service file function content method cache or that is what to do point to article scheme time more server essence network network service Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Redmi Docker Microsoft MySQL Shulou Technology