Linux系统ping域名失败,提示Name or service not known
Last updated
2023-01-18 17:55:05
{"value":"### \u95ee\u9898\u73b0\u8c61\n\nping\u516c\u7f51\u57df\u540d\u5931\u8d25\uff0c\u63d0\u793aName or service not known\uff0c\u4f46\u53ef\u4ee5ping\u901a\u5f39\u6027\u516c\u7f51IP\u3002\n\n### \u6839\u56e0\u5206\u6790\n\n\u51fa\u73b0\u8be5\u95ee\u9898\u901a\u5e38\u6709\u4e09\u4e2a\u539f\u56e0\uff1a\n\n1.\/etc\/resolv.conf\u672a\u914d\u7f6eDNS\u5730\u5740\u6216\u8005DNS\u5730\u5740\u9519\u8bef\u5bfc\u81f4\u3002\n\n2.\/etc\/nsswitch.conf\u6587\u4ef6\u5220\u9664DNS\u89e3\u6790\u8bb0\u5f55\u5bfc\u81f4\u3002\n\n3.\/lib64\/libnss_dns.so.2\u5e93\u6587\u4ef6\u4e22\u5931\u5bfc\u81f4\u65e0\u6cd5\u89e3\u6790\u57df\u540d\u3002\n\n### \u5904\u7406\u65b9\u6cd5\n\n#### \u573a\u666f\u4e00\uff1a\/etc\/resolv.conf\u672a\u914d\u7f6eDNS\u5730\u5740\u6216\u8005DNS\u5730\u5740\u9519\u8bef\u5bfc\u81f4\u3002\n\n\/etc\/resolv.conf\u4e2d\u6700\u5173\u952e\u7684\u662fnameserver\u9879\uff0c\u5982\u679c\u6ca1\u6307\u5b9anameserver\u5c31\u627e\u4e0d\u5230DNS\u670d\u52a1\u5668\uff0c\u5176\u5b83\u5173\u952e\u5b57\u662f\u53ef\u9009\u7684\u3002\nnameserver\u8868\u793a\u89e3\u6790\u57df\u540d\u65f6\u4f7f\u7528\u8be5\u5730\u5740\u6307\u5b9a\u7684\u4e3b\u673a\u4e3a\u57df\u540d\u670d\u52a1\u5668\u3002\u5176\u4e2d\u57df\u540d\u670d\u52a1\u5668\u662f\u6309\u7167\u6587\u4ef6\u4e2d\u51fa\u73b0\u7684\u987a\u5e8f\u6765\u67e5\u8be2\u7684\uff0c\u4e14\u53ea\u6709\u5f53\u7b2c\u4e00\u4e2anameserver\u6ca1\u6709\u53cd\u5e94\u65f6\u624d\u67e5\u8be2\u4e0b\u4e00\u4e2a\u7684nameserver\u3002\n\u8bf7\u68c0\u67e5\/etc\/resolv.conf\u4e2d\u914d\u7f6e\u7684DNS\u5730\u5740\u3002\n\n#### \u573a\u666f\u4e8c\uff1a\/etc\/nsswitch.conf\u6587\u4ef6\u5220\u9664DNS\u89e3\u6790\u8bb0\u5f55\u5bfc\u81f4\u3002\n\n\u68c0\u67e5\/etc\/nsswitch.conf\u662f\u5426\u6709DNS\u89e3\u6790\u914d\u7f6e\u3002\n\n![](https:\/\/97yw3pix.hk03.1112oss.com\/TechnicalQA%2F%E6%96%87%E6%A1%A3%2Fweek10%2FLinux%E7%B3%BB%E7%BB%9Fping%E5%9F%9F%E5%90%8D%E5%A4%B1%E8%B4%A5%EF%BC%8C%E6%8F%90%E7%A4%BAName%20or%20service%20not%20known%2F1.png)\n\n\u56de\u663e\u4fe1\u606f\u5982\u4e0b\u6240\u793a\uff0chosts\u884c\u4e2d\u672a\u914d\u7f6eDNS\u9009\u9879\uff0c\u5bfc\u81f4\u89e3\u6790\u57df\u540d\u65f6\u4e0d\u4f1a\u8bfb\u53d6\/etc\/resolv.conf\uff0c\u5bfc\u81f4\u57df\u540d\u89e3\u6790\u5931\u8d25\u3002\n\n![](https:\/\/97yw3pix.hk03.1112oss.com\/TechnicalQA%2F%E6%96%87%E6%A1%A3%2Fweek10%2FLinux%E7%B3%BB%E7%BB%9Fping%E5%9F%9F%E5%90%8D%E5%A4%B1%E8%B4%A5%EF%BC%8C%E6%8F%90%E7%A4%BAName%20or%20service%20not%20known%2F2.png)\n\n\u6253\u5f00\/etc\/nsswitch.conf\u627e\u5230hosts\u884c\u6dfb\u52a0DNS\u89e3\u6790\u3002\n\n![](https:\/\/97yw3pix.hk03.1112oss.com\/TechnicalQA%2F%E6%96%87%E6%A1%A3%2Fweek10%2FLinux%E7%B3%BB%E7%BB%9Fping%E5%9F%9F%E5%90%8D%E5%A4%B1%E8%B4%A5%EF%BC%8C%E6%8F%90%E7%A4%BAName%20or%20service%20not%20known%2F3.png)\n\n#### \u573a\u666f\u4e09\uff1a\/lib64\/libnss_dns.so.2\u5e93\u6587\u4ef6\u4e22\u5931\u5bfc\u81f4\u65e0\u6cd5\u89e3\u6790\u57df\u540d\u3002\n\n\/lib64\/libnss_dns.so.2\u5e93\u6587\u4ef6\u7531glibc\u5305\u4ea7\u751f\uff0c\u53ef\u4ee5\u901a\u8fc7\u6821\u9a8cglibc\u67e5\u770b\u5305\u662f\u5426\u88ab\u4fee\u6539\u3002\n\n![](https:\/\/97yw3pix.hk03.1112oss.com\/TechnicalQA%2F%E6%96%87%E6%A1%A3%2Fweek10%2FLinux%E7%B3%BB%E7%BB%9Fping%E5%9F%9F%E5%90%8D%E5%A4%B1%E8%B4%A5%EF%BC%8C%E6%8F%90%E7%A4%BAName%20or%20service%20not%20known%2F4.png)\n\n\u56de\u663e\u4fe1\u606f\u5982\u4e0b\u6240\u793a\uff0c\u8bf4\u660e\/lib64\/libnss_dns.so.2\u6587\u4ef6\u7f3a\u5931\u3002\n\n![](https:\/\/97yw3pix.hk03.1112oss.com\/TechnicalQA%2F%E6%96%87%E6%A1%A3%2Fweek10%2FLinux%E7%B3%BB%E7%BB%9Fping%E5%9F%9F%E5%90%8D%E5%A4%B1%E8%B4%A5%EF%BC%8C%E6%8F%90%E7%A4%BAName%20or%20service%20not%20known%2F5.png)\n\n\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\uff0c\u91cd\u65b0\u5efa\u7acb\u8f6f\u94fe\u63a5\u3002\n\n![](https:\/\/97yw3pix.hk03.1112oss.com\/TechnicalQA%2F%E6%96%87%E6%A1%A3%2Fweek10%2FLinux%E7%B3%BB%E7%BB%9Fping%E5%9F%9F%E5%90%8D%E5%A4%B1%E8%B4%A5%EF%BC%8C%E6%8F%90%E7%A4%BAName%20or%20service%20not%20known%2F6.png)"}