20.1 C
Texas
Melhttp://www.osradar.com
Guru Unix /Linux and GNU supporter

How to Set a Static IP Address in RHEL 8 or Centos8

In entreprise Environemtns  you are  dedicated en uniq  IP addresses for every machine. i will show to today from my virtual test Server many ways how to set a static Ip adress to your Centos8 or RHEL8 Server.

Lets begin about my system settings

Hostname

My hostnamne:  osradar-rhel8.local.domain

- Advertisement -

network Setting

My netwrok device is configured to get autmaticaly Ip address from the rooter via DHCP protocol

Lets  say i want a static IP address  for this Server like 192.168.2.100 and my gateway (router is  192.168.2.254)   lets do it on this way

Method 1

This is the Manual methode

Edit  the Device configuration  file /etc/sysconfig/network-scripts/ifcfg-enp0s3

vi /etc/sysconfig/network-scripts/ifcfg-enp0s3

Please ignore or remove the IPV6 lines if you are not using IPV6 protocols.

Restart  the  Device or just reboot the Server

ifdown enp0s3
ifup enp0s3

Check now

Try login from other machine

ssh  to new Ip address on the  remote Server  192.168.2.100

its wokring!

Method 2

This method is using nmcli tool ( Network Manager command tool)

How to Set a Static IP Address in RHEL 8 or Centos8 using nmcli tool

Before to start ,lets explain about some options to use with nmcli  tool

con  = connection

mod = modify

manual  =  Static ip Address

Set the IP address for interface enp0s3 on RHEL 8 or Centos8.

# nmcli con mod enp0s3 ipv4.addresses 192.168.2.101/24

Set the gateway on RHEL 8 or Centos8:

# nmcli con mod enp0s3 ipv4.gateway 192.168.2.254

Confirm to  the interface to use manual configuration  instead of  dhcp.

# nmcli con mod enp0s3 ipv4.method manual

Configure DNS:   (  8.8.8.8   is  google)

# nmcli con mod enp0s3 ipv4.dns "8.8.8.8"

Reload the interface configuration:

# nmcli con up enp0s3

check

Not that if  you are  doing these commands from an remote server via ssh connection , the connection will be dropped  🙂  because will get  new  IP address

Its Working too

Method 3

Set Static IP Using Nmtui Tool

nmtui

Edit Connection 

Edit Device name 

Change IPv4  from automatic to  Static 

under Show  you add the IP adderess GATEWAY  and  DNS   (  use  TAB to  move between the lines)

Then Go to OK in The bellow page Config / then TAB  to  back

Activate  The Connection  . or Reboot  your  Server 

Enjoy and share

- 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