参考文献:①http://www.360doc.com/content/14/1216/16/18578054_433393555.shtml,②https://www.codeweavers.com/support/wiki/diag/missinglibnss_mdns,④https://blog.csdn.net/sws9999/article/details/7018892
2440的板子可以ping通IP但是无法ping通域名,提示ping:bad address
[root@UnixHost ]# ping www.baidu.com
ping: bad address 'www.baidu.com'
怀疑是DNS服务器有问题!于是输入
[root@UnixHost ]# cat /etc/resolv.conf
nameserver 202.103.24.68
[root@UnixHost ]# ping 202.103.24.68
PING 202.103.24.68 (202.103.24.68): 56 data bytes
发现域名服务器可能有问题!
于是将域名服务器改为114.114.114.114或者8.8.8.8
[root@UnixHost ]# echo nameserver 114.114.114.114 > /etc/resolv.conf
[root@UnixHost ]# cat /etc/resolv.conf
nameserver 114.114.114.114
还是提示
[root@UnixHost ]# ping www.baidu.com
ping: bad address 'www.baidu.com'
[root@UnixHost ]#
按照参考文献的思路,有可能是因为dns库有问题,于是
[root@UnixHost ]# strace ping www.baidu.com
execve("/bin/ping", ["ping", "www.baidu.com"], [/* 10 vars */]) = 0
brk(0) = 0xf9000
uname({sys="Linux", node="UnixHost", ...}) = 0
...
open("/lib/libnss_mdns4_minimal.so.2", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/lib/libnss_mdns4_minimal.so.2", O_RDONLY) = -1 ENOENT (No such file or directory)
write(2, "ping: bad address 'www.baidu.com"..., 34ping: bad address 'www.baidu.com'
) = 34
exit_group(1) = ?
+++ exited with 1 +++
我滴乖乖,原来是少了一个库:libnss_mdns4_minimal.so.2,于是到交叉编译环境里边找到这个库放到/lib下面。strace真是神器呀!!!
但是交叉编译环境中搜索了半天,并没有发现以上so库,于是又找到了参考文献②,说是该库跟/etc/nsswitch.conf(Name Service Switch)的配置有关,cat该文件发现有如下语句:
hosts: files mdns4_minimal [NOTFOUND=return] dns mdns4
按照参考文献④,将改行注释掉,改为
#hosts: files mdns4_minimal [NOTFOUND=return] dns mdns4
hosts: file dns [NOTFOUND=return]
[root@UnixHost ]# vi /etc/nsswitch.conf
[root@UnixHost ]# ping www.baidu.com
PING www.baidu.com (153.3.236.12): 56 data bytes
64 bytes from 153.3.236.12: seq=0 ttl=50 time=60.007 ms
64 bytes from 153.3.236.12: seq=1 ttl=50 time=55.153 ms
64 bytes from 153.3.236.12: seq=2 ttl=50 time=48.221 ms
至此,2440 ARM Linux无法解析域名的问题终于解决了!