当前位置:网站首页>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的情况。
边栏推荐
- stop slave卡住--事务的事件没有复制完整
- go 多线程数据搜索
- The motivation of AES Advanced Encryption Protocol
- Array advanced improvement
- China Academy of information technology, Tsinghua University, Tencent security, cloud native security, industry university research and use strong alliance!
- Splunk audit 的设定
- 力扣刷题(2022-6-28)
- Configuration clic droit pour choisir d'ouvrir le fichier avec vs Code
- 剑指 Offer II 099. 最小路径之和-双百代码
- [Solved] Splunk: Cannot get username when all users are selected“
猜你喜欢
![[hardware] origin of standard resistance value](/img/d1/b9184c508d363eb0fa018ea6a57a10.png)
[hardware] origin of standard resistance value

地方经销商玩转社区团购模式,百万运营分享

Go language sqlx library operation SQLite3 database addition, deletion, modification and query

创新实力再获认可!腾讯安全MSS获2022年度云原生安全守护先锋
![[chestnut sugar GIS] ArcScene - how to make elevation map with height](/img/91/f3df0a7633263c6264cb5c27eb149f.png)
[chestnut sugar GIS] ArcScene - how to make elevation map with height

成功改变splunk 默认URL root path

Local dealers play the community group purchase mode and share millions of operations

MySQL queries nearby data And sort by distance

Chow-Liu Tree

Data analysis learning records -- complete a simple one-way ANOVA with Excel
随机推荐
設置單擊右鍵可以選擇用VS Code打開文件
Value sequence < detailed explanation of daily question >
ServletContext learning diary 1
[leetcode] there are duplicate elements [217]
2016. 增量元素之间的最大差值
[leetcode] most elements [169]
LeetCode 968. 监控二叉树
AES高級加密協議的動機闡述
严守工期,确保质量,这家AI数据标注公司做到了!
go 条件变量
Pytorch training CPU usage continues to grow (Bug)
Lambda表达式:一篇文章带你通透
设置单击右键可以选择用VS Code打开文件
Jielizhi, production line assembly link [chapter]
Kubernetes uses the host name to allocate the pod on the specified node
[chestnut sugar GIS] ArcMap - how to batch modify the font, color, size, etc. of annotation elements
Go language sqlx library operation SQLite3 database addition, deletion, modification and query
Qt QScrollArea
pytorch训练CPU占用持续增长(bug)
归并排序详解及应用