Solved Host doesn't resolve (Digital Ocean VPS)

Hello,

I have 2 VPS's running FreeBSD 10.1-REL. The TransIP works fine, the Digital Ocean VPS doesn't resolve localhost doesn't resolve.

Here is my TransIP FreeBSD VPS:

Code:
$ host localhost
localhost has address 127.0.0.1
localhost has IPv6 address ::1

$ grep -v "#" /etc/hosts
::1            localhost
127.0.0.1        localhost

And here is my Digital Ocean FreeBSD VPS:
Code:
$ host localhost
Host localhost not found: 3(NXDOMAIN)
[atma@poincare ~]$ grep -v "#" /etc/hosts
::1               localhost
127.0.0.1        localhost

Another difference that I noticed is that on DO I have to setup the hostname via sysctl.conf in order to get a "localhost.domain.name" instead of "localhost". While on TransIP rc.conf is enough.

1st Question: How can I fix the DO VPS to resolve to 127.0.0.1 and ::1 for localhost ?

2nd Question: Does these differences have anything to do with different VPS implementations? Because, apart from the fact that the TransIP was upgraded and the DO is a new installation, the versions running are the same.

Thanks
 
What's in /etc/nsswitch.conf and /etc/resolv.conf?

Code:
~ # cat /etc/resolv.conf
# Generated by bsdcloud-init 2015-07-25 19:16
nameserver 2001:4860:4860::8844
nameserver 2001:4860:4860::8888
nameserver 8.8.8.8

~ # cat /etc/nsswitch.conf
#
# nsswitch.conf(5) - name service switch configuration file
# $FreeBSD: releng/10.1/etc/nsswitch.conf 224765 2011-08-10 20:52:02Z dougb $
#
group: compat
group_compat: nis
hosts: files dns
networks: files
passwd: compat
passwd_compat: nis
shells: files
services: compat
services_compat: nis
protocols: files
rpc: files
 
I changed the DNS server to some random OpenNIC servers and it works:

Code:
~ # host localhost
localhost has address 127.0.0.1
localhost has IPv6 address ::1

Apparently Google's DNS do not resolve where they should. Can't tell why this is, host doesn't query /etc/hosts, thus all problems are related to the DNS servers.
 
That's odd, the configuration clearly states to use /etc/hosts first, before DNS (That's why I asked for nsswitch.conf).
 
Truth to be told, I've read online that host doesn't query /etc/hosts and it made sense, in regards to my problem. From the man page:

DESCRIPTION
host is a simple utility for performing DNS lookups. It is normally used
to convert names to IP addresses and vice versa.

name is the domain name that is to be looked up. It can also be a dot-
ted-decimal IPv4 address or a colon-delimited IPv6 address, in which case
host will by default perform a reverse lookup for that address.

When name is not provided, host prints a short summary of it's usage.

server is an optional argument which is either a domain name or an IP
address of the name server that host should query instead of the server
or servers listed in /etc/resolv.conf
. When server is a domain name,
system resolver is used to obtain it's address.​

So apparently it doesn't read /etc/hosts.
 
You may have a point there. To be honest I rarely check the /etc/hosts file as I always make sure my DNS is correctly configured. As I maintain my own domains I always make sure both localhost and localhost.my.domain resolve correctly.
 
Back
Top