Skip to content

Network Troubleshooting Tools in Termux

  • by

When managing websites or web applications, troubleshooting network, server, or performance-related issues is inevitable. Using Termux, an Android terminal emulator, you can perform a variety of diagnostics to identify and fix common problems. In this guide, we’ll cover essential tools and commands to help you troubleshoot websites and network issues from basic connectivity checks to advanced diagnostics.

1. Checking Network Connectivity

Network issues are often the first suspects when a website goes down or becomes unresponsive. These tools will help you diagnose if there are any issues with the network connection.

ping

The ping command is the most common tool for checking network connectivity. It sends ICMP (Internet Control Message Protocol) Echo Request messages to a destination (usually a domain or IP) and measures the round-trip time it takes for a response.

ping example.com

Explanation:

  • ping: The command itself.
  • example.com: The domain name or IP address you want to test.

What it does: If the server is reachable, it will return a series of replies, showing the time it takes to send a packet to the server and receive a reply. If the server is unreachable, the output will indicate packet loss or a timeout.

traceroute

The traceroute command tracks the path packets take from your device to the destination server. It is useful for diagnosing where delays or losses are happening in the route.

traceroute example.com

Explanation:

  • traceroute: The command used to trace the route packets take to reach their destination.
  • example.com: The destination domain or IP.

What it does: This tool shows each router along the way, displaying the time it took to reach each router (hop). It helps pinpoint where delays or packet losses are happening in the network.

mtr

mtr is a dynamic network diagnostic tool combining the functionality of ping and traceroute. It provides real-time statistics and visualizes the route packets take, which helps in pinpointing network problems more effectively.

mtr example.com

Explanation:

  • mtr: The command to start the tool.
  • example.com: The domain or IP address you want to test.

What it does: mtr continuously updates the route and round-trip times to each hop, making it easier to identify persistent or intermittent network issues.

netcat (nc)

netcat (often abbreviated as nc) is a versatile networking tool that can be used to test connectivity to specific ports on a remote server. It helps determine whether a service (like HTTP or HTTPS) is accessible.

nc -zv example.com 443

Explanation:

  • nc: The command for netcat.
  • -z: Tells netcat to scan without sending data (just checking if a port is open).
  • -v: Verbose mode to print the status of each connection.
  • example.com: The domain name of the server.
  • 443: The port (in this case, HTTPS).

What it does: It checks if a specific port (e.g., 443 for HTTPS) is open and listening on the server.

telnet

telnet is another tool used to check connectivity to a specific port. It can be used to test if services like HTTP, FTP, or SSH are accessible remotely.

telnet example.com 443

Explanation:

  • telnet: The command to initiate a telnet session.
  • example.com: The domain name of the server.
  • 443: The port you want to check.

What it does: Attempts to establish a connection to the specified port. If successful, it indicates that the service is reachable.

2. DNS Troubleshooting

Issues related to DNS (Domain Name System) resolution can prevent your website from loading, even if the server is running correctly. These tools help you diagnose DNS-related problems.

nslookup

nslookup is a basic DNS query tool used to obtain domain name or IP address mappings.

nslookup example.com

Explanation:

  • nslookup: The command used to query DNS records.
  • example.com: The domain name you are checking.

What it does: Queries the DNS server to resolve the domain to its associated IP address. If it fails, the issue may lie with DNS resolution.

dig

dig (Domain Information Groper) is a more advanced DNS lookup tool, providing detailed information about DNS records like A, MX, and TXT records.

dig example.com

Explanation:

  • dig: The command to initiate a DNS query.
  • example.com: The domain name to resolve.

What it does: Provides detailed output, including DNS query time, TTL (Time to Live), and the IP address for the domain. It is especially useful when debugging DNS propagation or misconfiguration issues.

host

host is a simpler DNS lookup tool, often preferred for quick queries. It’s easier to use compared to dig but provides less detailed information.

host example.com

Explanation:

  • host: The command for DNS lookup.
  • example.com: The domain name to query.

What it does: Resolves the domain name to its IP address and displays the result.

3. Website Performance Testing

If your website is loading slowly, these tools can help analyze server performance and identify bottlenecks.

curl

curl is a powerful tool for making HTTP requests. It can fetch headers, content, and performance metrics.

curl -I example.com

Explanation:

  • -I: Fetches only the HTTP headers (useful for diagnosing response codes and headers).
  • example.com: The target domain.

