Linux networking commands interview questions
It’s important to have a firm understanding of both the older and more recent tools when preparing for a Linux networking interview. Your ability to handle interfaces, identify connectivity problems, and comprehend the underlying protocols are usually what interviewers look for.
Core Interface & Configuration
Q: What is the difference between ifconfig and ip?
- Answer:
ifconfig(part of thenet-toolspackage) is deprecated. Theipcommand (part ofiproute2) is the modern replacement.ipis faster, more powerful, and can manage more than just IP addresses it handles routing, ARP (neighbor) tables, and tunnels.- Example:
ip addr showvsifconfig.
- Example:
Q: How do you check the IP address of a specific interface?
- Answer: Use
ip addr show <interface_name>(e.g.,ip addr show eth0).
Q: How can you bring a network interface up or down?
- Answer:
- Modern:
ip link set eth0 up/ip link set eth0 down - Legacy:
ifup eth0/ifdown eth0
- Modern:
Connectivity & Troubleshooting
Q: A server can’t reach a website. What are the first three commands you’d run?
- Answer:
- 1.
ping <IP>: Checks basic ICMP reachability. - 2.
dig <domain>ornslookup: Checks if DNS is resolving the hostname to an IP. - 3.
traceroute <IP>: Identifies where the connection is dropping in the network path.
- 1.
Q: What is the difference between traceroute and mtr?
- Answer:
tracerouteshows a static path to the destination.mtr(My Traceroute) is a real-time tool that combinespingandtraceroute, showing live updates of packet loss and latency at each hop.
Also read about Networking in Linux: Types, Advantages, and Disadvantages
Q: How do you check if a specific port (e.g., 80) is open on a remote server?
- Answer:
telnet <IP> 80nc -zv <IP> 80(Netcat is the preferred modern tool for this).
Monitoring Sockets & Traffic
Q: How do you see all listening ports and the processes using them?
- Answer:
ss -tulpn-t: TCP ports-u: UDP ports-l: Listening sockets-p: Show the Process ID (PID)-n: Show numeric addresses instead of hostnames.- Note: This has largely replaced the older
netstat -plntu.
Q: How would you capture and analyze network packets in real-time?
- Answer:
tcpdump.- To capture traffic on a specific interface:
tcpdump -i eth0. - To save it for later analysis in Wireshark:
tcpdump -w capture.pcap.
- To capture traffic on a specific interface:
Routing & DNS
Q: How do you view the kernel routing table?
- Answer:
ip routeor the olderroute -n.
Q: Where is the DNS resolver configuration stored in Linux?
- Answer: In the
/etc/resolv.conffile. It typically contains the IP addresses of the nameservers the system queries.
Q: How do you check the ARP cache?
- Answer: Use
ip neigh(modern) orarp -a(legacy). This shows the mapping of IP addresses to MAC addresses on the local segment.
Legacy vs Modern
| Task | Legacy (net-tools) | Modern (iproute2/others) |
| Address Info | ifconfig | ip addr |
| Routing Table | route -n | ip route |
| Socket Stats | netstat | ss |
| ARP Table | arp | ip neigh |
| Link Status | mii-tool / ethtool | ip link / ethtool |
Linux network troubleshooting commands and interview questions
Since you’re looking to ace an interview, it’s important to know not just the commands, but the why behind using them. Modern Linux networking has shifted from the old net-tools package to iproute2, and interviewers love to see if you’re up-to-date.
Troubleshooting Scenarios
Scenario A: Can’t reach the internet/another host
- The Command:
ping <IP_or_Domain> - Interview Question: “What does a successful ping tell you about the OSI model?”
- The Answer: It confirms connectivity up to the Network Layer (Layer 3). However, a failed ping doesn’t always mean the server is down; ICMP traffic might just be blocked by a firewall.
Scenario B: DNS Resolution Issues
- The Commands:
digornslookup - Interview Question: “A user can ping 8.8.8.8 but cannot reach google.com. What is the problem and how do you verify it?”
- The Answer: This is a classic DNS issue. I would use
dig google.comto see if the system can resolve the domain name to an IP address. If it fails, I check/etc/resolv.conf.
Also read about How To Configure Network In Linux Command Line for Beginners
Scenario C: Identifying Path Latency
- The Commands:
tracerouteormtr - Interview Question: “How do you identify which hop in a network path is dropping packets?”
- The Answer: I use
mtr(My Traceroute). Unlike a standard traceroute,mtrprovides real-time statistics on packet loss and latency for every router in the path.
Port and Socket Management
Interviewers frequently ask about local services and ports to see if you understand how applications bind to the network.
- The Modern Command:
ss -tulpn- -t: TCP
- -u: UDP
- -l: Listening sockets
- -p: Process ID/Name
- -n: Numeric ports (don’t resolve 80 to “http”)
- Common Question: “How do you find which process is using Port 80?”
- The Answer:
ss -tulpn | grep :80orlsof -i :80.
Configuration & Routing
You must know the ip command suite inside and out. ifconfig is widely considered “legacy” now.
| Task | Modern Command | Why it matters |
| Check IP/Interface | ip addr | Shows IP, MAC, and interface state (UP/DOWN). |
| Check Routing | ip route | Shows the default gateway and how traffic leaves the box. |
| Check ARP Table | ip neigh | Shows the Layer 2 (MAC) mapping for local devices. |
| Interface Stats | ip -s link | Useful for spotting “RX/TX errors” or dropped packets. |
Advanced Packet Analysis
If the role is for a Senior Admin or SRE, expect questions on tcpdump.
- Interview Question: “How would you capture only HTTP traffic on interface eth0 and save it to a file?”
- The Answer:
tcpdump -i eth0 'port 80' -w capture.pcap - Follow-up: “How do you read that file later?”
- The Answer: Use
tcpdump -r capture.pcapor open it in Wireshark for a GUI analysis.
Critical Files to Know
Often, the “command” is just checking a text file. Be prepared to mention these:
- /etc/hosts: Local DNS overrides.
- /etc/resolv.conf: Nameserver (DNS) configuration.
- /etc/nsswitch.conf: Determines the order of lookups (e.g., check
hostsfile beforeDNS). - /etc/network/interfaces or /etc/netplan/: Permanent interface configurations (depending on the distro).
Also read about What Is Linux Distributions (Distros)? Types And Features
