Control: reassign -1 libc6 On Du, 26 iul 20, 22:24:52, viweei wrote: > Package: libc > Version: 2.28 > OS: Linux debian 4.19.0-9-amd64 #1 SMP Debian 4.19.118-2+deb10u1 (2020-06-07) > x86_64 > > Problems caused by curl and wget domain name resolution, use curl is > successful, but wget fails to parse. > > viweei@debian:~$ wget baidu.com > --2020-07-26 20:06:55-- http://baidu.com/ > Resolving baidu.com (baidu.com)... failed: Temporary failure in name > resolution. > wget: unable to resolve host address 'baidu.com' > viweei@debian:~$ > viweei@debian:~$ > viweei@debian:~$ curl baidu.com > <html> > <meta http-equiv="refresh" content="0;url=http://www.baidu.com/"> > </html> > viweei@debian:~$ > ----------------------------------------------------------------------------------------------------- > > Screenshot: > > > Why does curl succeed and wget fails? I guess a different method of domain > name resolution is used, I used Python to confirm this problem, so I wrote > two programs. > > Firs: > viweei@debian:~/tmp$ cat first.py > import sys, socket > > result = socket.gethostbyname('baidu.com') > print result > viweei@debian:~/tmp$ python first.py > 220.181.38.148 > viweei@debian:~/tmp$ > > > Screenshot: > > > Second program fail.? > > viweei@debian:~/tmp$ cat two.py > import sys, socket > > result = socket.getaddrinfo('baidu.com',None) > print result > > viweei@debian:~/tmp$ python two.py > Traceback (most recent call last): > File "two.py", line 3, in <module> > result = socket.getaddrinfo('baidu.com',None) > socket.gaierror: [Errno -3] Temporary failure in name resolution > viweei@debian:~/tmp$ > > Screenshot: > > > So it can be seen that getaddrinfo failed, but why? In order to further > confirm that it is the problem of getaddrinfo, I converted the program to C > language. > > > viweei@debian:~/tmp$ cat test-dns.c > #include <stdio.h> > #include <sys/socket.h> > #include <netdb.h> > > const char * candidate="baidu.com"; > > int main(int argc, char * argv[]) > { > struct addrinfo *ai = NULL, *curr; > int ret = getaddrinfo(candidate, NULL, NULL, &ai); > > if(ret != 0){ > printf("Error on '%s': %s.\n", candidate, gai_strerror(ret)); > return 0; > } > > char ipstr[16]; > for(curr=ai; curr != NULL; curr=curr->ai_next){ > inet_ntop(AF_INET,&(((struct sockaddr_in *)(curr->ai_addr))->sin_addr), > ipstr, 16); > printf("%s\n", ipstr); > } > > if (ai) freeaddrinfo(ai); > return 0; > } > viweei@debian:~/tmp$ gcc test-dns.c -o test > test-dns.c: In function 'main': > test-dns.c:19:5: warning: implicit declaration of function 'inet_ntop' > [-Wimplicit-function-declaration] > inet_ntop(AF_INET,&(((struct sockaddr_in *)(curr->ai_addr))->sin_addr), > ipstr, 16); > ^~~~~~~~~ > viweei@debian:~/tmp$ ./test > 39.156.69.79 > 39.156.69.79 > 39.156.69.79 > 220.181.38.148 > 220.181.38.148 > 220.181.38.148 > viweei@debian:~/tmp$ > > > Screenshot: > > > What ? I can't believe it. Why ????? Maybe the version of libc used is > inconsistent? I checked the loaded so file. > > viweei@debian:~/tmp$ gcc test-dns.c -o test > test-dns.c: In function 'main': > test-dns.c:19:5: warning: implicit declaration of function 'inet_ntop' > [-Wimplicit-function-declaration] > inet_ntop(AF_INET,&(((struct sockaddr_in *)(curr->ai_addr))->sin_addr), > ipstr, 16); > ^~~~~~~~~ > viweei@debian:~/tmp$ ./test > 39.156.69.79 > 39.156.69.79 > 39.156.69.79 > 220.181.38.148 > 220.181.38.148 > 220.181.38.148 > viweei@debian:~/tmp$ ldd test > linux-vdso.so.1 (0x00007ffd8333c000) > libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f42450db000) > /lib64/ld-linux-x86-64.so.2 (0x00007f42452a9000) > viweei@debian:~/tmp$ > > C program use /lib/x86_64-linux-gnu/libc.so.6, Python program use > /usr/lib/x86_64-linux-gnu/libc-2.28.so. > > viweei@debian:~/tmp$ ls -l /lib/x86_64-linux-gnu/libc.so.6 > lrwxrwxrwx 1 root root 12 May 2 2019 /lib/x86_64-linux-gnu/libc.so.6 -> > libc-2.28.so > > It's the same. I don't understand why this happens? > > In addition, I also used tcpdump to capture packets > > Shell: sudo tcpdump -X port domain > > Capture Python program: > 22:15:40.486857 IP 192.168.0.193.38931 > public1.alidns.com.domain: 21424+ A? > baidu.com. (27) > 0x0000: 4500 0037 2627 4000 4011 6f1b c0a8 00c1 E..7&'@[email protected]..... > 0x0010: df05 0505 9813 0035 0023 a5a8 53b0 0100 .......5.#..S... > 0x0020: 0001 0000 0000 0000 0562 6169 6475 0363 .........baidu.c > 0x0030: 6f6d 0000 0100 01 om..... > 22:15:40.487020 IP 192.168.0.193.38931 > public1.alidns.com.domain: 30648+ > AAAA? baidu.com. (27) > 0x0000: 4500 0037 2628 4000 4011 6f1a c0a8 00c1 E..7&(@[email protected]..... > 0x0010: df05 0505 9813 0035 0023 a5a8 77b8 0100 .......5.#..w... > 0x0020: 0001 0000 0000 0000 0562 6169 6475 0363 .........baidu.c > 0x0030: 6f6d 0000 1c00 01 om..... > 22:15:40.487258 IP 192.168.0.193.40826 > public1.alidns.com.domain: 43570+ > PTR? 5.5.5.223.in-addr.arpa. (40) > 0x0000: 4500 0044 2629 4000 4011 6f0c c0a8 00c1 E..D&)@[email protected]..... > 0x0010: df05 0505 9f7a 0035 0030 a5b5 aa32 0100 .....z.5.0...2.. > 0x0020: 0001 0000 0000 0000 0135 0135 0135 0332 .........5.5.5.2 > 0x0030: 3233 0769 6e2d 6164 6472 0461 7270 6100 23.in-addr.arpa. > 0x0040: 000c 0001 .... > 22:15:40.535448 IP public1.alidns.com.domain > 192.168.0.193.40826: 43570 > 1/0/0 PTR public1.alidns.com. (72) > 0x0000: 4500 0064 2629 4000 7411 3aec df05 0505 E..d&)@.t.:..... > 0x0010: c0a8 00c1 0035 9f7a 0050 0000 aa32 8180 .....5.z.P...2.. > 0x0020: 0001 0001 0000 0000 0135 0135 0135 0332 .........5.5.5.2 > 0x0030: 3233 0769 6e2d 6164 6472 0461 7270 6100 23.in-addr.arpa. > 0x0040: 000c 0001 c00c 000c 0001 0000 0a5c 0014 .............\.. > 0x0050: 0770 7562 6c69 6331 0661 6c69 646e 7303 .public1.alidns. > 0x0060: 636f 6d00 com. > 22:15:40.535867 IP 192.168.0.193.51753 > public1.alidns.com.domain: 8798+ > PTR? 193.0.168.192.in-addr.arpa. (44) > 0x0000: 4500 0048 2632 4000 4011 6eff c0a8 00c1 E..H&2@[email protected]..... > 0x0010: df05 0505 ca29 0035 0034 a5b9 225e 0100 .....).5.4.."^.. > 0x0020: 0001 0000 0000 0000 0331 3933 0130 0331 .........193.0.1 > 0x0030: 3638 0331 3932 0769 6e2d 6164 6472 0461 68.192.in-addr.a > 0x0040: 7270 6100 000c 0001 rpa..... > 22:15:40.577107 IP public1.alidns.com.domain > 192.168.0.193.51753: 8798 > NXDomain 0/1/0 (121) > 0x0000: 4500 0095 2632 4000 7411 3ab2 df05 0505 E...&[email protected].:..... > 0x0010: c0a8 00c1 0035 ca29 0081 0000 225e 8183 .....5.)...."^.. > 0x0020: 0001 0000 0001 0000 0331 3933 0130 0331 .........193.0.1 > 0x0030: 3638 0331 3932 0769 6e2d 6164 6472 0461 68.192.in-addr.a > 0x0040: 7270 6100 000c 0001 c012 0006 0001 0000 rpa............. > 0x0050: 00f5 0041 0870 7269 736f 6e65 7204 6961 ...A.prisoner.ia > 0x0060: 6e61 036f 7267 000a 686f 7374 6d61 7374 na.org..hostmast > 0x0070: 6572 0c72 6f6f 742d 7365 7276 6572 73c0 er.root-servers. > 0x0080: 4600 0000 0100 093a 8000 0000 3c00 093a F......:....<..: > 0x0090: 8000 093a 80 ...:. > > The DNS server has successfully returned the NXDomain packet. Why does > getaddrinfo fail? > > I use strace tracking, Python program: > > > socket(AF_INET, SOCK_DGRAM|SOCK_CLOEXEC|SOCK_NONBLOCK, IPPROTO_IP) = 3 > connect(3, {sa_family=AF_INET, sin_port=htons(53), > sin_addr=inet_addr("223.5.5.5")}, 16) = 0 > poll([{fd=3, events=POLLOUT}], 1, 0) = 1 ([{fd=3, revents=POLLOUT}]) > sendmmsg(3, [{msg_hdr={msg_name=NULL, msg_namelen=0, > msg_iov=[{iov_base="\216\321\1\0\0\1\0\0\0\0\0\0\5baidu\3com\0\0\1\0\1", > iov_len=27}], msg_iovlen=1, msg_controllen=0, msg_flags=0}, msg_len=27}, > {msg_hdr={msg_name=NULL, msg_namelen=0, > msg_iov=[{iov_base="\10\334\1\0\0\1\0\0\0\0\0\0\5baidu\3com\0\0\34\0\1", > iov_len=27}], msg_iovlen=1, msg_controllen=0, msg_flags=0}, msg_len=27}], 2, > MSG_NOSIGNAL) = 2 > poll([{fd=3, events=POLLIN}], 1, 5000) = 0 (Timeout) > socket(AF_INET, SOCK_DGRAM|SOCK_CLOEXEC|SOCK_NONBLOCK, IPPROTO_IP) = 4 > connect(4, {sa_family=AF_INET, sin_port=htons(53), > sin_addr=inet_addr("223.6.6.6")}, 16) = 0 > poll([{fd=4, events=POLLOUT}], 1, 0) = 1 ([{fd=4, revents=POLLOUT}]) > sendmmsg(4, [{msg_hdr={msg_name=NULL, msg_namelen=0, > msg_iov=[{iov_base="\216\321\1\0\0\1\0\0\0\0\0\0\5baidu\3com\0\0\1\0\1", > iov_len=27}], msg_iovlen=1, msg_controllen=0, msg_flags=0}, msg_len=27}, > {msg_hdr={msg_name=NULL, msg_namelen=0, > msg_iov=[{iov_base="\10\334\1\0\0\1\0\0\0\0\0\0\5baidu\3com\0\0\34\0\1", > iov_len=27}], msg_iovlen=1, msg_controllen=0, msg_flags=0}, msg_len=27}], 2, > MSG_NOSIGNAL) = 2 > poll([{fd=4, events=POLLIN}], 1, 5000) = 0 (Timeout) > poll([{fd=3, events=POLLOUT}], 1, 0) = 1 ([{fd=3, revents=POLLOUT}]) > sendmmsg(3, [{msg_hdr={msg_name=NULL, msg_namelen=0, > msg_iov=[{iov_base="\216\321\1\0\0\1\0\0\0\0\0\0\5baidu\3com\0\0\1\0\1", > iov_len=27}], msg_iovlen=1, msg_controllen=0, msg_flags=0}, msg_len=27}, > {msg_hdr={msg_name=NULL, msg_namelen=0, > msg_iov=[{iov_base="\10\334\1\0\0\1\0\0\0\0\0\0\5baidu\3com\0\0\34\0\1", > iov_len=27}], msg_iovlen=1, msg_controllen=0, msg_flags=0}, msg_len=27}], 2, > MSG_NOSIGNAL) = 2 > poll([{fd=3, events=POLLIN}], 1, 5000) = 0 (Timeout) > poll([{fd=4, events=POLLOUT}], 1, 0) = 1 ([{fd=4, revents=POLLOUT}]) > sendmmsg(4, [{msg_hdr={msg_name=NULL, msg_namelen=0, > msg_iov=[{iov_base="\216\321\1\0\0\1\0\0\0\0\0\0\5baidu\3com\0\0\1\0\1", > iov_len=27}], msg_iovlen=1, msg_controllen=0, msg_flags=0}, msg_len=27}, > {msg_hdr={msg_name=NULL, msg_namelen=0, > msg_iov=[{iov_base="\10\334\1\0\0\1\0\0\0\0\0\0\5baidu\3com\0\0\34\0\1", > iov_len=27}], msg_iovlen=1, msg_controllen=0, msg_flags=0}, msg_len=27}], 2, > MSG_NOSIGNAL) = 2 > poll([{fd=4, events=POLLIN}], 1, 5000) = 0 (Timeout) > close(3) = 0 > close(4) = 0 > write(2, "Traceback (most recent call last"..., 35Traceback (most recent call > last): > ) = 35 > write(2, " File \"two.py\", line 3, in <mod"..., 37 File "two.py", line 3, > in <module> > ) = 37 > openat(AT_FDCWD, "two.py", O_RDONLY) = 3 > fstat(3, {st_dev=makedev(0xfe, 0x2), st_ino=2886851, st_mode=S_IFREG|0644, > st_nlink=1, st_uid=1000, st_gid=1000, st_blksize=4096, st_blocks=8, > st_size=80, st_atime=1595765851 /* 2020-07-26T20:17:31.713267320+0800 */, > st_atime_nsec=713267320, st_mtime=1595765644 /* > 2020-07-26T20:14:04.934042533+0800 */, st_mtime_nsec=934042533, > st_ctime=1595765644 /* 2020-07-26T20:14:04.934042533+0800 */, > st_ctime_nsec=934042533}) = 0 > read(3, "import sys, socket\n\nresult = soc"..., 4096) = 80 > write(2, " ", 4 ) = 4 > write(2, "result = socket.getaddrinfo('bai"..., 46result = > socket.getaddrinfo('baidu.com',None) > ) = 46 > close(3) = 0 > write(2, "socket", 6socket) = 6 > write(2, ".", 1.) = 1 > write(2, "gaierror", 8gaierror) = 8 > write(2, ": ", 2: ) = 2 > write(2, "[Errno -3] Temporary failure in "..., 47[Errno -3] Temporary > failure in name resolution) = 47 > write(2, "\n", 1 > ) = 1 > rt_sigaction(SIGINT, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=SA_RESTORER, > sa_restorer=0x7f76d6da4730}, {sa_handler=0x55e21d98bea0, sa_mask=[], > sa_flags=SA_RESTORER, sa_restorer=0x7f76d6da4730}, 8) = 0 > exit_group(1) = ? > +++ exited with 1 +++ > > It can be seen that the poll function has timed out. But i don’t know why? > > This is my resolv.conf file > > viweei@debian:~/tmp$ cat /etc/resolv.conf > nameserver 223.5.5.5 > nameserver 223.6.6.6
-- Looking after bugs filled against unknown packages
signature.asc
Description: PGP signature

