Static IP on CentOS 7: How to Configure
How to configure a static IP address on CentOS 7 using nmcli or the ifcfg file. Includes a warning about CentOS 7's EOL and supported alternatives.

In this article
- 01CentOS 7 Has Reached End of Life: What That Means for You
- 02Why Set a Static IP on a Linux Server
- 03Before You Start: Identify the Network Interface
- 04Method 1 — nmcli (the recommended approach on CentOS 7)
- 05Method 2 — Editing the ifcfg File Directly
- 06Verifying the Configuration Is Correct
- 07Related Service: Linux System Support and Virtualisation
CentOS 7 Has Reached End of Life: What That Means for You
Before we get into the guide, an important note: CentOS Linux 7 reached End-Of-Life on 30 June 2024. This means it no longer receives security updates from the CentOS project. If you still have CentOS 7 machines in production, the network configuration described below works exactly as documented, but your first concrete step should be planning a migration to a still-supported distribution (Rocky Linux, AlmaLinux or CentOS Stream), rather than continuing to invest in a system that no longer receives patches.
That said, the procedure for setting a static IP address is identical on these RHEL-compatible distributions: this guide stays useful even if you are already working on a CentOS 7 replacement.
Why Set a Static IP on a Linux Server
A server (file server, database, virtualisation host, NAS) needs to remain reachable at the same address at all times: if the IP changes every time the DHCP router restarts, you break connections from other machines, remote access (SSH), firewall rules and any automation that points to that host. That is why a server, unlike a regular client PC, is almost always given a static IP address configured manually on the network interface.
Before You Start: Identify the Network Interface
Connect to the CentOS 7 machine via SSH or console and find the name of the network interface you need to configure:
ip addr
The command returns the list of available interfaces (typically something like enp0s3 on a VM, or eth0/ens160 on physical hardware or other hypervisors) along with the IP address currently assigned via DHCP and the link state (UP/DOWN). Make a note of the exact name: you will need it in the next step.
Method 1 — nmcli (the recommended approach on CentOS 7)
CentOS 7 uses NetworkManager by default, and the most reliable way to configure a static IP is through the nmcli command, which writes the correct configuration without you having to edit files by hand:
nmcli con mod enp0s3 ipv4.addresses 10.10.10.150/24
nmcli con mod enp0s3 ipv4.gateway 10.10.10.254
nmcli con mod enp0s3 ipv4.dns "8.8.8.8 8.8.4.4"
nmcli con mod enp0s3 ipv4.method manual
nmcli con up enp0s3
Replace enp0s3 with the actual name of your interface, and the addresses with the ones used on your network. The last command reapplies the configuration without needing to restart the server.
Method 2 — Editing the ifcfg File Directly
If you prefer (or need to, on systems with NetworkManager disabled) to work on the interface's configuration file directly, open it with a text editor:
vi /etc/sysconfig/network-scripts/ifcfg-enp0s3
Inside the file, set (or add) these parameters:
BOOTPROTO=static
IPADDR=10.10.10.150
NETMASK=255.255.255.0
GATEWAY=10.10.10.254
DNS1=8.8.8.8
DNS2=8.8.4.4
ONBOOT=yes
The key parameter is BOOTPROTO=static (the default is dhcp): this tells the system to use the fixed address specified instead of requesting one from the router. Save the file and restart the interface:
systemctl restart network
or, if the network service is not active (common on more recent installs):
ifdown enp0s3 && ifup enp0s3
Verifying the Configuration Is Correct
After restarting the interface, check that the address has been applied correctly:
ip addr show enp0s3
ping -c 4 8.8.8.8
If the ping reaches its destination and ip addr shows the static address you set, the configuration was successful. If the machine stops responding on the network after the change, check that you used a free IP address within your subnet (not already assigned to another device) and the correct gateway.
Related Service: Linux System Support and Virtualisation
Beyond network configuration, we look after the whole lifecycle of Linux servers through our system support service, including migration to a supported, up-to-date Linux virtual server.
Frequently asked questions
Should I use nmcli or edit the ifcfg file?
On CentOS 7 with NetworkManager active (the default installation), nmcli is the safer method because it avoids syntax errors in the file and applies the configuration immediately. Editing the ifcfg file by hand is still useful to understand what is happening "under the hood", or on systems where NetworkManager has been disabled.
What happens if I get the IP address or gateway wrong?
If the address is already in use by another device on the network, or the gateway you entered is wrong, the machine loses network connectivity (but stays reachable from the local console, not remotely). Before applying changes from an SSH session, always make sure you have a way to access the machine even if something goes wrong (physical or virtual console).
Is it still worth using CentOS 7 in 2026?
No: CentOS Linux 7 reached end of life on 30 June 2024 and no longer receives security updates. For a production server, it is important to plan a migration to a still-supported RHEL-compatible distribution (Rocky Linux, AlmaLinux or CentOS Stream). If you would like a hand assessing the timeline and risks of the migration, get in touch: we provide IT support to SMEs, including on Linux infrastructure.
Technology partners
Want to discuss it with our team?
We analyse your infrastructure for free and propose the most suitable solution.







