Hello everyone and welcome to another fun article that takes us back to the basics of the Linux world. I know this article may sound too simple, but many people ask me, “How can I change my IP address on my Linux computer?” all the time. To do this, I created this simple guide that will come to your rescue.
Now that we’re done, let’s move on to changing the network configuration on the CentOS server.
I am using a virtual machine, so my console will be open to the server, but you can use Putty or Terminal depending on your needs or environment.
After logging in, we go to the default prompt, so the first thing we do is change our working directory to the network-scripts directory.
# cd / etc / sysconfig / network-scripts
Now in this folder we will have a file named ifcfg- and the type of network connection you have. This can be eno for VMware machines, or eth for other types of virtual machines or physical machines. But it always starts with ifcfg- .
In my case, the network interface is ifcfg-eno16777984 .
So what I’m going to do next is edit this file with vi and change the values.
# vi ifcfg-eno16777984
Now we get the following output:
TYPE = “Ethernet”
BOOTPROTO = “none”
DEFROUTE = “yes”
IPV4_FAILURE_FATAL = “no”
IPV6INIT = “yes”
IPV6_AUTOCONF = “yes”
IPV6_DEFROUTE = “yes”
IPV6_FAILURE_FATAL = “no”
NAME = “nic1”
UUID = “e24c5ba8-46ad-41ed-af8e-1fb6f75d98bc”
DEVICE = “eno16777984”
ONBOOT = “yes”
IPADDR = “192.168.1.20”
NETMASK = “255.255.255.0”
GATEWAY = “192.168.1.254”
DNS1 = “192.168.1.1”
DNS2 = “”
DNS3 = “”
DOMAIN = ” home “
IPV6_PEERDNS =” yes “
IPV6_PEERROUTES =” yes “
IPV6_PRIVACY =” no “
This file is self-explanatory. We will need to change the IPADDR , NETMASK , GATEWAY and DNS values ??to the desired values, and then just reboot the network adapter
After changing the values, we will follow the steps below to make the system reload the network configuration.
# ifdown # ifup
After these two commands, the network interface is brought offline and online, and the configuration is reloaded.
It’s simple, right? Hope you enjoyed the article!