Networking Commands Guide

Table of contents

1. ping
Purpose: Check connectivity between your computer and another host (e.g., website or IP address).
Usage:
Sends packets to the specified host to check if it's reachable.
Shows time taken for each packet (latency).
ping [hostname or IP]
Example :
C:\Users\Atul>ping google.com
Pinging google.com [142.250.199.174] with 32 bytes of data:
Reply from 142.250.199.174: bytes=32 time=5ms TTL=60
Reply from 142.250.199.174: bytes=32 time=6ms TTL=60
Reply from 142.250.199.174: bytes=32 time=5ms TTL=60
Reply from 142.250.199.174: bytes=32 time=7ms TTL=60
Ping statistics for 142.250.199.174:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 5ms, Maximum = 7ms, Average = 5ms
2. traceroute / tracert :
Purpose: Trace the route packets take to reach a destination.
traceroute
is used in Linux/Mac.tracert
is used in Windows
Usage:
Shows each hop (router) on the way to the destination.
Helps diagnose where network slowdowns or failures occur
traceroute [hostname or IP] # Linux/Mac
tracert [hostname or IP] # Windows
Example :
C:\Users\Atul>tracert google.com
Tracing route to google.com [142.250.71.110]
over a maximum of 30 hops:
1 3 ms 3 ms 2 ms 192.168.0.1
2 4 ms 2 ms 3 ms 10.70.0.1
3 * * * Request timed out.
4 32 ms 5 ms 4 ms 94-31-241-43.intechonline.net [43.241.31.94]
5 11 ms 4 ms 4 ms 142.251.76.23
6 7 ms 3 ms 3 ms 192.178.86.249
7 5 ms 3 ms 3 ms pnbomb-ad-in-f14.1e100.net [142.250.71.110]
Trace complete.
3. netstat
Purpose: Display network statistics and active connections.
Usage:
netstat [options]
Common Options:
-a
: Show all active connections and listening ports.-n
: Show numerical addresses instead of resolving hostnames.-t
: Display TCP connections (Linux/Mac).-u
: Display UDP connections (Linux/Mac).-b
: Show executable involved in creating each connection (Windows).-p
: Show the PID and program name for each connection (Linux/Mac).
Example :
PS C:\Users\Atul> netstat -an
Active Connections
Proto Local Address Foreign Address State
TCP 0.0.0.0:135 0.0.0.0:0 LISTENING
TCP 0.0.0.0:445 0.0.0.0:0 LISTENING
TCP 127.0.0.1:49669 127.0.0.1:49670 ESTABLISHED
TCP 127.0.0.1:49670 127.0.0.1:49669 ESTABLISHED
TCP 192.168.0.107:62483 20.198.119.84:443 ESTABLISHED
TCP 192.168.0.107:62583 64.233.170.188:5228 ESTABLISHED
TCP 192.168.0.107:62669 4.153.25.42:443 CLOSE_WAIT
TCP 192.168.0.107:63355 23.206.173.48:443 CLOSE_WAIT
TCP 192.168.0.107:63356 40.99.31.162:443 ESTABLISHED
TCP 192.168.0.107:63357 23.206.173.48:443 CLOSE_WAIT
TCP 192.168.0.107:63365 13.107.246.254:443 CLOSE_WAIT
TCP 192.168.0.107:63378 66.33.60.193:443 ESTABLISHED
TCP 192.168.0.107:63461 204.79.197.203:443 TIME_WAIT
TCP 192.168.0.107:63462 204.79.197.203:443 TIME_WAIT
TCP 192.168.0.107:63474 151.101.153.51:443 ESTABLISHED
TCP 192.168.0.107:63476 192.168.0.1:53 TIME_WAIT
TCP 192.168.0.107:63477 192.168.0.1:53 TIME_WAIT
TCP 192.168.0.107:63487 172.175.234.12:443 CLOSE_WAIT
TCP 192.168.56.1:139 0.0.0.0:0 LISTENING
TCP [::]:135 [::]:0 LISTENING
TCP [::]:445 [::]:0 LISTENING
TCP [::]:3306 [::]:0 LISTENING
TCP [::]:49678 [::]:0 LISTENING
UDP 0.0.0.0:53 *:*
UDP 0.0.0.0:123 *:*
UDP 0.0.0.0:5050 *:*
UDP 0.0.0.0:5353 *:*
UDP 0.0.0.0:52273 142.250.192.36:443
UDP 0.0.0.0:60051 142.250.70.110:443
UDP 127.0.0.1:1900 *:*
UDP 127.0.0.1:57589 127.0.0.1:57589
UDP 127.0.0.1:58410 *:*
UDP 172.21.240.1:137 *:*
UDP 172.21.240.1:138 *:*
UDP 172.21.240.1:1900 *:*
UDP [::]:123 *:*
UDP [::]:5353 *:*
UDP [fe80::b34a:e375:3e21:99b7%19]:1900 *:*
UDP [fe80::b34a:e375:3e21:99b7%19]:2177 *:*
4. curl
Purpose: Make HTTP requests and interact with web servers (GET, POST, etc.).
Usage:
curl [options] [URL]
Common Options:
-I
: Fetch HTTP headers only.-O
: Save the output to a file.-d
: Send POST data.-X
: Specify HTTP method (GET, POST, PUT, DELETE).
Example :
PS C:\Users\Atul> curl https://example.com
StatusCode : 200
StatusDescription : OK
Content : <!doctype html>
<html>
<head>
<title>Example Domain</title>
<meta charset="utf-8" />
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<meta name="viewport" conten...
RawContent : HTTP/1.1 200 OK
Alt-Svc: h3=":443"; ma=93600,h3-29=":443"; ma=93600,h3-Q050=":443"; ma=93600,quic=":443";
ma=93600; v="46,43"
Connection: keep-alive
Content-Length: 1256
Cache-Control: max-age=274...
Forms : {}
Headers : {[Alt-Svc, h3=":443"; ma=93600,h3-29=":443"; ma=93600,h3-Q050=":443"; ma=93600,quic=":443";
ma=93600; v="46,43"], [Connection, keep-alive], [Content-Length, 1256], [Cache-Control,
max-age=2745]...}
Images : {}
InputFields : {}
Links : {@{innerHTML=More information...; innerText=More information...; outerHTML=<A
href="https://www.iana.org/domains/example">More information...</A>; outerText=More
information...; tagName=A; href=https://www.iana.org/domains/example}}
ParsedHtml : mshtml.HTMLDocumentClass
RawContentLength : 1256
curl https://example.com # Perform a GET request
curl -I https://example.com # Fetch headers
curl -X POST -d "name=John" https://example.com/form
5. dig / nslookup
Purpose: Perform DNS lookups and get domain information.
dig
is more advanced and commonly used in Linux/Mac.nslookup
works on both Windows and Linux/Mac.
Usage:
dig [options] [hostname] # Linux/Mac
nslookup [hostname] # Windows/Linux/Mac
Common Options for dig
:
+short
: Display brief output.-t [record type]
: Specify DNS record type (A, MX, NS, TXT, etc.).
Examples:
dig google.com # Get DNS records
dig google.com +short # Brief IP address output
dig google.com -t MX # Get mail server records
nslookup google.com # Basic DNS lookup
PS C:\Users\Atul> nslookup google.com
Server: UnKnown
Address: 192.168.0.1
Non-authoritative answer:
Name: google.com
Addresses: 2404:6800:4009:82e::200e
142.250.199.174
Summary Table:
Command | Purpose | Platform |
ping | Check connectivity | All (Linux/Mac/Win) |
traceroute / tracert | Trace packet route | Linux/Mac / Windows |
netstat | View network connections & stats | All (Linux/Mac/Win) |
curl | Make HTTP requests | Linux/Mac/Win |
dig / nslookup | DNS lookup | dig (Linux/Mac), nslookup (All) |
Conclusion:
Networking commands like ping, traceroute/tracert, and netstat help check connectivity, trace routes, and monitor connections. curl tests web requests, while dig/nslookup resolves domain names. Mastering these tools is crucial for effective network troubleshooting and analysis.
Subscribe to my newsletter
Read articles from Atul Bobade directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
