HostOnNet Blog

Configure Network in CentOS 7 Server

Looking for Linux Server Admin or WordPress Expert? We can help.

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

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.