Win 11 Cygwin "dig" and "host": Option -6 causes command to hang
TL;DR
-----
It appears "dig" and "host" both depend on the existence of
/etc/resolv.conf, but only when the -6 option (send queries over IPv6)
is specified.
/etc/resolv.conf does not exist on either my old Win 10 or relatively
new Win 11 systems.
I have a vague recollection that at some point, maybe Windows 7 or even
XP, there was a Cygwin /etc/resolv.conf that was a link to
C:\windows\system32\drivers\etc\resolv.conf, but I don't think this has
been true for quite a while if it ever was. Also resolv.conf does not
exist in the windows location either.
Details
-------
Sample:
# Default query over IPv4
$ host google.com
google.com has address 74.125.197.102
google.com has address 74.125.197.100
google.com has address 74.125.197.138
google.com has address 74.125.197.101
google.com has address 74.125.197.139
google.com has address 74.125.197.113
google.com has IPv6 address 2607:f8b0:400e:c03::64
google.com has IPv6 address 2607:f8b0:400e:c03::71
google.com has IPv6 address 2607:f8b0:400e:c03::65
google.com has IPv6 address 2607:f8b0:400e:c03::66
google.com mail is handled by 10 smtp.google.com.
# Query over IPv6
$ host -6 google.com
;; connection timed out; no servers could be reached
# Query over IPv6 with explicit DNS server
$ host -6 google.com 2601:xxx:xxx:xxx:201:2eff:fe70:3bfe
Using domain server:
Name: 2601:xxx:xxx:xxx:201:2eff:fe70:3bfe
Address: 2601:xxx:xxx:xxx:201:2eff:fe70:3bfe#53
Aliases:
google.com has address 74.125.197.139
google.com has address 74.125.197.113
google.com has address 74.125.197.102
google.com has address 74.125.197.100
google.com has address 74.125.197.138
google.com has address 74.125.197.101
google.com has IPv6 address 2607:f8b0:400e:c03::71
google.com has IPv6 address 2607:f8b0:400e:c03::65
google.com has IPv6 address 2607:f8b0:400e:c03::66
google.com has IPv6 address 2607:f8b0:400e:c03::64
google.com mail is handled by 10 smtp.google.com.
I ran the failing command above in strace and saw that it's trying to
open /etc/resolv.conf
[...]
206 515079 [main] host 2426 open: open(/etc/resolv.conf, 0x0)
58 515137 [main] host 2426 normalize_posix_path: src
/etc/resolv.conf
59 515196 [main] host 2426 normalize_posix_path:
/etc/resolv.conf = normalize_posix_path (/etc/resolv.conf)
63 515259 [main] host 2426 mount_info::conv_to_win32_path:
conv_to_win32_path (/etc/resolv.conf)
68 515327 [main] host 2426 mount_info::cygdrive_win32_path: src
'/etc/resolv.conf', dst ''
61 515388 [main] host 2426 mount_info::conv_to_win32_path:
src_path /etc/resolv.conf, dst C:\cygwin64\etc\resolv.conf, flags
0x30008, rc 0
81 515469 [main] host 2426 symlink_info::check: 0xC0000034 =
NtCreateFile (\??\C:\cygwin64\etc\resolv.conf)
82 515551 [main] host 2426 symlink_info::check: 0xC0000034 =
NtQueryInformationFile (\??\C:\cygwin64\etc\resolv.conf)
90 515641 [main] host 2426 symlink_info::check: 0xC0000034 =
NtCreateFile (\??\C:\cygwin64\etc\resolv.conf.exe)
81 515722 [main] host 2426 symlink_info::check: 0xC0000034 =
NtQueryInformationFile (\??\C:\cygwin64\etc\resolv.conf.exe)
90 515812 [main] host 2426 symlink_info::check: 0xC0000034 =
NtCreateFile (\??\C:\cygwin64\etc\resolv.conf.lnk)
81 515893 [main] host 2426 symlink_info::check: 0xC0000034 =
NtQueryInformationFile (\??\C:\cygwin64\etc\resolv.conf.lnk)
88 515981 [main] host 2426 symlink_info::check: 0xC0000034 =
NtCreateFile (\??\C:\cygwin64\etc\resolv.conf.exe.lnk)
82 516063 [main] host 2426 symlink_info::check: 0xC0000034 =
NtQueryInformationFile (\??\C:\cygwin64\etc\resolv.conf.exe.lnk)
81 516144 [main] host 2426 symlink_info::check: 0 =
symlink.check(C:\cygwin64\etc\resolv.conf, 0x7FFFFB4B0) (mount_flags
0x30008, path_flags 0x0)
64 516208 [main] host 2426 mount_info::conv_to_win32_path:
conv_to_win32_path (/etc)
59 516267 [main] host 2426 mount_info::cygdrive_win32_path: src
'/etc', dst ''
60 516327 [main] host 2426 mount_info::conv_to_win32_path:
src_path /etc, dst C:\cygwin64\etc, flags 0x30008, rc 0
69 516396 [main] host 2426 symlink_info::check: 0x0 =
NtCreateFile (\??\C:\cygwin64\etc)
233 516629 [main] host 2426 symlink_info::check: not a symlink
65 516694 [main] host 2426 symlink_info::check: 0 =
symlink.check(C:\cygwin64\etc, 0x7FFFFB4B0) (mount_flags 0x30008,
path_flags 0x0)
62 516756 [main] host 2426 path_conv::check:
this->path(C:\cygwin64\etc\resolv.conf), has_acls(1)
61 516817 [main] host 2426 build_fh_pc: fh 0x80000BE18, dev
000000C3
60 516877 [main] host 2426 fhandler_base::open:
(\??\C:\cygwin64\etc\resolv.conf, 0x0)
89 516966 [main] host 2426 seterrno_from_nt_status:
/cygdrive/d/a/scallywag/cygwin/cygwin-3.5.0-1.x86_64/src/newlib-cygwin/winsup/cygwin/fhandler/base.cc:717
status 0xC0000034 -> windows error 2
75 517041 [main] host 2426 geterrno_from_win_error: windows
error 2 == errno 2
59 517100 [main] host 2426 fhandler_base::open: 0xC0000034 =
NtCreateFile (0x7FF84CA3A060, 0x80100000,
\??\C:\cygwin64\etc\resolv.conf, io, NULL, 0x0, 0x7, 0x1, 0x4020, NULL, 0)
85 517185 [main] host 2426 fhandler_base::open: 0 =
fhandler_base::open(\??\C:\cygwin64\etc\resolv.conf, 0x0)
90 517275 [main] host 2426 fhandler_base::open_fs: 0 =
fhandler_disk_file::open(\??\C:\cygwin64\etc\resolv.conf, 0x0)
90 517365 [main] host 2426 open: -1 = open(/etc/resolv.conf,
0x0), errno 2
[...]
I confirmed this was the problem by creating /etc/resolv.conf (within
the Cygwin root, not a symlink) and included the search domain and IPv4
and IPv6 dns servers, after which the -6 option no longer timed out.
--
Jim Garrison
j...@acm.org
--
Problem reports: https://cygwin.com/problems.html
FAQ: https://cygwin.com/faq/
Documentation: https://cygwin.com/docs.html
Unsubscribe info: https://cygwin.com/ml/#unsubscribe-simple