Where to Configure Static IP on CentOS 7
An administrator wants to permanently configure a static IP address on a CentOS 7 system. Which file should be edited?
Quick Answer
The answer is the file /etc/sysconfig/network-scripts/ifcfg-eth0. This is correct because CentOS 7, like its RHEL lineage, stores permanent network interface configurations in individual scripts under the /etc/sysconfig/network-scripts/ directory, named ifcfg- followed by the interface name, such as eth0. Within this file, you set BOOTPROTO=static and define the IPADDR, NETMASK, and GATEWAY parameters to establish a static IP that persists across reboots, bypassing the dynamic assignment from DHCP. On the Linux Foundation Certified System Administrator LFCS exam, this question tests your knowledge of legacy network configuration methods, as CentOS 7 still relies on these scripts by default even though NetworkManager is present. A common trap is confusing this with the newer /etc/NetworkManager/system-connections/ directory used by NetworkManager’s keyfile format, but the exam expects the traditional ifcfg path for permanent static configuration. Memory tip: think of “ifcfg” as “interface config” and remember that the file name always matches the interface name you see in ip link.
⚠ Common exam trap
The trap here is that candidates familiar with Debian-based systems may choose /etc/network/interfaces (Option D), while those who confuse global network settings with per-interface settings may pick /etc/sysconfig/network (Option B), both of which are incorrect for CentOS 7's static IP configuration.
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 interface configuration is stored in individual files under /etc/sysconfig/network-scripts/, named ifcfg-<interface>. The ifcfg-eth0 file contains parameters like BOOTPROTO, IPADDR, NETMASK, and GATEWAY, and setting BOOTPROTO=static along with the IP address values permanently configures a static IP. This is the standard method for RHEL/CentOS 7 systems using the legacy network scripts (not NetworkManager's keyfile format).
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/sysconfig/network-scripts/ifcfg-eth0
Why this is correct
Editing /etc/sysconfig/network-scripts/ifcfg-eth0 satisfies the persistence constraint: CentOS 7's NetworkManager and legacy network service both read per-interface ifcfg files at boot, so BOOTPROTO=none, IPADDR, NETMASK and GATEWAY survive reboots. Runtime tools like ip or ifconfig change only the live kernel state and are lost on restart.
- ✗
/etc/sysconfig/network
Why it's wrong here
/etc/sysconfig/network holds hostname and global routing flags, not per-interface addressing, so editing it leaves the NIC on DHCP. It is tempting because it is the system-wide network configuration file, and it would be the right place to set a global gateway or hostname, but interface IPs belong in /etc/sysconfig/network-scripts/ifcfg-<interface>.
- ✗
/etc/hostname
Why it's wrong here
/etc/hostname stores only the system's hostname, so editing it changes nothing about IP addressing. It is tempting because hostname and network identity are often configured together, and on systemd hosts the static hostname is set here rather than in the network configuration.
- ✗
/etc/network/interfaces
Why it's wrong here
/etc/network/interfaces is the Debian and Ubuntu interface configuration file; CentOS 7 uses ifcfg files under /etc/sysconfig/network-scripts/. It is tempting because it is the correct location on Debian-family systems, so administrators moving between distributions often reach for it by habit.
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 →
Same concept, more angles
1 more way this is tested on LFCS
These questions test the same concept from different angles. Work through them to make sure you can recognise it however the exam phrases it.
Variation 1. Order the steps to configure a static IP address on a CentOS/RHEL 7 system using ifcfg files.
medium- ✓ A.Edit the ifcfg file, then restart the network service, then verify the configuration.
- B.Restart the network service, then edit the ifcfg file, then verify the configuration.
- C.Edit the ifcfg file, then verify the configuration, then restart the network service.
- D.Verify the configuration, then edit the ifcfg file, then restart the network service.
Why A: Static IP configuration requires editing the ifcfg file, restarting network, and verification.
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.