How to configure a Static IP in CentOS 8?

Welcome back! In this quick article, I’ll explain how to configure a Static IP in CentOS 8. If you’re configuring a server machine using centOS, static IP is a must. So, Let’s get started!

My Setup

centOS 8 installed in VMware workstation 15.5
Allocated 4GB Ram

1 . Open Network-Script file

On centOS, we can easily configure a static IP via editing the network-scripts file. Open the following file via vim editor.

vim /etc/sysconfig/network-scripts/ifcfg-ens33

above the “ens33” is the network card interface name. You can check your one using the following command.

nmcli connection show

nmcli output

2 . Edit the Network-Script file

network-script file is like followings.

ifcfg-ens33 file

You need to change or add following parameters to assign static IP.

BOOTPROTO=none
IPADDR=<Static IP Address>
NETMASK=<Subnet Mask>
GATEWAY=<Default Gateway IP>
DNS1=<DNS Server IP>

After adding or editing the above parameters, you must reload your network interface to obtain the above parameters. Use the following commands.

nmcli connection down ens33
nmcli connection up ens33

3 . Check the IP address

If you follow the above instruction correctly, your centOS machine will get a static IP from the network script file. To check the IP address of your network interface, Use the following command.

ifconfig

The output needs to be as follows.

ifconfig output

That’s all about configuring static IP via terminal. If you have any questions, leave a comment below.

You may also like...

Leave a Reply

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