Professional Documents
Culture Documents
3 Ways To Set A Static IP Address in RHEL 8
3 Ways To Set A Static IP Address in RHEL 8
/etc/sysconfig/network-scripts/ifcfg-enp0s3
To find your network interface name, you can use the following nmcli command.
# nmcli con
Output:
To edit the file simply use your favorite editor and open the file:
# vim /etc/sysconfig/network-scripts/ifcfg-enp0s3
ifcfg-enp0s3 Configuration
TYPE="Ethernet"
BOOTPROTO="none"
NAME="enp0s3"
IPADDR="192.168.20.150"
NETMASK="255.255.255.0"
GATEWAY="192.168.20.1"
DEVICE="enp0s3"
ONBOOT="yes"
Now you can then check the new IP address using ip command as shown.
# ip a show enp0s3
# nmtui
# ip a show enp0s3
Inform the interface that it is using manual configuration (not dhcp etc.).
Configure DNS if required, we are showing the example with google DNS server
Here is the configuration file generated after running the above commands:
# cat /etc/sysconfig/network-scripts/ifcfg-enp0s3
ifcfg-enp0s3 Configuration
TYPE="Ethernet"
BOOTPROTO="none"
NAME="enp0s3"
IPADDR="192.168.20.170"
NETMASK="255.255.255.0"
GATEWAY="192.168.20.1"
DEVICE="enp0s3"
ONBOOT="yes"
PROXY_METHOD="none"
BROWSER_ONLY="no"
PREFIX="24"
DEFROUTE="yes"
IPV4_FAILURE_FATAL="no"
IPV6INIT="no"
UUID="3c36b8c2-334b-57c7-91b6-4401f3489c69"