当前位置:网站首页>ping域名报错unknown host,nslookup/systemd-resolve可以正常解析,ping公网地址通怎么解决?
ping域名报错unknown host,nslookup/systemd-resolve可以正常解析,ping公网地址通怎么解决?
2022-07-02 22:09:00 【洒满阳光的午后】
异常现象
ping域名报错unknown host,nslookup/systemd-resolve可以正常解析,ping公网地址通。
[email protected]:/etc# ping baidu.com
ping: unknown host baidu.com
[email protected]:/etc# nslookup www.baidu.com
Server: 192.168.61.200
Address: 192.168.61.200#53
Non-authoritative answer:
www.baidu.com canonical name = www.a.shifen.com.
Name: www.a.shifen.com
Address: 183.232.231.174
Name: www.a.shifen.com
Address: 183.232.231.172
[email protected]:/etc# systemd-resolve www.baidu.com
www.baidu.com: 183.232.231.172
183.232.231.174
(www.a.shifen.com)
-- Information acquired via protocol DNS in 74.1ms.
-- Data is authenticated: no
[email protected]:/etc# ping 183.232.231.174
PING 183.232.231.174 (183.232.231.174) 56(84) bytes of data.
64 bytes from 183.232.231.174: icmp_seq=1 ttl=54 time=33.4 ms
64 bytes from 183.232.231.174: icmp_seq=2 ttl=54 time=32.7 ms
64 bytes from 183.232.231.174: icmp_seq=3 ttl=54 time=33.9 ms
64 bytes from 183.232.231.174: icmp_seq=4 ttl=54 time=45.0 ms
^C
--- 183.232.231.174 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3013ms
rtt min/avg/max/mdev = 32.723/36.281/45.043/5.077 ms
需要检查的异常点
1、检查/etc/nsswitch.conf
[email protected]:~# cat /etc/nsswitch.conf
# /etc/nsswitch.conf
#
# Example configuration of GNU Name Service Switch functionality.
# If you have the `glibc-doc-reference' and `info' packages installed, try:
# `info libc "Name Service Switch"' for information about this file.
passwd: compat
group: compat
shadow: compat
gshadow: files
hosts: files dns
networks: files
protocols: db files
services: db files
ethers: db files
rpc: db files
netgroup: nis
检查hosts行,是否为 files dns,files 表示使用 /etc/hosts 和 /etc/network 配置文件,dns 表示使用 /etc/resolv.conf文件中的DNS解析地址。
ping 程序解析域名依赖于C库中的函数 gethostbyname() 和 gethostbyaddr(),对应配置文件 /etc/nsswitch.conf 中的hosts 配置项。nslookup 是直接使用 /etc/resolv.conf 中的DNS解析域名,因此不受该文件影响。
2、检查/etc/resolv.conf文件权限
# Ubuntu系统
# Ubuntu系统中resolv.conf为一个软连接,如有问题,可以手动重建软连接ln -s /etc/resolvconf/run/resolv.conf /etc/resolv.conf
# 重建完成后注意检查/etc/resolvconf/run/resolv.conf配置是否正确
[email protected]:~# ll /etc/resolv.conf
lrwxrwxrwx 1 root root 29 Apr 26 16:20 /etc/resolv.conf -> ../run/resolvconf/resolv.conf
# CentOS系统
[[email protected] ~]$ ll /etc/resolv.conf
-rw-r--r--. 1 root root 61 Nov 3 2021 /etc/resolv.conf
如果resolv.conf文件无读权限,也会造成ping uknown host的情况。
边栏推荐
- Share 10 JS closure interview questions (diagrams), come in and see how many you can answer correctly
- 用matlab调用vs2015来编译vs工程
- 1px pixel compatibility of mobile terminal, 1px border
- Lambda expression: an article takes you through
- 設置單擊右鍵可以選擇用VS Code打開文件
- Value sequence < detailed explanation of daily question >
- Configuration clic droit pour choisir d'ouvrir le fichier avec vs Code
- ServletContext learning diary 1
- Array advanced improvement
- Performance optimization - rigorous mode
猜你喜欢
Higher order operation of bits
Generics and reflection, this is enough
LeetCode 968. Monitor binary tree
MySQL reset password, forget password, reset root password, reset MySQL password
【喜欢的诗词】好了歌
Methods to solve the tampering of Chrome browser and edeg browser homepage
Motivation du Protocole de chiffrement avancé AES
Array advanced improvement
Looking at Ctrip's toughness and vision from the Q1 financial report in 2022
力扣刷题(2022-6-28)
随机推荐
Innovation strength is recognized again! Tencent security MSS was the pioneer of cloud native security guard in 2022
Minimum spanning tree
解决Chrome浏览器和Edeg浏览器主页被篡改的方法
P1007 single log bridge
[Luogu p1541] tortoise chess [DP]
Redis 过期策略+conf 记录
严守工期,确保质量,这家AI数据标注公司做到了!
How does Jerry test the wrong touch rate of keys [chapter]
门牌制作 C语言
Easyclick, EC Quanlang network verification source code
Jerry's charge unplugged, unable to touch the boot [chapter]
Pytorch training CPU usage continues to grow (Bug)
归并排序详解及应用
Golang's learning route
QT qsplitter splitter
剑指 Offer II 099. 最小路径之和-双百代码
20220527_数据库过程_语句留档
地方经销商玩转社区团购模式,百万运营分享
[chestnut sugar GIS] ArcScene - how to make elevation map with height
Data analysis learning records -- complete a simple one-way ANOVA with Excel