The entire ecosystem of the Red Hat Linux Enterprise family is used extensively on servers. Whether enterprise, small, or medium, RHEL-based distributions copy that segment along with Debian and Ubuntu. And in server management, it is common and frequent to use configurations over IP addresses. In this case, you will learn to establish a static IP address on CentOS 8, RHEL 8 and Oracle Linux 8.
How to set a static IP address on Centos 8 / RHEL 8 / Oracle Linux
Linux is a fairly flexible system and this results in several ways of doing the same process. In this case, it is the same, we will be able to establish a static IP address in several ways. To avoid unnecessarily lengthening the post, I will only show one single way.
It is advisable to read about static and dynamic IP addresses. This is because it is not always good to have them, although in an internal network it helps a lot to manage the services of that server. Even, at cluster level and related things, it is necessary to assign a specific address to a node.
So, let us start.
Using the Network scripts to set a static IP address
I think this is the most basic way to set a static IP address in CentOS 8, RHEL 8 and Oracle Linux 8. Because this way we will not have to install or use third-party tools to do the configuration. On the other hand, it is a bit rough for newbies.
First of all, you have to know what the network interfaces you have active are called. Let us suppose that we are going to define a static IP address to the ethernet wired network.
So, open a terminal and run the following:
:~$ ip addr show
In the screen output of the command, you will notice that they open several interfaces. In my case, there are only two. The local and another one called
enp0s3. That is the one we want to change.
Now open the configuration file of that network interface. I will use
nano for it, if you do not have it installed you can do it.
:~$ su :~# nano /etc/sysconfig/network-scripts/ifcfg-[network-interface]
The content of the file is quite explicit. However, to configure the static IP, it is enough to modify these elements:
Also, if you want to use DNS, add these two options.
Next, save the changes and close the file.
It is now necessary to reload the networks profile so that the system knows that there have been changes.
:~# nmcli connection reload
Finally, restart the connection.
:~# nmcli con down [network_interface] :~# nmcli con up [network_interface]
Now, check the new IP address with this command:
:~# ip addr show
So, everything is OK.
In this post, you have learned to set a static IP address in CentOS 8, RHEL 8 and Oracle Linux 8. This way you will be able to manage some servers a little better and it is a very used network function. On the other hand, if you use any of these distributions as a personal system it is probably not useful.
You can also read How to set a static IP address on Debian 10 Buster?
Please share this post and join our Telegram channel.