What I need to do is give a proper name to localhost
a Linux machine (where the Apache server is located with a web system). The idea is that this name can be resolved by all the machines connected to the same Local Network [This is a small intranet]. This, to avoid having to type the IP of the server. Namely; if before you had to type http://192.168.1.100
in the browser, now you should be able to type http://sistema.home
to display the system hosted on the machine. Before, I solved it by typing the name of the machine with the .home extension, but many users find it difficult to write http://Ubuntu-Server-HP-154.home
(very long and difficult to remember)
For this, the first thing I did was change the /etc/host file, leaving it like this:
127.0.0.1 sistema.home
127.0.1.1 Ubuntu-Server-HP-154.home
And then modify the servername of the /etc/apache2/sites-available/000-default.conf file:
ServerName sistema.home
Then I realized that this way I could only access locally by typing http://sistema.home
(it only resolved if I was browsing on the same server machine) so I also changed the name of my machine to de Ubuntu-Server-HP-154
a sistema
and configured the file /etc/hostname
sistema
I also made the corresponding changes in /etc/host like this:
127.0.0.1 sistema.home
127.0.1.1 sistema
Network restarts, systemctl restart systemd-hostnamed, Apache, Machine, etc
Well, from another machine I still can't access through http://sistema.home
, but I can through the old name of the machine http:// Ubuntu-Server-HP-154.home
. What's more, when I do a ping -a 192.168.1.100
it still resolves as Ubuntu-Server-HP-154.home
and not assistema.home
So I started to check the configuration with the command hostname
of the server machine:
.$ hostname
sistema
Perfect, it tells me that the hostname of my machine is called system
.$ hostname -f
sistema
Perfect, it tells me that the FQDN (Full Domain Name) is called system
.$ hostname -A
Ubuntu-server-HP-88454154.home Ubuntu-server-HP-88454154.home
What? It tells me that there are more FQDNs on my machine and they are called Ubuntu-Server-HP-154
But then: Where are those other FQDNs to delete them? Why is this happening? and then what is the correct way to change the localhost name so that it is available to the rest of the local network?
The /etc/hosts file has no effects at the name resolution level for tools like 'host' or 'nslookup', for other effects you would have to review the configuration in nsswitch.conf, which is where the search order is determined at other levels .
However, if the systems that keep finding the server with its old name are Linux, it is possible that you have some active process that caches the system, such as nscd or dnsmask.
You could reset the cache of any of these active processes by restarting them with systemctl, type
either
If the hosts that continue to see the old dns record are Windows, it may also be due to cache, you should be able to see the cache on these systems with:
To clear the cache on these windows systems you would have to run: