Find the interface you want to set the address
Table of Contents
lists all interfaces.
Find the interface name to set, such as
Edit the interface’s configuration file
NAME, the configuration file is stored in
/etc/sysconfig/network-scripts/ifcfg-NAME. For the above example of
enp2s0, the configuration file is
As an example, to set its IP to 184.108.40.206 with netmask 255.255.255.0, gateway 220.127.116.11, DNS 18.104.22.168, the content will be like
NM_CONTROLLED="yes" DEVICE="enp2s0" BOOTPROTO=static ONBOOT="yes" IPADDR=22.214.171.124 NETMASK=255.255.255.0 GATEWAY=126.96.36.199 DNS1=188.8.131.52
Restart network/NetworkManager services
You will need to restart the network/Networkmanager services to make the new configuration take effect
# systemctl restart network.service # systemctl restart NeworkManager.service
Then you can use
ifconfig -a again to verify whether the IP is set successfully.