Linux for DevOps Day 04: Networking Commands

Table of contents
- What does a DevOps Engineer actually do daily?
- What is ping?
- netstat โ See Whatโs Happening in Your Network
- What is netstat?
- Why DevOps Engineers Use netstat
- Real-World Example: Using EC2
- Whatโs a Socket?
- ๐ When to Use netstat?
- ifconfig โ Know Your Network Interfaces
- traceroute vs tracepath: Follow the Journey of Your Network Request
- mtr โ My Traceroute (Ping + Traceroute Combined)
- nslookup โ Find the IP Behind a Domain
- telnet โ Test Port Connectivity to a Server
- ip address show โ Modern Alternative to ifconfig
- iwconfig โ Wireless Network Info
- ss โ A Modern Replacement for netstat
- dig โ Deep DNS Lookup
- whois โ Domain Ownership & Registry Info
- nc (Netcat) โ The Network Swiss Army Knife
- arp โ View ARP Table (Address Resolution Protocol)
- ifplugstatus โ Is Your Ethernet Plugged In?
- curl โ Talk to APIs Like a DevOps Pro
- What is curl?
- What is wget?
- iptables โ Control Your Network Traffic
- watch โ Repeatedly Run a Command (Live Monitoring)
- nmap โ Scan Networks Like a Pro
- route โ View or Edit Routing Table
- โ Final Recap Table

