Find the interface you want to set the address ∞
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 126.96.36.199 with netmask 255.255.255.0, gateway 188.8.131.52, DNS 184.108.40.206, the content will be like
NM_CONTROLLED="yes" DEVICE="enp2s0" BOOTPROTO=static ONBOOT="yes" IPADDR=220.127.116.11 NETMASK=255.255.255.0 GATEWAY=18.104.22.168 DNS1=22.214.171.124
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.