Setting static IP in CentOS 7 Minimal Installation

In order to set the network adapter and get get CentOS to communicate on the network the Ethernet adapter will need to be configured. In this lesson I will set a static IP address for the network adapter. To view a list of your network adapters use the command ip addr.
The configuration file for the network adapter should be located at /etc/sysconfig/network-scripts/ifcfg-enp0s3. With the minimal installation of CentOS there are not many options available to configure the network adapter. One option is to use the vi editor or nano to configure ifcfg-enp0s3. Another option is to use the nmtui utility to edit the network adapter.
Modify ifcfg-enp0s3 using nmtui
If you plan on configuring the network adapter using the nmtui utility open a terminal and enter the command nmtui A utility application opens within the terminal that will allow you to configure the network adapters. With Edit a Connection selected, press Enter. Your network adapter should be listed, for example enp0s3 is what is listed on my computer. Using the arrow keys, select Edit and press Enter. To allow the adapter to fire up at startup, use the spacebar to place an “x” in the Automatically connect option. If you wish to set a static IP address you can do so by selecting the IP version and editing it.
Modify ifcfg-enp0s3 using vi or nano
If you are familiar with using the vi editor you can also modify the ifcf-eth0 file using vi. To use this option, type the following command in the prompt: vi /etc/sysconfig/network-scripts/ifcfg-enp0s3
You can also use nano as a text editor. If you are newer to Linux this editor has less of a learning curve than vi. Nano will need to be installed using the command: yum install nano Once installed, to use nano to edit the file type: nano /etc/sysconfig/network-scripts/ifcfg-enp0s3
Here is an example of the file using 192.168.1.2 as the static IP address.
TYPE=Ethernet
BOOTPROTO=none
DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6INIT=no
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
NAME=enp0s3
UUID=”WHAT EVER IS YOUR COMPUTER’s UUID”
ONBOOT=yes
HWADDR=”WHATEVER IS YOUR COMPUTER’S MAC ADDRESS”
IPADDR=192.168.1.2
PREFIX=24
GATEWAY=192.168.1.1
DNS=192.168.1.1
IPV6_PEERDNS=yes
IPV6_PEERROUTES=yes
Restarting the networking service
You may have to restart the network adapter or the machine. To restart the network adapter use the following command: service network restart.
Using ifconfig
If you wish to install the common networking tools you can now install the net-tools package using the following command: yum install net-tools
This will allow you to view your network adapters using the terminal command: ifconfig