To Configure network and set the static IP & hostname in RedHat Linux v9
Hi Everyone in this aricle I will show how to configure a Static IP Address and hostname in a network
Note: Do not try this on a production without having idea of networking
Requirements:
- IP address to set
- hostname and other details that we need to configure
Here, I will first configure the same IP assigned to the system and later I will configure a new static IP for the demo purpose
If you have the network details its well and good, but to go through and have a look on the values use the following command:
To give the current IP address
$ ip addr
This command will display all the network related information
$ nmcli conn show
From the above two command we can see that enp0s3 is the Network Config being use, which might be different in your case
To get all the details of the enp0s3 we use the following command :
$ nmcli conn show enp0s3
From the above we got the following details to change:
The current IP address is : 192.168.1.106 with subnet of 255.255.255.0 or /24
The gateway address is: 192.168.1.1
Let’s make the current address static , run the below command:
$ nmcli connection mod enp0s3 ipv4.addresses 192.168.1.106/24 ipv4.gateway 192.168.1.1 ipv4.dns 8.8.8.8 ipv4.dns-search google.com ipv4.method manual
After making the changes, we need to restart the connection with new config
Use the below command to do so.
$ nmcli conn down enp0s3 && nmcli conn up enp0s3
If we configured with correct parameters we will be able to logoin with the above ipv4 address set
Now let’s change the ip to a different withing the network , lets set the ip to 192.168.1.108
As usual run the below command:
$ nmcli connection mod enp0s3 ipv4.addresses 192.168.1.108/24
$ nmcli conn down enp0s3 && nmcli conn up enp0s3
the shell may hang as connection will be lost as there is change in the IP address
Let’s try to login with this new IP address
Hurray !! we are able login as shown in below
Hope this article was useful and you were able to configure a Static IP Address. If facing any issue. Feel free to leave a comment or you can connect on my linkedIn for any discussion……➕💕😊