How to configure static IP address in CentOS 8

by | May 20, 2020 | linux | 0 comments

There are two quick ways to configure an IP address on the network interface of CentOS 8 operating system. The one is using the command nmtui and another is by direct editing of network files.

If you are not comfortable editing configuration files, choose option 1 to configure networks interactively.

Method 1 – Using nmtui tool

Run the following command to access an interactive form of network interface configuration.

sudo nmtui

Now, edit the default existing connection. In case there is no connection available, use Activate a connection.

Setup networking centos 8

You will see the list of Ethernet interfaces, select the interface you want to configure, then select Edit option on the right side of the interface.

Configure static IP centOS 8

Keep the profile name and device name unchanged. Set the IP address, gateway and DNS servers to the IPv4 configuration option. You can add multiple addresses using the selection option just below the IP address box.

Use nmtui network configuration on centos 8

Save the configuration and restart the NetworkManager service using the following command.

sudo systemctl restart NetworkManager.service

Method 2 – Using configuration files

The default network interfaces configuration file exists in the directory /etc/sysconfig/network-scripts/. The file name may vary depending on the type of installation, such as Physical Machine or Virtual Machine. The configuration file shoul be like ifcfg-XXXX (for example: ifcfg-eth0, ifcfg-eth1, ifcfg-enp0s3 etc.)

sudo vim /etc/sysconfig/network-scripts/ifcfg-enp0s3

Use the following configuration to configure a static IP address for the CentOS 8 network interface.

Static IP configuration:

TYPE=Ethernet BOOTPROTO=static NAME=enp0s3 DEVICE=enp0s3 ONBOOT=yes IPADDR=192.168.1.237 PREFIX=24 GATEWAY=192.168.1.2 DNS1=8.8.8.8 DNS2=192.168.1.2 USRCTL=no

Alternatively, if you want to assign the IP address through the DHCP server, use the following settings.

DHCP Configuration

TYPE = Ethernet DEVICE = enp0s3 BOOTPROTO = dhcp ONBOOT = yes

Configuration parameter details:

  • DEVICE: Ethernet device name
  • BOOTPROTO: dhcp or static
  • ONBOOT: yes/no, indicates whether the interface will be turned on automatically or not at boot.
  • Guy: Interface type.
  • USRCTL: Yes/no, indicates that a non-root user can upload or download this device.

Save the configuration and restart the NetworkManager service using the following command.

sudo systemctl restart NetworkManager.service

That's it.

ZX Spectrum 48K Composite Video Mod

Zx Spectrum Composite Video Mod

Assemble a new ZX Spectrum issue 4B from new parts

Here we document the exciting experience of building a new ZX Spectrum issue 4B board from scratch. Thanks to innovative individuals like Charlie Ingley, who created a replacement ULA chip, this project is now possible. Initially it has been designed and...

DiyBMS v4 BMS for Lithium batteries

DiYBMS is an open source lithium battery optimizer by Stuart Pittaway

How To Set up SSH Keys on a Linux

This page explains a public key and shows you how to set up SSH keys on a Linux or Unix-like server. I am assuming that you are using Linux or Unix-like server and client with the following software: OpenSSH SSHD server OpenSSH ssh client and friends on Linux...

Configuring an rsync Task

Configuring an rsync Task How to configure automated data transfers using rysnc. 9 minute read Data often needs to be copied to another system for backup or when migrating to a new system. A fast and secure way of doing this is by using rsync. Rsync provides the...

easy crontab

Here are the cron expersions you can use in crontab. Examples of Cron Expressions Cron ExpressionMeaning* * * * *Run a cron job every minute*/5 * * * *Run a cron job every 5 minutes0 * * * *Run a cron job every hour0 12 * *...

File synchronization in Linux

In this tutorial we are going to configure rsync and crontab to synchronize files between two machines without using a password and schedule execution times for it. To avoid every time a synchronization script is launched, it asks for the password of the user of the...

Install webmin on CentOS 8

In this tutorial, we will show you how to install Webmin using two different methods on CentOS 8. Prerequisites A server running CentOS 8. User with administration privileges on the server. Getting Started By default, SELinux is enabled on the server...

Wifi Switch ESP8266

Two-channel Wi-Fi switch to be incorporated with simon 31 or Siemmes mechanisms Creating a smart home does not have to be difficult. In fact, there are more and more connected devices for the Smart Home within everyone's reach, such as lighting systems...
en_GB