← Linux and the Command Line
Lesson 29 of 51 · 5 XP
ping — is there a connection
Theory
Machine translation, not yet reviewed by a native speaker.
ping sends small packets (ICMP echo) and waits for a reply:
ping google.com # endlessly, Ctrl+C to stop
ping -c 4 8.8.8.8 # exactly 4 packets
64 bytes from 8.8.8.8: icmp_seq=1 ttl=117 time=23.4 ms
--- 8.8.8.8 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3004ms
rtt min/avg/max/mdev = 22.9/23.6/24.5/0.6 ms
What to look at:
time— the latency (round-trip time): for games it should be under 50–80 ms;packet loss— losses: anything above 0% is bad;ttl— how many "hops" the packet has left.
Diagnosing "no internet", step by step:
ping 192.168.1.1(the router) — whether the local network works;ping 8.8.8.8— whether there's a way out to the internet;ping google.com— whether DNS works (turning names into IP addresses).
If step 2 is fine but step 3 isn't, it's DNS that's broken, not the network.
Many servers don't answer ping on purpose: replying is simply switched off for security reasons. No reply doesn't necessarily mean the server is down.
ping's neighbours: traceroute — the packet's route through the nodes, ip a — your IP addresses, ss -tulpn — which ports your machine is listening on.
The Linux built into the browser runs without a network, so try the networking commands on your own computer or a VPS.