HostOnNet Blog


Configure Network in CentOS 7 Server

To set static IP in CentOS 7 Server, edit file

vi /etc/sysconfig/network-scripts/ifcfg-eth0

Find

BOOTPROTO=dhcp

Replace with

BOOTPROTO=none

Find

ONBOOT=no

Replace with

ONBOOT=yes

Add following, change IPADDRR and GATEWAY as required.

IPADDR=69.30.230.19
NETMASK=255.255.255.255
GATEWAY=69.30.230.17

Here is a diff with original ifcfg-eth0

[root@localhost ~]# diff  /etc/sysconfig/network-scripts/ifcfg-eth0 /root/ifcfg-eth0 
2c2
< BOOTPROTO=none
---
> BOOTPROTO=dhcp
7,9d6
< IPADDR=69.30.230.19
< NETMASK=255.255.255.255
< GATEWAY=69.30.230.17
20c17
< ONBOOT=yes
---
> ONBOOT=no
[root@localhost ~]# 

Setting DNS resolvers

Edit /etc/resolv.conf

vi /etc/resolv.conf

Add

nameserver 8.8.8.8
nameserver 8.8.4.4

Posted in CentOS