What does a DevOps Engineer actually do daily?
One of the most common tasks a DevOps engineer does is deploy applications on various servers or cloud systems.
But what happens when an app doesn't run or respond after deployment?
Thatโs where basic network troubleshooting begins. And the first command in your toolbox isโฆ
ping
โ Check If Something is Alive on the Network
Imagine this:
- You deploy your app, but it's not opening in the browser. First question in your mind is:
โIs the server even reachable?โ
To answer this, we use the ping command.
What is ping?
ping checks whether a particular system (like a server or website) is reachable over the network.
It works like this:
It sends small packets of data to the destination (IP address or domain).
If the destination receives it, it sends back a reply.
You get a result showing whether the system is reachable and how long it took for the round-trip.
So, if the ping is successful, it means:
โ Your internet is working
โ The target server is online
โ Basic network communication is happening
If not, you know thereโs a problem โ either with your system, the server, or the internet connection.
๐งช Real Example You want to check if your portfolio website is up and responding.
Just run:
ping portfolio.in
If everythingโs good, youโll see something like:
64 bytes from ...: icmp_seq=1 ttl=57 time=20.4 ms
That confirms:
โ๏ธ The domain is reachable
โ๏ธ The server is alive
โ๏ธ Thereโs no network block
๐ ๏ธ When Should DevOps Use ping?
App is not loading or giving connection errors
To confirm server is up before SSH login
To check internet connectivity
To test if a DNS name resolves correctly
First step in debugging downtime issues
netstat
โ See Whatโs Happening in Your Network
First Things First: Install the Toolkit
The netstat command doesnโt come pre-installed in newer Linux distributions. It belongs to an older but very useful package called net-tools.
Install it first:
sudo apt install net-tools
Once installed, you're ready to use:
netstat
What is netstat?
netstat stands for Network Statistics.
It gives you a snapshot of all network connections your system is handling โ like who your machine is talking to, which ports are open, and which protocols are being used.
Why DevOps Engineers Use netstat
As a DevOps engineer, this command is super helpful when:
You want to debug connection issues on your server
You need to see if a specific port is open or in use
Youโre checking for suspicious or unexpected network activity
Youโre managing multiple services on a single machine (like on AWS EC2).
Column | Meaning |
Proto | Protocol (TCP/UDP) used for communication |
Recv-Q | Data received but not yet processed |
Send-Q | Data waiting to be sent |
Local Address | Your systemโs IP and port |
Foreign Address | The remote system itโs connected to |
State | Connection state (e.g., LISTEN, ESTABLISHED, TIME_WAIT) |
Real-World Example: Using EC2
If youโre running an EC2 instance with multiple services (like web server, database, monitoring tools), you can use:
netstat -tuln
- This shows all TCP (-t) and UDP (-u) ports in a numeric (-n) format that are listening (-l).
Example output:
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN
This tells you:
Port 22 (SSH) is open
Port 80 (HTTP) is open
These are waiting for incoming connections
Whatโs a Socket?
Think of a socket as a doorway between your app and the network.
Whenever two systems want to talk (like your browser talking to a web server), they connect using sockets.
Each socket includes:
An IP address
A port number
A communication protocol (TCP/UDP)
If you're using an EC2 instance, every running service (like Apache, Nginx, MySQL) opens sockets to listen or communicate.
๐ When to Use netstat?
Check which ports are open on your system
Find out which services are using specific ports
Troubleshoot app not responding issues
Check if a server is establishing outbound/inbound connections
ifconfig
โ Know Your Network Interfaces
๐ง What is ifconfig?
ifconfig stands for interface configuration.
Itโs used to view or configure network interfaces on a Linux system โ kind of like looking under the hood to see how your system connects to the outside world.
to use it:
sudo apt install net-tools # Only needed if not already installed
ifconfig
๐ Output You'll See
When you run ifconfig, youโll see output like this (simplified):
docker0: ...
eth0: ...
lo: ...
Letโs break these down:
๐ eth0 โ Your Ethernet Interface
eth0 is the wired network interface (Ethernet).
If you're running a cloud server like EC2, it also uses a virtual version of this to connect to the internet.
Under the hood, eth0 is connected to a NIC (Network Interface Card) โ the physical (or virtual) device that allows your machine to connect to a network.
So if you see:
eth0: inet 172.31.22.45
It means your server has an IP address and is connected to a network using this interface.
๐ lo โ The Loopback Interface (Localhost)
lo stands for loopback โ a special internal network interface.
It lets your system talk to itself using the IP 127.0.0.1, also known as localhost.
Imagine you're testing a web app on your own laptop, like a React or Node.js project.
When you run:
npm start
You usually open the app in your browser at:
http://localhost:3000
This is powered by the loopback interface โ no external network or internet needed.
Even if the machine has no internet, lo
still works. It's used to test local services and servers.
docker0 โ The Docker Bridge Network
If youโve installed Docker, youโll see an extra interface like docker0.
This is a virtual network bridge Docker creates to let containers communicate with each other and with the host.
So if you're running multiple containers, docker0 helps them talk โ like a mini-internet just for your containers.
When to Use ifconfig as a DevOps Engineer?
To check your serverโs IP address
To verify if a network interface is up or down
To troubleshoot connectivity issues
To view Docker network interfaces
To check if your app is running on localhost
Quick Tip: Want a More Modern Tool?
Use:
ip a
This is the modern replacement for ifconfig and shows the same information in a slightly more detailed format.
traceroute
vs tracepath
: Follow the Journey of Your Network Request
๐ฅ How Do You Actually Watch a YouTube Video?
Letโs say you open YouTube in your browser. What happens behind the scenes?
Your device sends a request to your ISP (Internet Service Provider).
The ISP contacts a DNS server to translate youtube.com into an IP address.
The request starts traveling from one server to another โ hopping through various routers.
Eventually, it reaches YouTubeโs server, and the response (video data) travels back the same way.
This entire path โ from your system to YouTube โ is called the network route.
As a DevOps engineer, itโs important to understand this route, especially when diagnosing delays or connection failures. That's where tools like traceroute and tracepath come in.
What is traceroute?
traceroute shows you the exact path your request takes to reach a destination โ including every hop (server or router) it passes through.
Itโs like a Google Maps for network traffic.
Each hop tells you:
The IP of the router/server
How long it took to reach there (latency)
Where delays or failures might be happening
๐ง Install and Use traceroute:
sudo apt install traceroute
# sometimes it requires
sudo apt install inetutils-traceroute
Now trace a route to YouTube:
traceroute youtube.com
๐ You'll see something like:
1 192.168.1.1 1.2 ms
2 100.72.0.1 5.4 ms
3 172.217.194.138 25.6 ms
Each line = one hop. It tells you how many stops your request makes before reaching the destination.
โ Interview Tip
Q: If I give you a source and destination, how would you find all the IPs it goes through?
A: You can use the traceroute command to see each hop between the source and destination.
What is tracepath?
tracepath is similar to traceroute, but it:
Doesnโt require root access
Is often pre-installed in newer Linux systems
Uses slightly different logic (UDP vs ICMP)
Run it like this:
tracepath youtube.com
Youโll get the same kind of output: a list of hops, with delay times.
๐ Main difference: tracepath is simpler, doesn't need installation in many distros, and avoids using low-level packet manipulation.
DevOps Use Cases
As a DevOps Engineer, you might use traceroute or tracepath to:
Check where a network delay is happening
Find how many routers a request goes through
Debug slow API or application response time
Identify if a server is stuck behind a slow hop
Command | Use Case | Needs sudo? | Notes |
traceroute | Shows full route to destination | Yes | More detailed, needs install |
tracepath | Same, but no root needed | No | Often pre-installed, simpler |
mtr
โ My Traceroute (Ping + Traceroute Combined)
What is mtr?
mtr is a powerful network diagnostic tool that combines the features of both ping and traceroute. It gives you a live, real-time view of the path your packets take to a destination.
No need to run ping and traceroute separately โ mtr does both in one go.
๐ง Install & Use:
sudo apt install mtr
mtr youtube.com
It starts by pinging the destination, then gradually shows you each hop, along with:
Response times
Packet loss
Stability of the route
DevOps Tip:
Use mtr when:
You want a real-time report of network stability
You're debugging intermittent or flaky network issues
nslookup
โ Find the IP Behind a Domain
๐ What is nslookup?
nslookup (Name Server Lookup) is used to:
Check if a domain name is resolving correctly
View the public IP address associated with a domain
Test if your DNS is working
๐ ๏ธ Usage:
nslookup youtube.com
Youโll see:
The server that resolved your query
The IP address of the domain (public IP)
Sometimes additional DNS records (like MX, CNAME if specified)
โ Why DevOps Engineers Use It:
To verify domain resolution (especially after DNS updates)
To troubleshoot DNS-related issues
To confirm a service is pointing to the correct IP
telnet
โ Test Port Connectivity to a Server
What is telnet?
telnet is used to test connectivity to a specific port on a remote system.
Think of it as:
"Can I connect to this IP/domain on this port?"
This is super useful when debugging:
Web servers (port 80 or 443)
Database servers
APIs or microservices
๐ง Usage:
telnet youtube.com 80 # HTTP (public)
telnet youtube.com 443 # HTTPS (secure)
If the port is open and reachable, youโll connect. If not, itโll fail โ letting you know something is blocked (firewall, port closed, etc).
๐ DevOps Use Case:
Confirm if a service is up and listening on a certain port
Debug network/firewall rules in cloud environments
Validate microservices communication in private networks
hostname
โ Get or Set Your System's Name
What is hostname?
The hostname command shows the name of your system in the network. This is what other systems might see when they interact with yours.
Usage:
hostname # See your system name
sudo hostname Prashant # Temporarily change your hostname
Note: This change lasts until reboot. For permanent change, you modify system config files like /etc/hostname.
๐ง DevOps Use Case:
Identify machines in a multi-server setup
Temporarily rename instances during deployment or testing
Helps in system logs, SSH access, and monitoring
Recap Commands
Command | Purpose | Example Use |
mtr | Live ping + traceroute | mtr google.com |
nslookup | Check domain-to-IP resolution | nslookup example.com |
telnet | Test connectivity to a specific port | telnet server.com 443 |
hostname | View or change system name | sudo hostname DevOpsMachine |
ip address show
โ Modern Alternative to ifconfig
ip address show
or simply:
ip a
๐ This command displays:
All available network interfaces
Their IP addresses
Whether the interface is up or down
๐ง Why use it?
Itโs part of the modern iproute2 toolkit.
Replaces ifconfig, which is considered outdated.
Use this to check your serverโs IP address, network adapter status, or troubleshoot connectivity.
iwconfig
โ Wireless Network Info
sudo apt install wireless-tools
iwconfig
๐ก This command shows wireless network interfaces and their settings, such as:
Wi-Fi SSID
Signal strength
Bit rate
Frequency/channel
๐ง Useful when working on laptops, IoT devices, Raspberry Pi, or any Linux box with Wi-Fi.
ss
โ A Modern Replacement for netstat
ss -tuln
- โ ss stands for Socket Statistics.
Itโs faster and more accurate than netstat and shows:
Listening ports
Open connections
Protocols in use (TCP/UDP)
DevOps Use Case:
Use ss to debug which service is running on which port โ especially when netstat isnโt available.
dig
โ Deep DNS Lookup
dig youtube.com
๐งช dig stands for Domain Information Groper.
It gives detailed DNS info, including:
IP addresses (A records)
Name servers
TTL (Time to Live)
DNS query times
๐ง DevOps Use Case:
Troubleshoot DNS issues
Compare response from different DNS servers
Check propagation of DNS changes
whois
โ Domain Ownership & Registry Info
sudo apt install whois
whois youtube.com
๐ whois reveals who owns a domain, when it was registered, when it expires, and where it's hosted.
Use it for:
Domain-related investigations
Checking if a domain is about to expire
Security audits or asset discovery
nc
(Netcat) โ The Network Swiss Army Knife
nc -zv example.com 80
๐ ๏ธ nc can:
Test open ports
Create TCP/UDP connections
Transfer files
Even run a basic server!
๐ Example: Check if a port is open
nc -zv google.com 443
DevOps Use Case:
Test network connectivity between services
Simulate simple client-server behavior
File transfer over internal network
arp
โ View ARP Table (Address Resolution Protocol)
arp -a
๐ Shows the list of IP-to-MAC address mappings that your machine has cached.
Helpful when:
Debugging local network issues
Detecting devices connected to the same subnet
Investigating spoofing or IP conflicts
ifplugstatus
โ Is Your Ethernet Plugged In?
sudo apt install ifplugd
ifplugstatus
๐ This tells you whether your network cable (ethernet) is physically connected or not.
Useful for:
Troubleshooting "no internet" on desktops or servers
Quickly checking cable disconnection issues
Network health checks
curl
โ Talk to APIs Like a DevOps Pro
๐ฌ What is an API?
Imagine you're in a restaurant. You donโt walk into the kitchen to get your food โ you tell the waiter, and the waiter brings your food.
The waiter is like an API.
You โ API โ Server โ API โ You (response)
What is curl?
curl lets you talk to servers using APIs โ to get data, send data, or trigger actions.
curl -X GET [https://api.example.com/users](https://api.example.com/users)
๐งช Want clean, readable output?
Install and use jq (JSON prettifier):
sudo apt install jq
curl -X GET [https://api.example.com/users](https://api.example.com/users) | jq
๐ง DevOps Use Cases:
Test API endpoints
Fetch configuration/data from services
Automate deployment & monitoring tools
What is wget?
wget [https://example.com/file.zip](https://example.com/file.zip)
๐ฅ wget is used to download files from the internet via a direct link (HTTP/HTTPS/FTP).
๐ง DevOps Use Cases:
Download source code, scripts, or configs from URLs
Fetch release files during CI/CD pipeline runs
iptables
โ Control Your Network Traffic
iptables is a powerful tool to manage firewall rules in Linux. Itโs like a security gate that controls:
Which connections are allowed
Which ports/services are open
Which traffic to block
sudo iptables -h # Help
sudo iptables --list-rules # View current rules
What is a Routing Table?
A routing table is a set of rules that decides where your network traffic should go โ kind of like Google Maps for your packets.
๐ง DevOps Use Cases:
Restrict incoming traffic on specific ports
Allow only internal services to communicate
Secure server access in production
watch
โ Repeatedly Run a Command (Live Monitoring)
watch mtr youtube.com # Runs every 2 sec (default)
watch -n 5 mtr youtube.com # Every 5 seconds
๐บ watch runs a command again and again โ refreshing the output in real time.
๐ง DevOps Use Cases:
Monitor CPU/memory/disk/network usage
Watch logs or API responses
Debug real-time changes
nmap
โ Scan Networks Like a Pro
sudo apt install nmap
nmap example.com
๐ฐ๏ธ nmap (Network Mapper) scans remote systems to:
Discover open ports
Find running services
Detect operating systems
๐ Itโs like a network X-ray tool for security audits and diagnostics.
๐ง DevOps Use Cases:
Audit open ports on cloud servers
Check exposed services
Validate firewall and network rules
route
โ View or Edit Routing Table
route -n
๐ route shows or modifies your systemโs routing table, which tells your machine how to send traffic based on destination.
๐ง DevOps Use Cases:
Diagnose โno internetโ problems
Configure routing rules for VPN or internal network
โ ๏ธ route is older โ ip route is now preferred:
ip route show
โ Final Recap Table
Command | Purpose | Notes |
ip a | Show IP and interface status | Modern ifconfig |
iwconfig | Show Wi-Fi interfaces | Requires wireless-tools |
ss | Show open ports, connections | Faster than netstat |
dig | Deep DNS lookup | For checking DNS records |
whois | Domain ownership & registry info | Good for audits & investigations |
nc | Network utility for port check, transfer, TCP tests | Swiss army knife for networking |
arp | IP-MAC mapping table | Useful in local networks |
ifplugstatus | Check if ethernet cable is plugged in | Great for quick hardware checks |
Command | Purpose | Common Use |
curl | Talk to APIs, get or send data | API testing |
wget | Download files via URL | Automation |
iptables | Set firewall/network rules | Security |
watch | Repeat a command every X seconds | Monitoring |
nmap | Scan systems for open ports and services | Audit |
route | Show routing rules (replaced by ip route ) | Network |
Subscribe to my newsletter
Read articles from Prashant Gohel directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by

Prashant Gohel
Prashant Gohel
DevOps & Cloud Enthusiast | Exploring Linux, AWS, CI/CD & Automation | Sharing hands-on notes, tips, and real-world learning as I grow into a DevOps Engineer