---
title: Network Diagnostic Tools
description: Basic terminal commands for checking connectivity, routes, ports, DNS records, and HTTP responses
tokens: ~425
---

# Network Diagnostic Tools

A few diagnostic tools that help to check whether a host is reachable, how traffic travels through the network, which ports are open, how DNS resolves, and what response a server returns.

## Commands

### `ping` - check if a host is reachable

`ping` sends small packets to a host and waits for a reply. It is useful for checking basic connectivity, for example when you are not sure whether the problem is with the network, browser, or application.

```bash
ping -c 4 8.8.8.8
ping google.com
ping6 2606:4700:4700::1111
```

### `traceroute` - show the route to a host

`traceroute` shows the network hops between your machine and the destination. It helps to debug where a connection slows down or fails.

```bash
traceroute google.com  
```

On Windows the command is `tracert`.

### `netstat` - inspect network connections

`netstat` netstat shows your active network connections, listening ports, and routing information.

### `nslookup` - query DNS records

nslookup checks how a domain name resolves to an IP address. Useful for simple DNS debugging.

```bash
nslookup google.com
```

### `dig` - detailed DNS lookup

`dig` is a more detailed DNS diagnostic tool. It can query specific record types, such as A, AAAA, MX, TXT, or CNAME

```bash
dig google.com
```

### `curl` - make HTTP requests from the terminal

`curl` sends requests to URLs and prints the response. It is useful for checking APIs, headers, redirects, and server responses.

```bash
curl google.com
curl -I google.com         # show only response headers
curl -L google.com         # follow redirects
curl -X POST google.com -H "Content-Type: application/json" -d '{"name": "John"}' # send a POST request with JSON body
```