24 C
Texas
angeloma
Senior Writer and partner

How to set a static IP address on CentOS 8/ RHEL 8 / Oracle Linux 8

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

- Advertisement -

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

1.- The network interface on CentOS 8 RHEL 8 Oracle Linux 8
1.- The network interface on CentOS 8 RHEL 8 Oracle Linux 8

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:

TYPE="Ethernet"
BOOTPROTO="none"
NAME="eth0"
IPADDR=192.168.250.105
NETMASK=255.255.255.0
GATEWAY=192.168.1.1
BROADCAST=192.168.255.255
DEVICE="eth0"
ONBOOT="yes"

Also, if you want to use DNS, add these two options.

DNS1=[DNS_SERVER]
DNS2=[DNS_SERVER]

Next, save the changes and close the file.

2.- Set a static IP address on centos 8, RHEL 8 and Oracle Linux 8
2.- Set a static IP address on centos 8, RHEL 8 and Oracle Linux 8

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

3.- Check the changes
3.- Check the changes

So, everything is OK.

Conclusion

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.

- Advertisement -
Everything Linux, A.I, IT News, DataOps, Open Source and more delivered right to you.
Subscribe
"The best Linux newsletter on the web"

LEAVE A REPLY

Please enter your comment!
Please enter your name here



Latest article