⚡ ~/naveed Interview Prep
⚡ Portfolio Home ✍️ Engineering Blog Deep Dives 🎯 Interview Hub 998+ Scenarios ☸️ Kubernetes Mastery Hub 24 Modules 🎮 DevOps Arcade & Quizzes Subnet Blitz ⚡ 🗺️ DevOps Roadmaps PDFs & Guides 🤖 Morpheus Analysis AI Quant ↗ 🛠️ Developer Tools Utilities 🧪 Labs & Experiments 📄 Interactive CV & Certs 🔗 All Links & Socials ⚡ Join The Dispatch (Weekly SRE Newsletter) →
Junior / Associate DevOps [L1] Linux Linux / SRE — Scenario-Based Interview Questions Core Fundamentals [L1]

Q: A developer adds an entry to `/etc/hosts` to override DNS for testing, but it doesn't seem to work. DNS still resolves the original IP. What could be wrong?

The /etc/hosts file provides static hostname-to-IP mappings. Whether it takes precedence over DNS is controlled by /etc/nsswitch.conf.

#Linux #Linux / SRE — Scenario-Based Interview Questions #L1 #SRE #Systems #Troubleshooting
🎙️ Candidate Opening & Architectural Context
""Never reboot a server blindly; always capture top process telemetry, lsof descriptors, and thread dumps first. The interviewer is testing: Name resolution order, nsswitch.conf.. I structure my answer around systematic triage first, root cause analysis second, and permanent remediation third.""
Advertisement

🛠️ Production Runbook & Step-by-Step Resolution

1️⃣

Initial Diagnostics & Root Cause Analysis

The /etc/hosts file provides static hostname-to-IP mappings. Whether it takes precedence over DNS is controlled by /etc/nsswitch.conf.

  • Typo or formatting error: Each line must be IP_ADDRESS hostname [alias], separated by spaces or tabs. Extra characters or wrong formatting silently breaks the entry.
  • Application-level DNS caching: Some applications (Java, browsers) cache DNS lookups internally and ignore /etc/hosts changes until restarted.
  • systemd-resolved: Modern distributions may route DNS through systemd-resolved, which may have its own caching. Flush with resolvectl flush-caches.
2️⃣

Remediation & Permanent Safeguards

Check the hosts: line in /etc/nsswitch.conf: This means the system checks /etc/hosts first (files), then DNS. If the order is reversed (hosts: dns files), DNS takes priority and /etc/hosts is only consulted if DNS fails. Other common issues:

hosts: files dns
💡 The Senior SRE Gold Nugget (Key Architectural Takeaway)
"Pro-Tip: Typo or formatting error: Each line must be IP_ADDRESS hostname [alias], separated by spaces or tabs. Extra characters or wrong fo."
⚡ 60-Second Elevator Pitch Talking Points
  • Typo or formatting error: Each line must be IP_ADDRESS hostname [alias], separated by spaces or t...
  • Application-level DNS caching: Some applications (Java, browsers) cache DNS lookups internally an...
  • systemd-resolved: Modern distributions may route DNS through systemd-resolved, which may have its...
Advertisement
Want more Linux scenarios?
Explore our complete collection of scenario-based Linux interview runbooks.
Browse All Linux Questions →

📚 Related Production Scenarios in Linux