Networking is crucial for DevOps & Cloud Engineers, as it ensures server communication, monitoring, security, and automation. This guide covers essential commands, networking types, tools, and alternatives.
Command | Description | Use Cases |
---|---|---|
ping | Checks network connectivity to a host. | Verify if a remote server is reachable. |
netstat | Displays active connections, ports, and network stats. | Identify listening services and open ports. |
ifconfig | Shows network interfaces and their IPs (deprecated). | Check network configurations (Use ip a instead). |
traceroute | Traces the path packets take to a host. | Identify network hops and diagnose slow connections. |
tracepath | Similar to traceroute but works without root access. | Check route paths without requiring admin privileges. |
mtr | Combines ping and traceroute for real-time diagnostics. | Monitor packet loss and latency in network paths. |
nslookup | Queries DNS records for a domain. | Check IP address resolution for a domain. |
telnet | Connects to a remote host on a specified port. | Test if a port is open on a server. |
hostname | Displays or sets the system hostname. | Identify the current machine in a network. |
hostnamectl | Configures and changes the system hostname. | Permanently update the system hostname. |
ip | Manages IP addresses and interfaces (modern replacement for ifconfig ). | View, add, or remove network configurations. |
iwconfig | Configures wireless network interfaces. | View or set Wi-Fi configurations (deprecated). |
ss | Displays socket connections (modern replacement for netstat ). | Check active network connections. |
arp | Displays the system’s ARP table. | Find MAC addresses associated with IPs in the local network. |
dig | Performs DNS lookups with detailed output. | Retrieve domain information and troubleshoot DNS issues. |
nc (Netcat) | Tests network connections, sends/receives data over TCP/UDP. | Check if a remote port is open or act as a simple server. |
whois | Retrieves domain registration details. | Find information about domain owners and expiry. |
route | Displays or modifies the routing table. | View network routes for outgoing traffic. |
nmap | Scans networks for open ports and services. | Perform security audits and detect running services. |
wget | Downloads files from the internet. | Fetch files from a URL over HTTP/HTTPS or FTP. |
curl | Transfers data from or to a server using various protocols. | Retrieve API data, send HTTP requests, or test endpoints. |
watch | Runs a command at regular intervals and displays output. | Continuously monitor network or system changes. |
iptables | Manages firewall rules for network security. | Block, allow, or log network traffic. |
tracepath | Identifies packet routes without needing root access. | Diagnose network connectivity issues. |
scp | Securely copies files between systems over SSH. | Transfer files between local and remote systems. |
rsync | Synchronizes files between systems efficiently. | Copy files incrementally while preserving permissions. |
jq | Parses and manipulates JSON data from command-line output. | Process API responses in DevOps automation. |
Why is Networking Important for DevOps?
DevOps is not just about deployment and pipelines—it involves:
✅ Server Communication: Ensuring microservices and cloud instances can connect.
✅ Security & Monitoring: Preventing unauthorized access and tracking network traffic.
✅ Automated Infrastructure: Cloud networking for AWS, GCP, and Kubernetes.
✅ CI/CD Deployment: Automating software releases across distributed environments.
📌 Alternatives?
- Managed Services: AWS CloudFormation, Terraform, Ansible (for infrastructure automation).
- Cloud Networking Tools: AWS VPC, Azure Virtual Network, Google Cloud Networking.
- Service Meshes: Istio, Linkerd (for microservices networking).
ping
– Check Connectivity
✅ Usage: Tests if a host/server is reachable.
✅ How It Works:
- Sends ICMP Echo Requests to a target.
Example:
ping google.com
📌 Best Practice: Use ping -c 4 google.com
to send only 4 packets.
netstat
– Network Statistics
✅ Usage: Displays active connections, routing tables, and network stats.
✅ How It Works:
- Shows listening ports, established connections, and traffic stats.
Example:
netstat -tulnp
📌 Best Practice: Use ss -tulnp
instead (modern alternative).
ifconfig
– Network Interface Configuration
✅ Usage: Shows and configures network interfaces (deprecated, replaced by ip
).
Example:
ifconfig
📌 Alternative: Use ip a
for modern networking.
traceroute
vs tracepath
– Route Tracking
✅ Usage: Displays the hops between your system and a destination.
✅ How It Works:
traceroute
uses ICMP packets.tracepath
uses UDP (no root needed).
Example:
traceroute google.com
tracepath google.com
📌 Best Practice: Use mtr
for real-time tracing.
mtr
– Advanced Network Diagnostic
✅ Usage: Combines ping
+ traceroute
.
✅ How It Works:
- Continuously pings each hop.
Example:
mtr google.com
📌 Best Practice: Use mtr --report
for logs.
nslookup
– DNS Lookup
✅ Usage: Queries DNS records.
Example:
nslookup google.com
📌 Alternative: Use dig
.
telnet
– Test Open Ports
✅ Usage: Connects to a TCP port to check availability.
Example:
telnet google.com 80
📌 Best Practice: Use nc -zv <host> <port>
instead.
hostname
– View System Name
✅ Usage: Displays current hostname.
Example:
hostname
📌 Change Hostname:
sudo hostnamectl set-hostname new-hostname
ip
– Modern Network Configuration
✅ Usage: Replaces ifconfig
for managing IPs & interfaces.
Example:
ip a
📌 Best Practice: Use ip route
instead of route
.
iwconfig
– Wireless Network Configuration
✅ Usage: Manages Wi-Fi interfaces (deprecated).
Example:
iwconfig
📌 Alternative: Use nmcli
.
ss
– Socket Statistics (Better than netstat
)
✅ Usage: Shows active TCP & UDP connections.
Example:
ss -tulnp
📌 Best Practice: Replace netstat
with ss
.
arp
– View MAC Addresses
✅ Usage: Displays ARP cache (mapping of IPs to MAC addresses).
Example:
arp -a
📌 Best Practice: Use ip neigh
.
dig
– Advanced DNS Lookup
✅ Usage: Retrieves DNS records like A
, CNAME
, MX
.
Example:
dig google.com
📌 Best Practice: Use dig +short
for cleaner output.
nc
(Netcat) – Network Debugging
✅ Usage: Opens TCP/UDP connections to test services.
Example:
nc -zv google.com 80
📌 Best Practice: Use nc
for port scanning.
whois
– Domain Information
✅ Usage: Retrieves domain registration details.
Example:
whois google.com
📌 Best Practice: Use whois
for domain investigations.
route
– Show Routing Table
✅ Usage: Displays how network packets are routed.
Example:
route -n
📌 Alternative: Use ip route
.
nmap
– Network Scanner
✅ Usage: Scans open ports and network services.
Example:
nmap -p 80,443 google.com
📌 Best Practice: Use nmap
for security audits.
wget
– Download Files
✅ Usage: Fetches files from the web.
Example:
wget https://example.com/file.tar.gz
curl
– Send HTTP Requests
✅ Usage: Retrieves HTTP responses, APIs, and data.
Example:
curl -I https://google.com
iptables
– Firewall Rules
✅ Usage: Controls network traffic filtering.
Example:
sudo iptables -L
📌 Best Practice: Use ufw
for easier firewall management.
curl
vs wget
Feature | curl | wget |
---|---|---|
Use Case | API Calls, Web Scraping | File Downloads |
Supports FTP | ✅ Yes | ✅ Yes |
Recursive Download | ❌ No | ✅ Yes |
JSON Parsing | ✅ Yes (jq ) | ❌ No |
📌 Best Practice: Use curl
for APIs, wget
for downloading files.
Why Use jq
in DevOps?
✅ jq
is a command-line JSON processor used to parse API responses.
Example:
curl -s https://api.github.com/users/octocat | jq '.login'
📌 Best Practice: Use jq
in CI/CD scripts to process JSON API data.
Comparison of ICMP, UDP, TCP, and Other Protocols
Protocol | Type | Connection-Oriented? | Reliability | Use Cases |
---|---|---|---|---|
ICMP (Internet Control Message Protocol) | Network Layer | ❌ No | ❌ Not Reliable | Used for network diagnostics (ping , traceroute ). |
UDP (User Datagram Protocol) | Transport Layer | ❌ No | ❌ Not Reliable | Used for real-time applications (VoIP, video streaming, DNS). |
TCP (Transmission Control Protocol) | Transport Layer | ✅ Yes | ✅ Reliable | Used for web traffic (HTTP/HTTPS ), SSH, file transfers. |
HTTP (HyperText Transfer Protocol) | Application Layer | ✅ Yes (via TCP) | ✅ Reliable | Used for website communication (APIs, browsers). |
HTTPS (Secure HTTP) | Application Layer | ✅ Yes (via TCP) | ✅ Reliable, Encrypted | Secure web communication (TLS/SSL encryption). |
FTP (File Transfer Protocol) | Application Layer | ✅ Yes (via TCP) | ✅ Reliable | Transfers files between client and server. |
SFTP (Secure File Transfer Protocol) | Application Layer | ✅ Yes (via SSH) | ✅ Reliable, Encrypted | Secure file transfer over SSH. |
SSH (Secure Shell Protocol) | Application Layer | ✅ Yes (via TCP) | ✅ Reliable, Encrypted | Remote system login and command execution. |
DNS (Domain Name System) | Application Layer | ❌ No (uses UDP) | ❌ Not Reliable | Resolves domain names to IP addresses. |
DHCP (Dynamic Host Configuration Protocol) | Application Layer | ❌ No (uses UDP) | ❌ Not Reliable | Assigns IP addresses dynamically to devices. |
SMTP (Simple Mail Transfer Protocol) | Application Layer | ✅ Yes (via TCP) | ✅ Reliable | Sends emails between servers. |
POP3/IMAP (Email Retrieval Protocols) | Application Layer | ✅ Yes (via TCP) | ✅ Reliable | Retrieves emails from mail servers. |
Telnet | Application Layer | ✅ Yes (via TCP) | ✅ Reliable (Unencrypted) | Remote system access (Deprecated, replaced by SSH). |
ICMPv6 | Network Layer | ❌ No | ❌ Not Reliable | Used for IPv6 network diagnostics, error reporting. |
When to Use IP vs TCP vs UDP?
Use Case | Protocol |
---|---|
Routing & Addressing | IP |
Reliable Web Communication | TCP |
Streaming & Gaming | UDP |
Sending Large Files | TCP |
Fast Name Resolution (DNS) | UDP |
Real-time Video/VoIP Calls | UDP |