Static IP addresses can be a great way to ensure your devices always have the same IP address. This is especially helpful if you're running any type of server, such as web hosting, and need to keep your servers available on the same address no matter what. Luckily, static IPv4 configuration on CentOS 8 is easy!

Open Terminal

To get started with setting up your static IP address, open up your terminal

Edit network interface

Edit the network interface configuration file at:

/etc/sysconfig/network-scripts/ifcfg-eth0

Make sure to replace 'eth0' with whatever your actual network interface is called; you can find this by typing in terminal:

ip addr show

Once you've opened that file for editing, add these lines to the configuration:

BOOTPROTO=static

IPADDR=XXX.XXX.X.X (replace with your desired IP address)

NETMASK=255.255.255.0

GATEWAY=XXX.XXX.X.X (replace with your gateway IP address)

DNS1=8.8.8.8

DNS2=4.4 .4 .4 (optional, you can use any other DNS server of your choosing)

Save & Restart

Save and close the file, then restart the network services by typing:

systemctl restart network

Now, if you type in:

ip addr show

You should see that your static IP address has been successfully assigned to your device.

And that's it - congratulations, you've just set up a static IPv4 configuration on CentOS 8! Now you can rest assured knowing that your server is always available on the same address no matter what. Enjoy!

 

Was this answer helpful? 13 Users Found This Useful (43 Votes)