ping incorretamente pingando 127.0.0.1

2

Eu tenho um problema estranho no DNS. Estou executando um ambiente dual ipv4 / ipv6 no Gentoo Linux.

O ping de alguns sites resulta em ping ping 127.0.0.1. por exemplo,

#> ping authserver.mojang.com
PING authserver.mojang.com (127.0.0.1) 56(84) bytes of data.
64 bytes from localhost.localdomain (127.0.0.1): icmp_seq=1 ttl=64 time=0.045 ms
64 bytes from localhost.localdomain (127.0.0.1): icmp_seq=2 ttl=64 time=0.043 ms
64 bytes from localhost.localdomain (127.0.0.1): icmp_seq=3 ttl=64 time=0.058 ms
--- authserver.mojang.com ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2000ms
rtt min/avg/max/mdev = 0.043/0.048/0.058/0.010 ms

Dig, no entanto, retorna corretamente o seguinte:

# dig authserver.mojang.com

; <<>> DiG 9.9.3-P2 <<>> authserver.mojang.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 15800
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 512
;; QUESTION SECTION:
;authserver.mojang.com.         IN      A

;; ANSWER SECTION:
authserver.mojang.com.  5       IN      A       54.235.119.47

;; Query time: 14 msec
;; SERVER: 2001:4860:4860::8888#53(2001:4860:4860::8888)
;; WHEN: Sat Nov 09 15:34:40 GMT 2013
;; MSG SIZE  rcvd: 66

Estou confuso! Meu navegador retorna o site correto e o mesmo computador inicializado no Windows também funciona corretamente.

Eu não alterei o / etc / hosts (alterei o nome do meu computador para postar aqui):     127.0.0.1 localhost.localdomain localhost

# IPv4 and IPv6 localhost aliases
127.0.0.1       my.computer.com my localhost
::1             my.computer.com my localhost

Meu resolv.conf:

# Generated by dhcpcd from eth0
options inet6
# Google
nameserver 2001:4860:4860::8888
nameserver 2001:4860:4860::8844
nameserver 8.8.8.8
nameserver 8.8.4.4

domain my.domain.com

EDITAR: Meu /etc/nsswitch.conf (intocado):

# /etc/nsswitch.conf:
# $Header: /var/cvsroot/gentoo/src/patchsets/glibc/extra/etc/nsswitch.conf,v 1.1 2006/09/29     23:52:23 vapier Exp $

passwd:      compat
shadow:      compat
group:       compat

# passwd:    db files nis
# shadow:    db files nis
# group:     db files nis

hosts:       files dns
networks:    files dns

services:    db files
protocols:   db files
rpc:         db files
ethers:      db files
netmasks:    files
netgroup:    files
bootparams:  files

automount:   files
aliases:     files

Como sugerido, eu corri strace no ping: strace log

Não está se conectando ao ncsd:

connect(4, {sa_family=AF_FILE, sun_path="/var/run/nscd/socket"}, 110) = -1 ENOENT (No such file or directory)

Em seguida, ele tenta se conectar ao DNS do Google:

