Configure Network — CentOS 7¶
First of all we need to find the correct network device. The command nmcli d will do the trick:
rtm@centos:~$ nmcli d
DEVICE TYPE STATE CONNECTION
enp0s3 ethernet disconnected enp0s3
lo loopback unmanaged —
In my case it's enp0s3. So let's edit the configuration file — remember you need to be root to do it! The file is located here: /etc/sysconfig/network-scripts/ifcfg-enp0s3, and has the following content:
TYPE=Ethernet
BOOTPROTO=none
DEFROUTE=yes
PEERDNS=yes
PEERROUTES=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_PEERDNS=yes
IPV6_PEERROUTES=yes
IPV6_FAILURE_FATAL=no
NAME=enp0s3
UUID=828a0fb1-f5c7-4657-bfb6-5c939d888014
DEVICE=enp0s3
ONBOOT=no
From now on we have two paths to follow, DHCP or static. Both are shown below.
DHCP¶
It's the easier way — just edit the two marked lines:
to:
Then restart the network interface:
Static¶
This requires a little more will. Edit the file:
to:
But you will need to add some config lines:
Then restart the network interface:
Everything must be working at this point!