Network Checks with ping, ss, curl
Network troubleshooting is a crucial skill for any Linux user, whether you are managing servers, developing applications, or simply ensuring your system is connected. Several command line tools are available to help you quickly diagnose and understand network connectivity and performance issues. Among the most essential are ping, ss, and curl. Each serves a unique purpose: ping checks basic reachability and latency, ss examines open sockets and connections on your system, and curl allows you to interact with web endpoints or APIs directly from the terminal. Understanding how and when to use these tools will help you efficiently pinpoint and resolve network problems.
ping -c 4 google.com
The ping command sends ICMP echo requests to a remote host and waits for replies, allowing you to check whether a host is reachable and measure the time taken for each packet. The -c option specifies the number of packets to send, which is useful for limiting the test. In the output, you can see each response, the round-trip time (time), and a summary at the end showing packet loss and average latency. If you see 100% packet loss or no replies, it usually means the host is unreachable or ICMP is blocked. Use ping for quick, basic connectivity tests and to measure network latency.
ss -tuln
The ss command is a powerful utility for inspecting your system's network sockets and connections. The -tuln options list TCP (-t), UDP (-u), listening (-l), and show numeric addresses and ports (-n). This helps you see which ports are open and which services are listening. You can further filter connections, such as viewing only established TCP connections with ss -t state established. Use ss to understand what network services are running, check for unexpected open ports, or troubleshoot local connectivity issues.
The curl tool allows you to make HTTP requests directly from the terminal. With the -I option, curl fetches only the HTTP headers, which is useful for quickly checking if a web server is up and responding. You can also use curl to retrieve the full content of a web page or interact with APIs by specifying additional options. This makes curl invaluable for diagnosing web service availability, checking API responses, or debugging client-server interactions.
curl -I https://example.com
- Use
pingwhen you want to verify if a remote host is reachable over the network; - Check for packet loss or high latency to diagnose connectivity or performance issues;
- Limitations: does not test specific ports or services, and may be blocked by firewalls.
- Use
ssto inspect which ports and services are open on your local machine; - Identify active or listening network connections and troubleshoot service bindings;
- Limitations: only shows local system sockets, not remote host status.
- Use
curlfor checking the availability and response of web servers or APIs; - Test HTTP(S) endpoints, retrieve headers, or fetch content directly from the terminal;
- Limitations: only works with application layer protocols like HTTP, not general network reachability.
¡Gracias por tus comentarios!
Pregunte a AI
Pregunte a AI
Pregunte lo que quiera o pruebe una de las preguntas sugeridas para comenzar nuestra charla
Genial!
Completion tasa mejorada a 8.33
Network Checks with ping, ss, curl
Desliza para mostrar el menú
Network troubleshooting is a crucial skill for any Linux user, whether you are managing servers, developing applications, or simply ensuring your system is connected. Several command line tools are available to help you quickly diagnose and understand network connectivity and performance issues. Among the most essential are ping, ss, and curl. Each serves a unique purpose: ping checks basic reachability and latency, ss examines open sockets and connections on your system, and curl allows you to interact with web endpoints or APIs directly from the terminal. Understanding how and when to use these tools will help you efficiently pinpoint and resolve network problems.
ping -c 4 google.com
The ping command sends ICMP echo requests to a remote host and waits for replies, allowing you to check whether a host is reachable and measure the time taken for each packet. The -c option specifies the number of packets to send, which is useful for limiting the test. In the output, you can see each response, the round-trip time (time), and a summary at the end showing packet loss and average latency. If you see 100% packet loss or no replies, it usually means the host is unreachable or ICMP is blocked. Use ping for quick, basic connectivity tests and to measure network latency.
ss -tuln
The ss command is a powerful utility for inspecting your system's network sockets and connections. The -tuln options list TCP (-t), UDP (-u), listening (-l), and show numeric addresses and ports (-n). This helps you see which ports are open and which services are listening. You can further filter connections, such as viewing only established TCP connections with ss -t state established. Use ss to understand what network services are running, check for unexpected open ports, or troubleshoot local connectivity issues.
The curl tool allows you to make HTTP requests directly from the terminal. With the -I option, curl fetches only the HTTP headers, which is useful for quickly checking if a web server is up and responding. You can also use curl to retrieve the full content of a web page or interact with APIs by specifying additional options. This makes curl invaluable for diagnosing web service availability, checking API responses, or debugging client-server interactions.
curl -I https://example.com
- Use
pingwhen you want to verify if a remote host is reachable over the network; - Check for packet loss or high latency to diagnose connectivity or performance issues;
- Limitations: does not test specific ports or services, and may be blocked by firewalls.
- Use
ssto inspect which ports and services are open on your local machine; - Identify active or listening network connections and troubleshoot service bindings;
- Limitations: only shows local system sockets, not remote host status.
- Use
curlfor checking the availability and response of web servers or APIs; - Test HTTP(S) endpoints, retrieve headers, or fetch content directly from the terminal;
- Limitations: only works with application layer protocols like HTTP, not general network reachability.
¡Gracias por tus comentarios!