Centos 7 - Assign Static IP Address to Nic1

GenieMaster
GenieMaster used Ask the Experts™
on
Hi I have a server that has Centos7 that does not have an GUI Interface installed. By accident for some reason it looks as though during the install I did not set the IP Address details of Nic1and these should be static. I am trying to set it so that the IP address details of Nic 1 is 10.10.230.12. subnet mask is 255.255.255.0, gw is 10.10.230.6 and the dns I was going to just set as 8.8.8.8 (Google DNS Servers)
Can you help on the commands to run to set this please. The server has 2 nics but only nic1 is plugged in.  if I run the command ip a this is what I get (please see attached file). I assume the nic is that called enp2s0f0
Centos7.jpg
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Most Valuable Expert 2015

Commented:
as root:

either use vi or nano

vi /etc/sysconfig/network-scripts/ifcfg-enp2s0f0 and substitute your IP and gateway.

TYPE=Ethernet
NM_CONTROLLED="no"
BOOTPROTO=none
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
NAME=enp2s0f0
UUID=***DO NOT CHANGE THIS*** USE YOUR UUID
DEVICE=enp2s0f0
ONBOOT=yes
DNS1=8.8.4.4
DNS2=8.8.8.8
IPADDR=192.168.1.2
PREFIX=29
GATEWAY=192.168.1.1
IPV6_PRIVACY=no
ZONE=public
PEERDNS=no

and save it.

add your DNS servers to /etc/resolv.conf:

nameserver 8.8.8.8
nameserver 8.8.4.4

or whatever IPs you are using for DNS
Jayachandran PalanisamyTechnical Consultant - Linux

Commented:
Adding further to above comment by Jan Springer. Do network service restart to get the changes effective.

systemctl restart network

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial