[SOLVED] odd name resolution problem

Issues related to configuring your network
dsp2267
Posts: 15
Joined: 2011/11/04 13:44:02

[SOLVED] odd name resolution problem

Post by dsp2267 » 2014/03/28 05:32:43

At least I think its a DNS problem. I have created a virtual machine in VMware Workstation 10, and installed CentOS 6.5 into it. The VM has one network adapter, eth0, that I've configured to use bridged networking (i.e. it has its own address, 192.168.1.251, and it sees my Linksys router at 192.168.1.1 as gateway). I plan to use it to run various network storage protocols, such as FTP and NFS. Via the usual command line operations I changed eth0's networking to the 192.168.1.251/24 static IPv4 address, and edited /etc/resolv.conf to point to my ISP's DNS servers.

Here's where it gets weird. I have routing from my CentOS machine to 85.12.3.227 (the IPv4 address for http://www.centos.org). If I run "dig http://www.centos.org" it returns the A record with that IPv4 address. If I run Firefox and surf to http://85.12.3.227/ I get the CentOS project home page just fine. But if I surf to http://www.centos.org/, I get a "server not found". Likewise, if I run "traceroute 85.12.3.227", I have hops all the way. But if I run "traceroute http://www.centos.org" I get a "cannot handle host" error. Likewise with ping; using the FQDN fails, using the IPv4 address works. So Layer 7 applications aren't getting name resolution.

But how can dig properly perform name resolution, but not ping?

Here is /etc/hosts;
127.0.0.1 centos.home.org centos
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6

here is /etc/resolv.conf;
# /etc/resolv.conf
#
nameserver 68.105.28.11
nameserver 68.105.28.12
nameserver 68.105.29.11

here is /etc/sysconfig/network-scripts/ifcfg-eth0;
DEVICE=eth0
TYPE=Ethernet
UUID=443e73d9-5903-4133-a7b0-1e01308babe5
ONBOOT=yes
NM_CONTROLLED=no
BOOTPROTO=none
IPADDR=192.168.1.251
GATEWAY=192.168.1.1
HWADDR=00:0C:29:28:EB:91
DEFROUTE=yes
PEERDNS=no
PEERROUTES=yes
IPV4_FAILURE_FATAL=yes
IPV6INIT=no
NAME="System eth0"
LAST_CONNECT=1394484818
Last edited by dsp2267 on 2014/04/09 04:00:47, edited 1 time in total.

User avatar
Super Jamie
Posts: 310
Joined: 2014/01/10 23:44:51

Re: odd name resolution problem

Post by Super Jamie » 2014/03/28 08:04:28

Check to see how your system is resolving hostnames. The original settings are:

Code: Select all

# egrep ^hosts /etc/nsswitch.conf 
hosts:      files dns
Perhaps one DNS server is not working? Just try with one DNS server, and also try with only 8.8.8.8 (Google public DNS)

User avatar
TrevorH
Site Admin
Posts: 33219
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: odd name resolution problem

Post by TrevorH » 2014/03/28 10:52:16

Post the output from `ls -la /etc/nsswitch.conf` and `ls -laZ /etc/nsswitch.conf`
The future appears to be RHEL or Debian. I think I'm going Debian.
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke

dsp2267
Posts: 15
Joined: 2011/11/04 13:44:02

Re: odd name resolution problem

Post by dsp2267 » 2014/03/28 14:54:12

Super Jamie wrote:Check to see how your system is resolving hostnames. The original settings are:

Code: Select all

# egrep ^hosts /etc/nsswitch.conf 
hosts:      files dns
Perhaps one DNS server is not working? Just try with one DNS server, and also try with only 8.8.8.8 (Google public DNS)
My nsswitch.conf file is in its default state, which is "hosts: files dns". Also, I have SELinux disabled;

[root@CentOS ~]# ls -la /etc/nsswitch.conf
-rw-r--r--. 1 root root 1688 May 4 2010 /etc/nsswitch.conf
[root@CentOS ~]#
[root@CentOS ~]#
[root@CentOS ~]# ls -laZ /etc/nsswitch.conf
-rw-r--r--. root root system_u:object_r:etc_t:s0 /etc/nsswitch.conf

