Configure CentOS network settings: instructions


+2 votes

Dear experts!

Please, help to configure network in CentOS. I have installed the system on an old laptop to study it, plugged in the network cable, but network doesn’t function.

related to an answer for: Installing CentOS: a step-by-step guide
asked Nov 21, 2016 in System administration by Chen

1 Answer

0 votes

Good day to you!
Configuring network in CentOS is very simple. You need to edit one file and restart the network utility. But first things first.
In CentOS, network settings are located:

/etc/sysconfig/network-scripts/

For each network card, a separate settings file is created: ifcfg-eth0, ifcfg-eth1 .... ifcfg-eth99. The name of the file for the first or the only network card will be ifcfg-eth0. To edit it, type in the console:

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

Press "i" button to switch to editing mode and insert one of the following configurations in the file.

Configuring the static IP network

The typical configuration is as follows:

DEVICE='eth0' //network card name
TYPE=Ethernet // network card type
BOOTPROTO=none // automatic setup protocol (for example, DHCP) 
ONBOOT='yes' //switch on when starting the system
IPADDR=177.61.211.162 //Static IP 
NETMASK=255.255.192.0 //Subnet mask
GATEWAY=177.61.192.1 // Default gateway
DNS1=8.8.8.8 //DNS server 
DNS2=8.8.4.4

If your CentOS server operates within the local home network, you can find the subnet mask and communication server on any other PC with Windows or Linux. You can occupy any free IP address. If the server is connected to a provider or located in a data center, you should receive all the settings from your provider.

Configuring the dynamic IP network

It’s a very rare case, when the dynamic IP network is to be configured in CentOS, but I will post the settings just to be on a safe side:

DEVICE='eth0' // network card name
TYPE=Ethernet // network card type
BOOTPROTO='dhcp' // automatic setup protocol
ONBOOT='yes' // switch on when starting the system

Applying new configurations of the network

Applying new configurations of the network

After you have made all the necessary alterations in ifcfg-eth0 file, click “Esc” button to exit editing mode and after that, type “:wq” for stateful exit from the editing program and press “Enter”.
Now, check the settings of the main configuration file: 

vi /etc/sysconfig/network

There should be the following content:

NETWORKING=yes
HOSTNAME=dev.helpdesk.zone //you host name 

To apply the alterations, you should restart the network interface:

/etc/init.d/network restart

Centos network restart

If you have more questions or need details - please, ask a question or leave a comment.

answered Nov 21, 2016 by Expert Brian (5,370 points)

Related questions

Welcome to Help Desk, here you can ask any questions and receive answers from our experts and other members of the community.

If you have any questions, please do not hesitate to contact our help desk!

Make a question!