Linux系统是一个开源的操作系统,广泛应用于服务器、嵌入式设备和个人电脑等领域。在Linux系统中测试网络连接是确保系统能够正常访问互联网或局域网资源的重要步骤。
ping www.google.com
如果返回类似以下的信息,说明系统能够上网:
PING www.google.com (172.217.168.46) 56(84) bytes of data.
64 bytes from zrh11s07-in-f4.1e100.net (172.217.168.46): icmp_seq=1 ttl=56 time=5.84 ms
64 bytes from zrh11s07-in-f4.1e100.net (172.217.168.46): icmp_seq=2 ttl=56 time=6.12 ms
traceroute www.google.com
这个命令会显示数据包从你的系统到目标主机所经过的路由节点。
curl -I https://www.google.com
如果返回类似以下的信息,说明Web服务可用:
HTTP/1.1 200 OK
Date: Mon, 01 Jan 2024 00:00:00 GMT
Expires: -1
Cache-Control: private, max-age=0
Content-Type: text/html; charset=ISO-8859-1
P3P: CP="This is not a P3P policy! See g.co/p3phelp for more info."
Server: gws
X-XSS-Protection: 0
X-Frame-Options: SAMEORIGIN
Alt-Svc: h3=":443"; ma=2592000,h3-29=":443"; ma=2592000,h3-T051=":443"; ma=2592000,h3-Q050=":443"; ma=2592000,h3-Q046=":443"; ma=2592000,h3-Q043=":443"; ma=2592000,quic=":443"; ma=2592000; v="43,42"
Transfer-Encoding: chunked
telnet www.google.com 80
如果返回类似以下的信息,说明端口可用:
Trying 172.217.168.46...
Connected to www.google.com.
Escape character is '^]'.
原因:
解决方法:
/etc/network/interfaces
或/etc/sysconfig/network-scripts/ifcfg-eth0
)/etc/resolv.conf
)iptables
或firewalld
)原因:
解决方法:
/etc/resolv.conf
)nslookup
或dig
命令检查域名解析是否正常原因:
解决方法:
telnet
或nc
命令检查目标端口是否开放iptables
或firewalld
)领取专属 10元无门槛券
手把手带您无忧上云