dsp2267
Posts: 15
Joined: 2011/11/04 13:44:02

Re: odd name resolution problem

Post by dsp2267 » 2014/03/28 15:03:41

Also, the 3 nameservers I put in resolv.conf are the same that my desktop (Win7) use, without any problems. Plus I can get resolution from all 3 using dig commands such as

# dig +short 68.105.28.11 www.centos.org

all 3 return 85.12.30.227 as the IPv4 address for www.centos.org.

drk
Posts: 405
Joined: 2014/01/30 20:38:28

Re: odd name resolution problem

Post by drk » 2014/03/28 19:38:15

Here is /etc/hosts;
127.0.0.1 centos.home.org centos
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
That looks funky. You should add "localhost" stuff back to the 127 line ala:

Code: Select all

127.0.0.1  localhost localhost.localdomain localhost4 localhost4.localdomain4 centos.home.org centos
Since you have given the VM a static address you could even do this:

Code: Select all

127.0.0.1  localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6

192.168.1.251 centos.home.org centos

dsp2267
Posts: 15
Joined: 2011/11/04 13:44:02

Re: odd name resolution problem

Post by dsp2267 » 2014/03/28 22:47:22

drk wrote:
Here is /etc/hosts;
127.0.0.1 centos.home.org centos
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
That looks funky. You should add "localhost" stuff back to the 127 line ala:

Code: Select all

127.0.0.1  localhost localhost.localdomain localhost4 localhost4.localdomain4 centos.home.org centos
Since you have given the VM a static address you could even do this:

Code: Select all

127.0.0.1  localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6

192.168.1.251 centos.home.org centos
Tried all this, same result (dig can return the A record, ping can't resolve).

User avatar
Super Jamie
Posts: 310
Joined: 2014/01/10 23:44:51

Re: odd name resolution problem

Post by Super Jamie » 2014/03/28 23:41:09

Here's a small C program to test the different name resolution functions on your system. You'll need to yum groupinstall "Development tools"

Save this as hostlook.c http://pastie.org/8977205

Compile with:

Code: Select all

cc -g hostlook.c -o hostlook
Run like:

Code: Select all

$ ./hostlook www.google.com
Hostname: www.google.com
gethostbyname returned: 74.125.237.210
getaddrinfo returned: 74.125.237.208

dsp2267
Posts: 15
Joined: 2011/11/04 13:44:02

Re: odd name resolution problem

Post by dsp2267 » 2014/03/29 18:48:16

nota bene for future thread readers; if name resolution isn't working, yum won't work either.

with static IPv4 addressing;

Code: Select all

[root@CentOS Desktop]# ./hostlook www.google.com
Error in gethostbyname: : Host name lookup failure
[root@CentOS Desktop]# ./hostlook www.centos.org
Error in gethostbyname: : Host name lookup failure
[root@CentOS Desktop]# 
with original network settings and DHCP;

Code: Select all

[root@CentOS Desktop]# ~/Desktop/hostlook  www.google.com
Hostname: www.google.com
gethostbyname returned: 74.125.225.212
getaddrinfo returned: 74.125.225.208
[root@CentOS Desktop]#

dsp2267
Posts: 15
Joined: 2011/11/04 13:44:02

Re: odd name resolution problem

Post by dsp2267 » 2014/03/29 19:06:17

Code: Select all

# /etc/resolv.conf
#
 nameserver 68.105.28.11
 nameserver 68.105.28.12
 nameserver 68.105.29.11

[root@CentOS Desktop]# traceroute 68.105.28.11
traceroute to 68.105.28.11 (68.105.28.11), 30 hops max, 60 byte packets
 1  192.168.1.1 (192.168.1.1)  3.513 ms  4.131 ms  4.092 ms
 edit
 6  68.105.28.11 (68.105.28.11)  21.011 ms  17.809 ms  21.673 ms
so I have routing all the way from my CentOS VM to my ISP's nameserver, and back again. And as before, dig can resolve www.centos.org to 85.12.30.227.

???

Locked