What it does: Returns the HTTP response headers, showing the status code (e.g., 200 OK) and server information.

curl -w "@curl-format.txt" -o /dev/null -s https://example.com

Explanation:

  • -w "@curl-format.txt": Uses a custom output format for performance metrics.
  • -o /dev/null: Discards the content of the page, as you’re only interested in performance stats.
  • -s: Runs curl in silent mode (no progress bar).

What it does: Measures various performance metrics like DNS resolution time, connection time, transfer time, and total time for the HTTP request.

wget

wget is a command-line tool for downloading files from a URL. It can also be used to check response headers.

wget --server-response example.com

Explanation:

  • --server-response: Instructs wget to print the HTTP headers from the server.

</

  • example.com: The URL from which the content will be fetched.

What it does: Displays the HTTP response headers received from the server when fetching the content. Useful for troubleshooting issues like redirections, response codes, or server configurations.

ab (Apache Benchmark)

ab is a tool for benchmarking the performance of an HTTP server. It helps test how many requests a server can handle per second.

ab -n 100 -c 10 http://example.com/

Explanation:

  • -n 100: The total number of requests to perform.
  • -c 10: The number of requests to make at a time (concurrency).
  • http://example.com/: The URL of the website you want to test.

What it does: Benchmarks the server by simulating 100 requests with 10 concurrent connections. It provides metrics on response time, requests per second, and more.

httperf

httperf is another tool used for testing web server performance. It is similar to ab but provides more detailed statistics.

httperf --server example.com --num-conn 100 --rate 10

Explanation:

  • --server example.com: The target web server.
  • --num-conn 100: The number of connections to make.
  • --rate 10: The rate at which the requests will be sent (10 per second).

What it does: Sends multiple requests to a web server and provides detailed performance data, including connection time and request success rate.

4. SSL/TLS Testing

SSL/TLS issues can lead to security warnings or failure to load HTTPS websites. These tools allow you to inspect and test SSL/TLS configurations.

openssl

openssl is a versatile tool for inspecting SSL certificates and testing HTTPS connections. It’s often used to diagnose SSL/TLS-related issues.

openssl s_client -connect example.com:443

Explanation:

  • s_client: Initiates an SSL/TLS connection to the specified server.
  • -connect example.com:443: Connects to the server on port 443 (HTTPS).

What it does: Starts an SSL/TLS handshake and prints out the certificate details, which can help troubleshoot SSL/TLS issues, such as expired certificates or untrusted certificate authorities.

openssl x509 -in cert.pem -noout -text

Explanation:

  • x509: A command for displaying certificate details.
  • -in cert.pem: Specifies the certificate file to examine.
  • -noout: Suppresses the encoded certificate output, showing only the human-readable details.
  • -text: Displays detailed information about the certificate.

What it does: Displays the details of an SSL certificate, including the subject, issuer, validity period, and extensions.

5. HTTP/HTTPS Headers Analysis

HTTP headers provide critical information about how a server is handling requests. Analyzing these headers helps troubleshoot issues like redirects, caching, and server configurations.

curl -I

Use the -I option with curl to fetch HTTP headers from the server.

curl -I https://example.com

Explanation:

  • -I: Fetches only the HTTP headers.
  • https://example.com: The URL from which headers are requested.

What it does: Returns the HTTP headers sent by the server, including the status code, content type, and server information.

wget –server-response

Use the --server-response option with wget to fetch HTTP headers.

wget --server-response https://example.com

Explanation:

  • --server-response: Displays the HTTP response headers.
  • https://example.com: The URL to fetch the headers for.

What it does: Fetches and displays HTTP headers sent by the server when attempting to retrieve the webpage.

http (httpie)

http is an alternative to curl, designed for easier HTTP requests and responses analysis.

http GET https://example.com

Explanation:

  • GET: The HTTP method used to request the resource.
  • https://example.com: The URL to send the GET request to.

What it does: Sends a GET request to the specified URL and outputs the response headers and body.

Conclusion

This guide covers a wide range of tools and commands you can use in Termux to troubleshoot issues with websites, servers, DNS, SSL/TLS, and network connectivity. These tools can help you diagnose and resolve most problems you’re likely to encounter when managing websites or working with servers. Whether you’re performing basic connectivity checks or diving into performance testing, this list has got you covered.