Skip to content

Network Tools

Essential networking utilities for troubleshooting and diagnostics.

Ping

COMMANDDESCRIPTION
ping hostPing host
ping -c 4 hostPing 4 times
ping -i 0.2 hostPing every 0.2 seconds
ping -s 1500 hostSet packet size to 1500 bytes
ping -f hostFlood ping (root only)

Traceroute

COMMANDDESCRIPTION
traceroute hostTrace route to host
traceroute -n hostNo DNS lookup
traceroute -p 80 hostUse specific port
traceroute -w 1 hostWait 1 second for response

DNS Tools

nslookup

COMMANDDESCRIPTION
nslookup hostDNS lookup
nslookup -type=A hostA record lookup
nslookup -type=MX hostMX record lookup
nslookup -type=NS hostNS record lookup
nslookup host 8.8.8.8Use specific DNS server

dig

COMMANDDESCRIPTION
dig hostDNS lookup (detailed)
dig +short hostShort output
dig @8.8.8.8 hostUse specific DNS server
dig MX hostMX record lookup
dig NS hostNS record lookup
dig TXT hostTXT record lookup
dig +trace hostTrace DNS lookup

host

COMMANDDESCRIPTION
host hostDNS lookup
host -t A hostA record lookup
host -t MX hostMX record lookup
host -t NS hostNS record lookup

Curl

Basic Usage

COMMANDDESCRIPTION
curl URLGET request
curl -I URLHEAD request (headers only)
curl -X POST URLPOST request
curl -d "data" URLPOST data
curl -o file URLSave to file
curl -O URLSave with remote filename
curl -u user:pass URLBasic authentication
curl -H "Header: Value" URLAdd header
curl -v URLVerbose output
curl -L URLFollow redirects
curl -k URLSkip SSL verification

Common Examples

bash
# POST JSON data
curl -X POST -H "Content-Type: application/json" \
  -d '{"key":"value"}' URL

# Upload file
curl -F "file=@localfile.txt" URL

# Download with resume
curl -C - -O URL

# Use proxy
curl -x http://proxy:port URL

# Follow redirects
curl -L -O http://example.com/file

# Check HTTP status code
curl -o /dev/null -s -w "%{http_code}" URL

Wget

COMMANDDESCRIPTION
wget URLDownload file
wget -c URLContinue interrupted download
wget -O filename URLSave to specific filename
wget -r URLRecursive download
wget -b URLBackground download
wget -c -r URLRecursive with resume

Netcat

COMMANDDESCRIPTION
nc -l 8080Listen on port 8080
nc -l -p 8080Listen on port 8080
nc -zv host 80Check if port is open
nc -zv host 1-100Scan ports 1-100
nc host portConnect to host:port
`echo "message"nc host port`
nc -l -p 8080 < fileSend file

Netstat

COMMANDDESCRIPTION
netstat -tulnList listening TCP/UDP ports
netstat -tulpnList listening ports with process
netstat -anList all connections
netstat -rShow routing table
netstat -iShow network interfaces

ss (Socket Statistics)

COMMANDDESCRIPTION
ss -tulnList listening TCP/UDP ports
ss -tulpnList listening with process
ss -sShow statistics
ss -4IPv4 sockets
ss -6IPv6 sockets

ip

COMMANDDESCRIPTION
ip addrShow IP addresses
ip linkShow network interfaces
ip routeShow routing table
ip link set dev eth0 upBring interface up
ip link set dev eth0 downBring interface down
ip addr add 192.168.1.2/24 dev eth0Add IP address
ip addr del 192.168.1.2/24 dev eth0Remove IP address
ip route add default via 192.168.1.1Add default route

Tcpdump

COMMANDDESCRIPTION
tcpdump -i eth0Capture on interface
tcpdump -i eth0 -nNo DNS resolution
tcpdump -i eth0 port 80Capture HTTP traffic
tcpdump -i eth0 host 192.168.1.1Capture from specific host
tcpdump -i eth0 -w capture.pcapWrite to file
tcpdump -r capture.pcapRead from file
tcpdump -i eth0 -vVerbose output
tcpdump -i eth0 -c 100Capture 100 packets

