1. ping 网站域名检测 DNS 解析
# 示例:ping百度域名
ping www.baidu.com
# 正常输出:Reply from 14.215.177.38: bytes=32 time=12ms TTL=128
# 异常提示:Ping request could not find host www.baidu.com. Please check the name and try again.作用:通过域名 ping 测试,若返回 "unknown host" 则可能是 DNS 服务器配置错误或域名解析失败
2. 检查 hosts 文件域名映射
Windows系统hosts文件路径
notepad C:\Windows\System32\drivers\etc\hostsLinux/macOS系统hosts文件路径
vi /etc/hosts
# 正确配置示例
192.168.1.100 internal-service.local作用:内网服务通过域名访问时,优先检查本地 hosts 文件是否正确映射 IP
3. ping 目标服务器 IP 地址
# 示例:ping 谷歌公共DNS服务器
ping 8.8.8.8
# 正常输出:64 bytes from 8.8.8.8: icmp_seq=1 ttl=118 time=34.5 ms
# 异常输出:Request timed out.作用:确认本地到目标服务器的网络链路是否通畅
4. telnet 检测端口连通性
# 示例:检测SMTP服务端口
telnet 163.com 25
# 正常输出:220 163.com Anti-spam GT for Coremail System (163com[20141201])
# 异常输出:Connect to 163.com 25 failed: Connection refused作用:判断目标服务是否启动及端口是否开放
5. 服务器端 telnet 检测
# 示例:在服务器上检测本地SSH服务
telnet 127.0.0.1 22
# 正常输出:SSH-2.0-OpenSSH_8.2p1 Ubuntu-4ubuntu0.5
# 防火墙阻挡:Connect to 127.0.0.1 22 failed: Connection refused
# 服务未启动:telnet: connect to address 127.0.0.1: Connection refused作用:区分是服务未启动还是防火墙阻挡导致的连接失败
6. ping 公共 DNS 服务器检测公网
# 示例:ping 114公共DNS
ping 114.114.114.114
# 正常输出:64 bytes from 114.114.114.114: icmp_seq=1 ttl=53 time=12.3 ms
# 异常情况:若所有公网IP都ping不通,可能是网关或ISP链路问题作用:确认是否可以访问 Internet 公网
7. 查看本地网络配置
Windows查看IP配置
ipconfig /allLinux/macOS查看IP配置
ifconfig -a
# 关键信息检查:
# IP Address: 192.168.1.100
# Default Gateway: 192.168.1.1
# DNS Servers: 114.114.114.114, 8.8.8.8作用:检查 IP 地址、网关、DNS 等配置是否正确
8. ping 默认网关检测内网连通
# 示例:ping本地网关
ping 192.168.1.1
# 正常输出:64 bytes from 192.168.1.1: icmp_seq=1 ttl=128 time=1.2 ms
# 异常输出:Request timed out. 可能是本地网络线缆或路由器问题作用:检测到内部网络接入点的连通性
Windows系统路由跟踪
tracert www.baidu.comLinux/macOS系统路由跟踪
traceroute www.baidu.com
# 正常输出示例:
# 1 1 ms 1 ms 1 ms 192.168.1.1
# 2 3 ms 2 ms 2 ms 10.10.1.1
# ...
# 异常情况:某一跳出现* * *,可能是路由节点故障作用:在多网络或 V** 环境中,判断请求是否经过正确网关 / 路由
#网络 #测试