Get 50% Discount Offer 7 Days


Contact Info

Chicago 12, Melborne City, USA

+88 01682648101

[email protected]

The Ultimate Guide to Change IP Address on Centos

If you intend to change and configure your IP address in the CentOS system, you should know that the IP configuration in CentOS is done automatically. So, to change your IP in CentOS, you have to do it manually. This article examines how to change the IP address with possible methods. So apply the below steps carefully to achieve your desired result.


If you want to change the IP address on CentOS distribution you have to prepare some requirements like:

  • Up-to-date CentOS distribution in Linux VPS
  • A user with root access

3 Simple Methods to Change IP Address on CentOS

You can configure and change your IP address using a number of options or methods available in this article. So, keep studying:

change IP address on centos

Method 1: Change IP Address on CentOS Via Network Configuration File

First, run the following command to determine the name of your network adapter:

sudo lshw -class network -short

Now use a suitable text editor to open the configuration file of your network adapter and replace x with the name of your network adapter:

nano /etc/sysconfig/network-scripts/ifcfg-ethX

As you can see below, you should configure the variables in the file:


Below are the most common configuration parameters with explanation:

BOOTPROTO= none, bootp or dhcp
DEVICE=<name> –> where <name> is the name of the physical device.
DNS{1,2}=<address> –> where <address> is a name server address to be placed in /etc/resolv.conf
MACADDR=<MAC-address> –> Where <MAC-address> is the hardware address of the Ethernet device in the form AA:BB:CC:DD:EE:F

ONBOOT=<answer> –> Where <answer> is one of the following:
yes — This device should be activated at boot-time.
no — This device should not be activated at boot-time.

yes – Modify /etc/resolv.conf if the DNS directive is set. If using DHCP, then yes is the default.
no – Do not modify /etc/resolv.conf.

yes  – Non-root users are allowed to control this device.
no – Non-root users are not allowed to control this device.

If you have the network manager service and run it, you must configure it so that the network manager does not manage this interface (eth0). You can do this by adding the following line:


Use the command below to stop the network manager service:

sudo systemctl stop NetworkManager

Save the changes, shutdown, and bring back the interface:

sudo ifdown eth0 && sudo ifup ethX

Now stop the network manager service using the following command:

sudo systemctl stop NetworkManager

Go through this command to check the current adapter setting:

ip addr show

Method 2: Change IP Address on CentOS Via IP and ifconfig commands

Note that the ifconfig command is deprecated, but it is still part of the net-tools package and can be installed with this command:

yum -y install iproute

For more clarification, we will show both iptools and ifconfig commands.

If you want to show IP address-related information, use the following command:

ip addr

Then to bring up or down an interface, use the command below:

sudo ifconfig ethX down
sudo ip link set dev ethX down

You can set the static IP using ip or ifconfig commands. be careful, because changes made with these two are not persistent against reboots.

sudo ifconfig ethX netmask
sudo ip addr add dev ethX

To clear the IP information, run the following command:

sudo ifconfig ethX del
sudo ip addr del dev ethX

For destinations without static routes defined, you set the default route using ip and ifconfig commands:

sudo route add default gw
sudo ip route add default via

Method 3: Change IP Address on CentOS Via Network Manager

The network manager service is used for CentOS management and for dynamic configuration and control of network devices. This service can also be used to keep active connections available.

You can remove the network manager, but if you just want to disable and then remove it, use the command below:

systemctl disable NetworkManager
systemctl remove NetworkManager

In this section, we will mention commands so that you can use the network manager service using them.

First, you should check the status of the network manager using these commands:

systemctl status NetworkManager
sudo systemctl start NetworkManager

To bring network interfaces up and down use the network manager with the commands below:

sudo nmcli connection down ethX
sudo nmcli connection up ethX

Configuring A Static IP Via Network Manager

change IP on centos

Use this command to list the current connections:

nmcli con show

Enter UUID or network name from step 1 to delete connections:

nmcli con delete eth0

By running the command below, you can create a network using ethx:

nmcli con add type ethernet ifname ethX con-name ethx \ autoconnect yes ip4 gw4

Now you need to configure DNS. You have to do the network settings manually:

nmcli con mod ethX ipv4.method manual 
nmcli con mod ethX ipv4.dns ""

Use this command to restart the network:

sudo nmcli con down ethX && sudo nmcli con up eth0

Running the following command, helps you to view the connection ethx:

nmcli con show ethX

Troubleshooting Issues About Change IP Address on CentOS

Here are some problems with changing IP address CentOS:

1- Lost connection after IP changes.


If you lose connection to the server after changing the IP, it could be due to an incorrect configuration. Revert the changes and check for typos or mistakes.

2- Incorrect Syntax in Configuration File


Ensure that the syntax in the configuration file is correct. A small typo can cause issues.

3- There may be firewall problems


Update firewall rules to allow traffic to the new IP address. Use the firewall-cmd or iptables command to configure firewall settings.


As mentioned in this article, IP is configured automatically and the service used to manage CentOS is called network manager. But if you need to change your IP, you have to do it manually. We also tried to show you how to change and configure the IP in three different ways. So follow the steps carefully and if you have any questions, contact us in the comments section.

How useful was this post?

Click on a star to rate it!

Average rating 5 / 5. Vote count: 2

No votes so far! Be the first to rate this post.

Share this Post

Leave a Reply

Your email address will not be published. Required fields are marked *