Linux

How To Configure CentOs network manually

In this artticle you will learn how to manually config CentOS network (DHCP or STATIC).

PART I. Steps To Configure DHCP

Step 01: Go to /etc/sysconfig/network-scripts

Command: cd /etc/sysconfig/network-scripts

Step 02: Type ls and find your network interface name. In this case it is called ifcfg-enp0s3

Step 03: Edit the file

Command: sudo vi ifcfg-enp0s3

Step 04: Make sure thst BOOTPROTO = dhcp and ONBOOT  is set to YES

Step 05: Add MM_CONTROLED=no (This line ensures that Network Control Manager will not make any changes to this configuration)

Step 06: Hit Esc key and type :wq to write the file to disk and quit the editor.

Step 07: Restart the network interface.

Command: systemctl restart network

Step 08: You can type ip a to see if there is an IP adress assigned

That’s it for DHCP configuration.

 

PART II. Steps To Configure Static IP Address

 

Step 01: Go to /etc/sysconfig/network-scripts

Command: cd /etc/sysconfig/network-scripts

Step 02: Type ls and find your network interface name. In this case it is called ifcfg-enp0s3

Step 03: Edit the file

Command: vi ifcfg-enp0s3

Step 04: Make sure that BOOTPROTO this time is set to static and add the following lines:

IPADDR = (YOUR IP ADDRESS)

NETMASK= (YOUR SUBNET MASK)

GATEWAY= (YOUR GATEWAY IP)

DNS1= (YOUR DNS)

DNS2=(YOUR SECOND DNS)

Step 04: Hit Esc key and type :wq to write the file to disk and quit the editor.

Step 05: Restart the network interface.

Command: systemctl restart network

Step 08: You can type ip a to verify that the desired IP adress is assigned.

 

That’s it!