I have a 13.1 VM which I use for work. My hosts file is a massive list of every server in our environment (currently more than 2500 lines). Until recently I was able to simply type “ssh <hostname>” and be connected. In one specific case, I have an entry called mt01. Now, when I attempt to access this server I get “ssh: Could not resolve hostname mt01: Name or service not known”
I’ve tried netconfig update -f and it had worked a couple times. Not so much, now.
How do I force name resolution to use my hosts file first? Why would it have changed? Does the size of the file cause a problem?
I do not thinkit has anything to to with the supnet. It is a bout resolving a hostname into an IP address. If that IP address is valid *un)reachable, etc. is of no ineterest.
What is used in resolving is defined in /etc/resolv.conf. You could check what is in there. In mine (and I never changed something there) is;
henk@boven:/etc> grep hosts /etc/nsswitch.conf
hosts: files mdns_minimal [NOTFOUND=return] dns
henk@boven:/etc>
The file you’ve cited is the nsswitch.conf file. I included that in my original post.
As for my resolv.conf file, I have the Google DNS IP (8.8.8.8). If I include the DNS IPs for the network I’m connecting to it works. Which is fine. Certainly a functioning solution. However, it doesn’t actually sold the problem of the hosts file being ignored as a name resolution resource.
It works flawless in my situation (for years). Strange thyt it stopped at yours. I know it is something you are trying to find out already for some time: what was changed “recently”.
On 2014-10-10 10:06, theillien wrote:
>
> jetchisel;2668704 Wrote:
>> Well are you still on the same subnet as your servers? can you access
>> them via ip only?
>
> I am not on the same subnet and I can access all servers using IP.
>
>
Of course, I do not have thousands of entries in the hosts file, but
that should not be a problem, either. Maybe there is a syntax error in
the file and it is not read in full.
–
Cheers / Saludos,
Carlos E. R.
(from 13.1 x86_64 “Bottle” at Telcontar)
An extremely large Hosts file as large as you describe is unusual.
Recommend trying the following…
Cut/Paste the existing Hosts file entry from wherever it is, re-position at or near top of the Hosts file.
Cut/Paste or re-create the Hosts file entry with the text in a command, this should hopefully avoid hidden characters which can be introduced using a graphical text editor. In fact, try to avoid using graphical text editors completely when troubleshooting faulty text files.
If this Hosts file is used on multiple machines, are y ou using the same file on every machine? Are there any machines which don’t use this Hosts file?
Test using another Hosts file. You can disable it by renaming to something else, like appending a “.original” to the file, then re-creating a new Hosts file. If your new file works, then you can copy/paste blocks of entries from your old file to your new until you find the problem re-occurs, which would narrow down the circumstances causing your Hosts file to fail.
If your Hosts file is used on multiple machines, I’d recommend you consider using DHCP to centrally manage your Hosts file, you can push the single master copy to any/all your client machines automatically and refresh the file on bootup (or DHCP renew lease).
On 2014-10-10 18:06, tsu2 wrote:
>
> An extremely large Hosts file as large as you describe is unusual.
An alternative is to use dnsmasq.
You can have a smallish hosts file, which is what the system reads, and
a huge, auxiliary file, which is only read and served by dnsmasq
(–addn-hosts). Entries are cached and answers are fast, and it also
caches external (to the machine) dns entries.
It is possible that dnsmasq does some syntax checking on start/reload.
Editing hosts file is easier than a real bind…
–
Cheers / Saludos,
Carlos E. R.
(from 13.1 x86_64 “Bottle” at Telcontar)
Cut/Paste or re-create the Hosts file entry with the text in a command, this should hopefully avoid hidden characters which can be introduced using a graphical text editor. In fact, try to avoid using graphical text editors completely when troubleshooting faulty text files.
I only use vim
If this Hosts file is used on multiple machines, are y ou using the same file on every machine? Are there any machines which don’t use this Hosts file?
I only use it on this system.
Test using another Hosts file. You can disable it by renaming to something else, like appending a “.original” to the file, then re-creating a new Hosts file. If your new file works, then you can copy/paste blocks of entries from your old file to your new until you find the problem re-occurs, which would narrow down the circumstances causing your Hosts file to fail.
Preliminary tests work. This indicates an issue with the hosts file. I will slowly add back systems that I use regularly and rely on an intermediary (mt01) in the remote environment as my jumping off point for other systems.
If your Hosts file is used on multiple machines, I’d recommend you consider using DHCP to centrally manage your Hosts file, you can push the single master copy to any/all your client machines automatically and refresh the file on bootup (or DHCP renew lease).
Seems a bit of a PITA to deal with a problem on a single computer.