Add static IP addresses manually on CentOS 7 or Redhat
In this blog post, I will describe you how to add static IP address on CentOS 7 or other Redhat based Linux distros.
An IP address can be added by two ways -
1. Using nmcli command utility
2. By directly editing the network configuration file.
The Path of Network configuration file in CentOS and RHEL based Linux distros is /etc/sysconfig/network-scripts/ in this directory you will find configuration file like ifcfg-eno1 or ifcfg-eth0 etc. where eth0 and eno1 is your interface name, which may vary according to your network interface on the system.
How can I find my interface name?
Just enter the simple below mentioned command, it will show your active interface.
nmcli device
As I have highlighted in an above image enp0s3 is my network interface.
Now, open the network configuration file with your favourite text editor vim, nano etc located at /etc/sysconfig/network-scripts/ifcfg-x where x is your interface name.
Add the following highlighted entries into the file and change them according to your network configuration -
For example
ONBOOT = yes
IPADDR = 192.168.3.206
GATEWAY = 192.168.3.1
DNS1 = 8.8.8.8DNS2 = 192.168.3.1(optional)
PREFIX = 24 or NETMASK = 255.255.255.0
BOOTPROTO = yes
After adding entries save the file and restart the network service by using the following command
systemctl restart network
0 Comments