LFCS Networking Practice Question
A system administrator needs to configure a static IP address on a CentOS 7 server. Which file should be edited to set the IP address permanently?
⚠ Common exam trap
The trap here is that candidates familiar with Ubuntu or Debian systems may incorrectly choose /etc/network/interfaces (Option B) or /etc/netplan/01-netcfg.yaml (Option A), forgetting that CentOS 7 uses the Red Hat-style ifcfg scripts in /etc/sysconfig/network-scripts/.
Answer choices
Why each option matters
Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.
Correct answer & explanation
✓
/etc/sysconfig/network-scripts/ifcfg-eth0
On CentOS 7, network interfaces are configured via scripts located in /etc/sysconfig/network-scripts/, with each interface having a file named ifcfg-<interface>. The ifcfg-eth0 file stores static IP settings such as IPADDR, NETMASK, and GATEWAY, which are read by the network service (network.service) to apply persistent configuration.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
/etc/netplan/01-netcfg.yaml
Why it's wrong here
Netplan YAML files belong to Ubuntu 18.04 and later, not CentOS 7, which reads ifcfg-* files in /etc/sysconfig/network-scripts/. It is tempting because Netplan is the modern declarative approach on Ubuntu, so it would be correct when setting a static address on a recent Ubuntu server.
- ✗
/etc/network/interfaces
Why it's wrong here
/etc/network/interfaces is Debian and Ubuntu's ifupdown configuration file; CentOS 7 uses NetworkManager and ifcfg files under /etc/sysconfig/network-scripts/. It is tempting because it is the standard location on Debian-derived systems, so it would be correct when configuring a static address on Ubuntu or Debian.
- ✗
/etc/hostname
Why it's wrong here
/etc/hostname sets only the transient system hostname, containing no IP addressing directives, so editing it leaves the interface unconfigured. It is tempting because hostname and network identity are often conflated, and this file would be the right target when changing the server's name rather than its static address.
- ✓
/etc/sysconfig/network-scripts/ifcfg-eth0
Why this is correct
On CentOS 7, NetworkManager and the legacy network service read per-interface configuration from /etc/sysconfig/network-scripts/ifcfg-eth0, so editing this file sets a persistent static address. Changes survive reboot, unlike runtime ip commands, satisfying the stem's requirement for permanent configuration.
Visual reference
Go deeper
Related to this question
About these practice questions
Courseiva writes every LFCS question from scratch — 406 in total, each with an explanation and a wrong-answer breakdown. None are copied from real exams or dumps. Learn why practice questions differ from exam dumps →
JA
Written by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
This LFCS practice question is part of Courseiva's free Linux Foundation certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the LFCS exam.