Filters

bash
# Capture HTTP
tcpdump -i eth0 port 80

# Capture HTTPS
tcpdump -i eth0 port 443

# Capture from IP
tcpdump -i eth0 src 192.168.1.1

# Capture to IP
tcpdump -i eth0 dst 192.168.1.2

# Capture TCP
tcpdump -i eth0 tcp

# Capture UDP
tcpdump -i eth0 udp

# Capture ICMP
tcpdump -i eth0 icmp

# Capture with host and port
tcpdump -i eth0 host 192.168.1.1 and port 80

# Capture with OR
tcpdump -i eth0 "port 80 or port 443"

# Capture with NOT
tcpdump -i eth0 not port 22

Wireshark

Useful Display Filters

text
# HTTP
http

# HTTPS
tls

# TCP
tcp

# UDP
udp

# Filter by IP
ip.addr == 192.168.1.1

# Filter by port
tcp.port == 80

# Filter by host and port
ip.addr == 192.168.1.1 and tcp.port == 80

# Filter by protocol
tcp or udp

# Filter by network
ip.src == 192.168.1.0/24

Nmap

COMMANDDESCRIPTION
nmap hostScan host
nmap -p 80,443 hostScan specific ports
nmap -p 1-1000 hostScan port range
nmap -A hostAggressive scan
nmap -sV hostService version detection
nmap -O hostOS detection
nmap -T4 hostFaster scan
nmap -sS hostSYN scan (default)
nmap -sU hostUDP scan

Examples

bash
# Quick scan (common ports)
nmap -F host

# Comprehensive scan
nmap -A -T4 host

# Scan network
nmap 192.168.1.0/24

# Scan with specific ports
nmap -p 22,80,443,3306 host

# Scan multiple hosts
nmap host1 host2 host3

Telnet

COMMANDDESCRIPTION
telnet host portConnect to port
telnet host 25Connect to SMTP
telnet host 80Connect to HTTP

SSH

COMMANDDESCRIPTION
ssh user@hostConnect to host
ssh -p port user@hostConnect on specific port
ssh -i key user@hostUse specific key
ssh -L 8080:localhost:80 user@hostLocal port forwarding
ssh -R 8080:localhost:80 user@hostRemote port forwarding
ssh-keygen -t ed25519Generate SSH key
ssh-copy-id user@hostCopy key to host

ARP

COMMANDDESCRIPTION
arp -aShow ARP table
arp -nShow without DNS resolution
arp -d hostDelete ARP entry
arp -s host MACAdd ARP entry

Route

COMMANDDESCRIPTION
route -nShow routing table
route add default gw 192.168.1.1Add default route
route del defaultDelete default route
route add -host 192.168.1.2 gw 192.168.1.1Add host route

Useful Commands

Check if port is open

bash
nc -zv host port

Find process using port

bash
lsof -i :port

Get public IP

bash
curl ifconfig.me
curl ipinfo.io/ip

Check internet connectivity

bash
ping -c 4 8.8.8.8

Check DNS resolution

bash
nslookup host
dig +short host

Speed test

bash
curl -o /dev/null http://speedtest.tele2.net/100mb.img

Download and test speed

bash
curl -o /dev/null -w "Speed: %{speed_download} bytes/sec" URL

Best Practices

  • Use curl for HTTP operations
  • Use dig for detailed DNS queries
  • Use nc for port checking
  • Use tcpdump for packet capture
  • Use nmap for port scanning
  • Use ssh-keygen for SSH keys
  • Use ip instead of ifconfig (modern)
  • Use ss instead of netstat (modern)
  • Use tcpdump for troubleshooting
  • Monitor network traffic
  • Use proper firewalls

TIP

Use mtr (My Traceroute) for real-time network monitoring: mtr host.

Released under MIT License.