connect(4, {sa_family=AF_INET6, sin6_port=htons(53), inet_pton(AF_INET6, "2001:4860:4860::8888", &sin6_addr), sin6_flowinfo=0, sin6_scope_id=0}, 28) = 0
poll([{fd=4, events=POLLOUT}], 1, 0)    = 1 ([{fd=4, revents=POLLOUT}])
sendto(4, "3
socket(PF_INET6, SOCK_DGRAM|SOCK_NONBLOCK, IPPROTO_IP) = 4
connect(4, {sa_family=AF_INET6, sin6_port=htons(53), inet_pton(AF_INET6, "2001:4860:4860::8888", &sin6_addr), sin6_flowinfo=0, sin6_scope_id=0}, 28) = 0
poll([{fd=4, events=POLLOUT}], 1, 0)    = 1 ([{fd=4, revents=POLLOUT}])
sendto(4, "M4
#> ping authserver.mojang.com
PING authserver.mojang.com (127.0.0.1) 56(84) bytes of data.
64 bytes from localhost.localdomain (127.0.0.1): icmp_seq=1 ttl=64 time=0.045 ms
64 bytes from localhost.localdomain (127.0.0.1): icmp_seq=2 ttl=64 time=0.043 ms
64 bytes from localhost.localdomain (127.0.0.1): icmp_seq=3 ttl=64 time=0.058 ms
--- authserver.mojang.com ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2000ms
rtt min/avg/max/mdev = 0.043/0.048/0.058/0.010 ms
# dig authserver.mojang.com

; <<>> DiG 9.9.3-P2 <<>> authserver.mojang.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 15800
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 512
;; QUESTION SECTION:
;authserver.mojang.com.         IN      A

;; ANSWER SECTION:
authserver.mojang.com.  5       IN      A       54.235.119.47

;; Query time: 14 msec
;; SERVER: 2001:4860:4860::8888#53(2001:4860:4860::8888)
;; WHEN: Sat Nov 09 15:34:40 GMT 2013
;; MSG SIZE  rcvd: 66
# IPv4 and IPv6 localhost aliases
127.0.0.1       my.computer.com my localhost
::1             my.computer.com my localhost
# Generated by dhcpcd from eth0
options inet6
# Google
nameserver 2001:4860:4860::8888
nameserver 2001:4860:4860::8844
nameserver 8.8.8.8
nameserver 8.8.4.4

domain my.domain.com
# /etc/nsswitch.conf:
# $Header: /var/cvsroot/gentoo/src/patchsets/glibc/extra/etc/nsswitch.conf,v 1.1 2006/09/29     23:52:23 vapier Exp $

passwd:      compat
shadow:      compat
group:       compat

# passwd:    db files nis
# shadow:    db files nis
# group:     db files nis

hosts:       files dns
networks:    files dns

services:    db files
protocols:   db files
rpc:         db files
ethers:      db files
netmasks:    files
netgroup:    files
bootparams:  files

automount:   files
aliases:     files
connect(4, {sa_family=AF_FILE, sun_path="/var/run/nscd/socket"}, 110) = -1 ENOENT (No such file or directory)
connect(4, {sa_family=AF_INET6, sin6_port=htons(53), inet_pton(AF_INET6, "2001:4860:4860::8888", &sin6_addr), sin6_flowinfo=0, sin6_scope_id=0}, 28) = 0
poll([{fd=4, events=POLLOUT}], 1, 0)    = 1 ([{fd=4, revents=POLLOUT}])
sendto(4, "3
socket(PF_INET6, SOCK_DGRAM|SOCK_NONBLOCK, IPPROTO_IP) = 4
connect(4, {sa_family=AF_INET6, sin6_port=htons(53), inet_pton(AF_INET6, "2001:4860:4860::8888", &sin6_addr), sin6_flowinfo=0, sin6_scope_id=0}, 28) = 0
poll([{fd=4, events=POLLOUT}], 1, 0)    = 1 ([{fd=4, revents=POLLOUT}])
sendto(4, "M4%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%\nauthservermojangc"..., 39, MSG_NOSIGNAL, NULL, 0) = 39
poll([{fd=4, events=POLLIN}], 1, 5000)  = 1 ([{fd=4, revents=POLLIN}])
ioctl(4, FIONREAD, [55])                = 0
recvfrom(4, "M410%pre%%pre%%pre%%pre%%pre%%pre%\nauthservermojangc"..., 1024, 0, {sa_family=AF_INET6, sin6_port=htons(53), inet_pton(AF_INET6, "2001:4860:4860::8888", &sin6_addr), sin6_flowinfo=0, sin6_scope_id=0}, [28]) = 55
 | 00000  4d ec 81 80 00 01 00 01  00 00 00 00 0a 61 75 74  M....... .....aut^? |
 | 00010  68 73 65 72 76 65 72 06  6d 6f 6a 61 6e 67 03 63  hserver. mojang.c^? |
 | 00020  6f 6d 00 00 01 00 01 c0  0c 00 01 00 01 00 00 00  om...... ........^? |
 | 00030  05 00 04 17 15 2d ec                              .....-.          ^? |
close(4)                                = 0
%pre%%pre%%pre%%pre%%pre%%pre%%pre%\nauthservermojangc"..., 39, MSG_NOSIGNAL, NULL, 0) = 39 poll([{fd=4, events=POLLIN}], 1, 5000) = 1 ([{fd=4, revents=POLLIN}]) ioctl(4, FIONREAD, [55]) = 0 recvfrom(4, "310%pre%%pre%%pre%%pre%%pre%%pre%\nauthservermojangc"..., 1024, 0, {sa_family=AF_INET6, sin6_port=htons(53), inet_pton(AF_INET6, "2001:4860:4860::8888", &sin6_addr), sin6_flowinfo=0, sin6_scope_id=0}, [28]) = 55 close(4) = 0
%pre%\nauthservermojangc"..., 39, MSG_NOSIGNAL, NULL, 0) = 39 poll([{fd=4, events=POLLIN}], 1, 5000) = 1 ([{fd=4, revents=POLLIN}]) ioctl(4, FIONREAD, [55]) = 0 recvfrom(4, "M410%pre%%pre%%pre%%pre%%pre%%pre%\nauthservermojangc"..., 1024, 0, {sa_family=AF_INET6, sin6_port=htons(53), inet_pton(AF_INET6, "2001:4860:4860::8888", &sin6_addr), sin6_flowinfo=0, sin6_scope_id=0}, [28]) = 55 | 00000 4d ec 81 80 00 01 00 01 00 00 00 00 0a 61 75 74 M....... .....aut^? | | 00010 68 73 65 72 76 65 72 06 6d 6f 6a 61 6e 67 03 63 hserver. mojang.c^? | | 00020 6f 6d 00 00 01 00 01 c0 0c 00 01 00 01 00 00 00 om...... ........^? | | 00030 05 00 04 17 15 2d ec .....-. ^? | close(4) = 0
%pre%%pre%%pre%%pre%%pre%%pre%%pre%\nauthservermojangc"..., 39, MSG_NOSIGNAL, NULL, 0) = 39 poll([{fd=4, events=POLLIN}], 1, 5000) = 1 ([{fd=4, revents=POLLIN}]) ioctl(4, FIONREAD, [55]) = 0 recvfrom(4, "310%pre%%pre%%pre%%pre%%pre%%pre%\nauthservermojangc"..., 1024, 0, {sa_family=AF_INET6, sin6_port=htons(53), inet_pton(AF_INET6, "2001:4860:4860::8888", &sin6_addr), sin6_flowinfo=0, sin6_scope_id=0}, [28]) = 55 close(4) = 0

Ainda não está funcionando!

Como sugerido, usar -e ler a última consulta do DNS é o seguinte:

%pre%

Receio não saber o suficiente sobre o protocolo DNS para decodificá-lo. Rastreamento completo aqui: Strace completo

    
por AlexW 09.11.2013 / 16:45

1 resposta

3

Os sintomas que você descreve (dig dá resposta correta, gethostbyname não) significa que em algum lugar do sistema há uma resposta incorreta em cache.

Rodando

strace ping authserver.mojang.com

deve ajudar você a ter uma ideia de onde esses dados podem ser armazenados em cache. O nscd é geralmente o culpado neste caso. Procure por chamadas de conexão, isso é para um servidor de DNS.

connect(4, {sa_family=AF_INET, sin_port=htons(53), sin_addr=inet_addr("134.79.110.9")}, 28) = 0

Este é para o socket nscd.

connect(4, {sa_family=AF_FILE, path="/var/run/nscd/socket"...}, 110) = 0

Você verá a mensagem de envio com o nome do DNS que está tentando contatar e uma responderá com o endereço IP do host local. Este é um exemplo de uma pesquisa de DNS bem-sucedida.

sendto(4, "@0
strace ping authserver.mojang.com
connect(4, {sa_family=AF_INET, sin_port=htons(53), sin_addr=inet_addr("134.79.110.9")}, 28) = 0
connect(4, {sa_family=AF_FILE, path="/var/run/nscd/socket"...}, 110) = 0
sendto(4, "@0%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%wwwslacstanforde"..., 39, MSG_NOSIGNAL, NULL, 0) = 39

recvfrom(4, "@050%pre%%pre%%pre%%pre%wwwslacstanforde"..., 1024, 0, {sa_family=AF_INET, sin_port=htons(53), sin_addr=inet_addr("134.79.110.9")}, [16]) = 309
%pre%%pre%%pre%%pre%wwwslacstanforde"..., 39, MSG_NOSIGNAL, NULL, 0) = 39 recvfrom(4, "@050%pre%%pre%%pre%%pre%wwwslacstanforde"..., 1024, 0, {sa_family=AF_INET, sin_port=htons(53), sin_addr=inet_addr("134.79.110.9")}, [16]) = 309
    
por 09.11.2013 / 18:43