Networks in CentOS

Managing IP addresses in Centos


Access the server via SSH

list the directory /etc/sysconfig/network-scripts/

[root@centos8 ]# ls /etc/sysconfig /network-scripts/
ifcfg-ens192  ifcfg-ens224


There should be one or more files beginning “ifcfg-”
In my case its "ifcfg-ens192"

edit the file /etc/sysconfig/network-scripts/ifcfg-ens192

nano /etc/sysconfig/network-scripts /ifcfg-ens192


replace the contents with this:

TYPE=Ethernet
#replace the next two lines with your own data
NAME=Public_ens192
DEVICE=ens192

ONBOOT=yes
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=static
IPADDR=ABC.DEF.GHI.JKL
PREFIX=32
GATEWAY=10.255.255.1
DEFROUTE=yes
IPV4_FAILURE_FATAL=no

#Uncomment one or more of these to add extra ipv4. Each IPADDRn needs a unique number in place of 'n' and a PREFIXn to match
#IPADDRn=ABC.DEF.GHI.JKL
#PREFIXn=32
#IPADDRn=ABC.DEF.GHI.JKL
#PREFIXn=32


#ipv6 config - uncomment to use ipv6. Remember to switch IPV6ADDR with the ipv6 you have
#IPV6INIT=yes
#IPV6_AUTOCONF=no
#DHCPV6_DUID=ll
#IPV6ADDR=ab12:ef34:ij56:mn78::1/128
#IPV6_DEFAULTGW=fe80::1
#IPV6_DEFROUTE=yes
#IPV6_FAILURE_FATAL=no

#uncomment the next line to use multiple IPS. Keep all your ipv6 in one line within the quotes, space seperated
#IPV6ADDR_SECONDARIES="ab12:ef34:ij56:mn78::1/128 ab12:ef34:ij56:mn78::1/128"

#DNS - Replace with your own choices if you wish.
DNS1=8.8.8.8
DNS2=1.1.1.1
DNS3=8.8.4.4
#Enable/replace the ipv6 entries if you need
#DNS4=2001:4860:4860::8888
#DNS5=2001:4860:4860::8844


Save (Ctrl X, then Y)



Reboot the server (I have not got a reliable way to restart networking on Centos)


Check with:

ip a #List assigned IPs

ping google.com #ensure you can reach google

ping6 google.com #ensure you can reach google over ipv6