Static IPs are typically only used on servers. Remembering how to set it up has always been so-so as it's done only once when setting up the server the first time.
I've not use Centos much before I started working for my current employer. There we use it constantly though, alongside windows server, and I got into checking it out for my own setup as well.

The file that needs to be changed is /etc/sysconfig/network-scripts/ifcfg-enp7s0

TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=none
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=enp7s0
UUID=2c045fc4-538e-3eea-b9ee-bd1dff8ced6b
DEVICE=enp7s0
ONBOOT=yes
IPADDR=192.168.1.14
PREFIX=24
GATEWAY=192.168.1.1
DNS1=1.1.1.1
DOMAIN=localdomain

The name of the file contains the name of the network interface. Change settings according to your own setup.
Finding the interface name can be done using the command nmcli connection show. Example below:

$ nmcli connection show
NAME                UUID                                  TYPE      DEVICE 
Wired connection 1  2c045fc4-538e-3eea-b9ee-bd1dff8ced6b  ethernet  enp7s0 
Both the name and the UUID are used inside the file.

Now restart the interface with systemctl restart network



Categories

Linux Network