即使在 16.04 上安装了 winbind,Windows/WINS 主机名仍然不起作用

即使在 16.04 上安装了 winbind,Windows/WINS 主机名仍然不起作用

过去,我能够通过执行sudo apt-get install winbind然后编辑/etc/nsswitch.conf(添加wins到行尾hosts:)从 Ubuntu 内部解析 LAN 上的 Windows 主机名。它出现在 Ubuntu 16.04 中(实际上使用 Xubuntu 16.04),这不再足够了。

示例输出:

me@myubuntumachine:~$ ping mywindowsmachine
ping: unknown host mywindowsmachine

(标签:NetBIOS WINS)

答案1

我自己研究了这个问题,问题似乎是缺少一个libnss_wins.so库,我检查了如何确保这个库存在于我的机器上,我发现sudo apt-get install libnss-winbind并这样做立即解决了问题。

更多信息:我通过捕获输出来检查发生了什么strace ping mywindowsmachine,问题很容易发现,因为程序试图找到一个不存在的文件,libnss_wins.so.2。这显示了一个简单的解决方案,即确保文件存在。下面是截断的 strace 输出,仅显示与搜索此libnss_wins.so.2文件有关的行,这里重要的是,直到最后一次,每次查找文件的尝试都会失败。在我的另一台 Ubuntu 机器上,我比较了相同的strace输出,它在第四次或第五次尝试时成功了:

open("/lib/x86_64-linux-gnu/tls/x86_64/libnss_wins.so.2", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/lib/x86_64-linux-gnu/tls/x86_64", 0x7ffd56786e80) = -1 ENOENT (No such file or directory)
open("/lib/x86_64-linux-gnu/tls/libnss_wins.so.2", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/lib/x86_64-linux-gnu/tls", 0x7ffd56786e80) = -1 ENOENT (No such file or directory)
open("/lib/x86_64-linux-gnu/x86_64/libnss_wins.so.2", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/lib/x86_64-linux-gnu/x86_64", 0x7ffd56786e80) = -1 ENOENT (No such file or directory)
open("/lib/x86_64-linux-gnu/libnss_wins.so.2", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/lib/x86_64-linux-gnu", {st_mode=S_IFDIR|0755, st_size=12288, ...}) = 0
open("/usr/lib/x86_64-linux-gnu/tls/x86_64/libnss_wins.so.2", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/usr/lib/x86_64-linux-gnu/tls/x86_64", 0x7ffd56786e80) = -1 ENOENT (No such file or directory)
open("/usr/lib/x86_64-linux-gnu/tls/libnss_wins.so.2", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/usr/lib/x86_64-linux-gnu/tls", 0x7ffd56786e80) = -1 ENOENT (No such file or directory)
open("/usr/lib/x86_64-linux-gnu/x86_64/libnss_wins.so.2", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/usr/lib/x86_64-linux-gnu/x86_64", 0x7ffd56786e80) = -1 ENOENT (No such file or directory)
open("/usr/lib/x86_64-linux-gnu/libnss_wins.so.2", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/usr/lib/x86_64-linux-gnu", {st_mode=S_IFDIR|0755, st_size=69632, ...}) = 0
open("/lib/tls/x86_64/libnss_wins.so.2", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/lib/tls/x86_64", 0x7ffd56786e80) = -1 ENOENT (No such file or directory)
open("/lib/tls/libnss_wins.so.2", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/lib/tls", 0x7ffd56786e80)        = -1 ENOENT (No such file or directory)
open("/lib/x86_64/libnss_wins.so.2", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/lib/x86_64", 0x7ffd56786e80)     = -1 ENOENT (No such file or directory)
open("/lib/libnss_wins.so.2", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/lib", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
open("/usr/lib/tls/x86_64/libnss_wins.so.2", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/usr/lib/tls/x86_64", 0x7ffd56786e80) = -1 ENOENT (No such file or directory)
open("/usr/lib/tls/libnss_wins.so.2", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/usr/lib/tls", 0x7ffd56786e80)    = -1 ENOENT (No such file or directory)
open("/usr/lib/x86_64/libnss_wins.so.2", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/usr/lib/x86_64", 0x7ffd56786e80) = -1 ENOENT (No such file or directory)
open("/usr/lib/libnss_wins.so.2", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)

相关内容