[SOLVED] odd name resolution problem
[SOLVED] odd name resolution problem
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
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.
- Super Jamie
- Posts: 310
- Joined: 2014/01/10 23:44:51
Re: odd name resolution problem
Check to see how your system is resolving hostnames. The original settings are:
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)
Code: Select all
# egrep ^hosts /etc/nsswitch.conf
hosts: files dns
Re: odd name resolution problem
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
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
Re: odd name resolution problem
My nsswitch.conf file is in its default state, which is "hosts: files dns". Also, I have SELinux disabled;Super Jamie wrote:Check to see how your system is resolving hostnames. The original settings are:
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)Code: Select all
# egrep ^hosts /etc/nsswitch.conf hosts: files dns
[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
Re: odd name resolution problem
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.
# dig +short 68.105.28.11 www.centos.org
all 3 return 85.12.30.227 as the IPv4 address for www.centos.org.
Re: odd name resolution problem
That looks funky. You should add "localhost" stuff back to the 127 line ala:Here is /etc/hosts;
127.0.0.1 centos.home.org centos
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
Code: Select all
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 centos.home.org centos
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
Re: odd name resolution problem
Tried all this, same result (dig can return the A record, ping can't resolve).drk wrote:That looks funky. You should add "localhost" stuff back to the 127 line ala:Here is /etc/hosts;
127.0.0.1 centos.home.org centos
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6Since 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 centos.home.org centos
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
- Super Jamie
- Posts: 310
- Joined: 2014/01/10 23:44:51
Re: odd name resolution problem
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:
Run like:
Save this as hostlook.c http://pastie.org/8977205
Compile with:
Code: Select all
cc -g hostlook.c -o hostlook
Code: Select all
$ ./hostlook www.google.com
Hostname: www.google.com
gethostbyname returned: 74.125.237.210
getaddrinfo returned: 74.125.237.208
Re: odd name resolution problem
nota bene for future thread readers; if name resolution isn't working, yum won't work either.
with static IPv4 addressing;
with original network settings and DHCP;
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]#
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]#
Re: odd name resolution problem
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
???