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
My hostnamne: osradar-rhel8.local.domain
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
This is the Manual methode
Edit the Device configuration file /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
Try login from other machine
ssh to new Ip address on the remote Server 192.168.2.100
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: ( 220.127.116.11 is google)
# nmcli con mod enp0s3 ipv4.dns "18.104.22.168"
Reload the interface configuration:
# nmcli con up enp0s3
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
Set Static IP Using Nmtui Tool
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