Show Menu
Cheatography

Linux Network Commands Cheat Sheet by

Network commands for network troubleshooting

Interfaces & IP Addresses

Command
Purpose
ip addr
Show IP addres­ses­/in­ter­faces
ip addr show eth0
Show specific interface
ip link
Show interf­ace­s/link state
ip link set eth0 up
Enable interface
ip link set eth0 down
Disable interface
ip -s link
Interface statistics
nmcli device status
Networ­kMa­nager device status
nmcli connection show
Show connec­tions
hostname
Show hostname
hostna­mectl
Hostna­me/­system inform­ation

Legacy commands

Command
Purpose
ifconfig
Interface config­uration
ifup
Bring interface up
ifdown
Bring interface down
 

Routing

Command
Purpose
ip route
Display routing table
ip route get IP
Show route used to reach IP
ip route add ...
Add route
ip route del ...
Delete route
route -n
Legacy routing table

Connec­tivity

Command
Purpose
ping HOST
Test connec­tivity
ping -c 4 HOST
Send 4 pings
tracepath HOST
Trace network path
tracepath HOST
Trace route to host
mtr HOST
Continuous route/­latency test

ARP / Neighbor Table

Modern:
ip neigh


Legacy:
arp -a
 

DNS & Name Resolution

Command
Purpose
dig DOMAIN
DNS lookup
dig DOMAIN A
Query A record
dig DOMAIN MX
Query mail records
dig -x IP
Reverse DNS lookup
nslookup DOMAIN
Basic DNS lookup
host DOMAIN
Simple DNS lookup
getend hosts HOST
Test system name resolution
resolvectl status
DNS resolver status
Important files:
/etc/hosts
/etc/r­eso­lve.conf
/etc/n­ssw­itc­h.conf

Network Config­uration

Networ­kMa­nager
nmcli

nmtui

system­d-n­etworkd
networkctl
 

Ports, Connec­tions & Troubl­esh­ooting

Command
Purpose
ss
Display sockets
ss -t
TCP sockets
ss -u
UDP sockets
ss -l
Listening sockets
ss -tulpn
Listening TCP/UDP + processes
ss -tan
TCP connec­tions numeri­cally
t = TCP
u = UDP
l = Listening
p = Process
n = Numeric

Network Testing Tools

Command
Purpose
curl URL
Test HTTP/HTTPS
wget URL
Downlo­ad/test web resource
nc HOST PORT
Test TCP/UDP port
tcpdump
Capture network packets
nmap HOST
Scan hosts/­ports

Network Statistics

Command
Purpose
ip -s link
RX/TX statistics
ss -s
Socket summary
ethtool
NIC/link inform­ation
   
 

Comments

No comments yet. Add yours below!

Add a Comment

Your Comment

Please enter your name.

    Please enter your email address

      Please enter your Comment.

          Related Cheat Sheets

          Linux Command Line Cheat Sheet

          More Cheat Sheets by hlhlhl

          Linux File and Directory Commands Cheat Sheet
          Managing Processes and Jobs in Linux Cheat Sheet
           
          Advertisement