当前位置:网站首页>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的情况。
边栏推荐
- Data analysis learning records -- complete a simple one-way ANOVA with Excel
- [羊城杯2020]easyphp
- 容器化技术在嵌入式领域的应用
- Splunk audit setting
- 数据分析学习记录--用EXCEL完成简单的单因素方差分析
- Start from the bottom structure to learn the customization and testing of FPGA --- Xilinx ROM IP
- Generics and reflection, this is enough
- Jerry's prototype will trigger shutdown after multiple touches [chapter]
- The motivation of AES Advanced Encryption Protocol
- How does Jerry test the wrong touch rate of keys [chapter]
猜你喜欢
严守工期,确保质量,这家AI数据标注公司做到了!
Performance optimization - rigorous mode
Qt QScrollArea
Lambda expression: an article takes you through
[leetcode] reverse the word III in the string [557]
ServletContext learning diary 1
Value sequence < detailed explanation of daily question >
Construction of Hisilicon 3559 universal platform: rotation operation on the captured YUV image
Minimum spanning tree
Gas station [problem analysis - > problem conversion - > greed]
随机推荐
Loss function~
归并排序详解及应用
Performance optimization - rigorous mode
Detailed explanation and application of merging and sorting
odoo13搭建医院HRP环境(详细步骤)
DTM distributed transaction manager PHP collaboration client V0.1 beta release!!!
LC173. 二叉搜索树迭代器
[leetcode] most elements [169]
The threshold value of fusing proportion cannot be changed with sentinel, and setting the slow call proportion has no effect
Pytorch training CPU usage continues to grow (Bug)
pytorch训练CPU占用持续增长(bug)
World Environment Day | Chow Tai Fook serves wholeheartedly to promote carbon reduction and environmental protection
Generics and reflection, this is enough
`Usage of ${}`
MySQL查询附近的数据.并按距离进行排序.
P1007 single log bridge
Innovation strength is recognized again! Tencent security MSS was the pioneer of cloud native security guard in 2022
损失函数~
boot actuator - prometheus使用
数据分析学习记录(二)---响应曲面法及Design-Expert的简单使用