Day 7: Complete Guide to Linux Networking Commands for DevOps & Cloud Engineers

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.

CommandDescriptionUse Cases
pingChecks network connectivity to a host.Verify if a remote server is reachable.
netstatDisplays active connections, ports, and network stats.Identify listening services and open ports.
ifconfigShows network interfaces and their IPs (deprecated).Check network configurations (Use ip a instead).
tracerouteTraces the path packets take to a host.Identify network hops and diagnose slow connections.
tracepathSimilar to traceroute but works without root access.Check route paths without requiring admin privileges.
mtrCombines ping and traceroute for real-time diagnostics.Monitor packet loss and latency in network paths.
nslookupQueries DNS records for a domain.Check IP address resolution for a domain.
telnetConnects to a remote host on a specified port.Test if a port is open on a server.
hostnameDisplays or sets the system hostname.Identify the current machine in a network.
hostnamectlConfigures and changes the system hostname.Permanently update the system hostname.
ipManages IP addresses and interfaces (modern replacement for ifconfig).View, add, or remove network configurations.
iwconfigConfigures wireless network interfaces.View or set Wi-Fi configurations (deprecated).
ssDisplays socket connections (modern replacement for netstat).Check active network connections.
arpDisplays the system’s ARP table.Find MAC addresses associated with IPs in the local network.
digPerforms 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.
whoisRetrieves domain registration details.Find information about domain owners and expiry.
routeDisplays or modifies the routing table.View network routes for outgoing traffic.
nmapScans networks for open ports and services.Perform security audits and detect running services.
wgetDownloads files from the internet.Fetch files from a URL over HTTP/HTTPS or FTP.
curlTransfers data from or to a server using various protocols.Retrieve API data, send HTTP requests, or test endpoints.
watchRuns a command at regular intervals and displays output.Continuously monitor network or system changes.
iptablesManages firewall rules for network security.Block, allow, or log network traffic.
tracepathIdentifies packet routes without needing root access.Diagnose network connectivity issues.
scpSecurely copies files between systems over SSH.Transfer files between local and remote systems.
rsyncSynchronizes files between systems efficiently.Copy files incrementally while preserving permissions.
jqParses 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

Featurecurlwget
Use CaseAPI Calls, Web ScrapingFile 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

ProtocolTypeConnection-Oriented?ReliabilityUse Cases
ICMP (Internet Control Message Protocol)Network Layer❌ No❌ Not ReliableUsed for network diagnostics (ping, traceroute).
UDP (User Datagram Protocol)Transport Layer❌ No❌ Not ReliableUsed for real-time applications (VoIP, video streaming, DNS).
TCP (Transmission Control Protocol)Transport Layer✅ Yes✅ ReliableUsed for web traffic (HTTP/HTTPS), SSH, file transfers.
HTTP (HyperText Transfer Protocol)Application Layer✅ Yes (via TCP)✅ ReliableUsed for website communication (APIs, browsers).
HTTPS (Secure HTTP)Application Layer✅ Yes (via TCP)✅ Reliable, EncryptedSecure web communication (TLS/SSL encryption).
FTP (File Transfer Protocol)Application Layer✅ Yes (via TCP)✅ ReliableTransfers files between client and server.
SFTP (Secure File Transfer Protocol)Application Layer✅ Yes (via SSH)✅ Reliable, EncryptedSecure file transfer over SSH.
SSH (Secure Shell Protocol)Application Layer✅ Yes (via TCP)✅ Reliable, EncryptedRemote system login and command execution.
DNS (Domain Name System)Application Layer❌ No (uses UDP)❌ Not ReliableResolves domain names to IP addresses.
DHCP (Dynamic Host Configuration Protocol)Application Layer❌ No (uses UDP)❌ Not ReliableAssigns IP addresses dynamically to devices.
SMTP (Simple Mail Transfer Protocol)Application Layer✅ Yes (via TCP)✅ ReliableSends emails between servers.
POP3/IMAP (Email Retrieval Protocols)Application Layer✅ Yes (via TCP)✅ ReliableRetrieves emails from mail servers.
TelnetApplication Layer✅ Yes (via TCP)✅ Reliable (Unencrypted)Remote system access (Deprecated, replaced by SSH).
ICMPv6Network Layer❌ No❌ Not ReliableUsed for IPv6 network diagnostics, error reporting.

When to Use IP vs TCP vs UDP?

Use CaseProtocol
Routing & AddressingIP
Reliable Web CommunicationTCP
Streaming & GamingUDP
Sending Large FilesTCP
Fast Name Resolution (DNS)UDP
Real-time Video/VoIP CallsUDP
Scroll to Top