The Wayback Machine - https://web.archive.org/web/20240618223556/https://www.geeksforgeeks.org/centos-network-configuration-without-networkmanager/
Open In App

CentOS Network Configuration without NetworkManager

Last Updated : 04 Dec, 2022
Improve
Improve
Like Article
Like
Save
Share
Report

As we know, to set up communication between the two systems we have to configure the network which means we have to define system IP, DNS, and gateway the communication can be through either Ethernet, Wi-Fi, or Bluetooth. Therefore a Linux user must know about the Network Configuration of any Linux Operating system so that the user can resolve some internal or external connectivity issues

NetworkManager is a daemon that sits on top of “libudev” and other Linux kernel interfaces and provides a high-level interface for the configuration of the network interfaces. The network manager can be used to configure Ethernet, Wi-Fi, Mobile, DSL, and PPPoE connections. It can also be used to create, edit, and remove interfaces. 

Network Configuration without Network Manager

In spite of the benefits of the Network Manager, one should not use it on servers because it does not provide advanced configuration options, and also does not support some device types like ISDN, IPSec, etc.

1. Displaying Network Interfaces

To list and manipulate devices, routing, and tunnels the ip command is used. It is a tool used for configuring network interfaces. With the help of ip command, we can see the link-layer information of all available devices. Type the command below to see the information on all available devices.

ip link show

The output of ip link show

The above screenshot displays the following interfaces:

  1. Loopback(lo):  It is used to check for internal connections, not for outgoing connections.
  2. Ethernet(enp0s3): It is the network interface name in which “en” stands for ethernet, “p0” is the bus number of the ethernet card, and “s3” is the slot number.
  3. Virtual Bridge-0(virbr0):  It is an interface used for NAT (Network Address Translation). It is provided by the “libvirt” library. Virtual environments use it to connect to the outside network.
  4. Virtual Bridge-0 NIC(virbr0-nic): It acts as a bridge between the physical Network Card and the Virtual Machine’s virtual Network Card. 

The following are the functions of ip command:

  • Manage and display network interfaces
  • Monitor and manage IP addresses
  • Manage and display the IP routing table
  • Display and modify IP neighbor entries

2. Configure DHCP on an Interface

To configure a network for DHCP via the terminal follow the steps below:

Step 1: First of all list all the available network devices by typing the following command.

nmcli d

Listing all Network Devices

Step 2: Copy the name of the network that we want to configure for DHCP.

Step 3: Now open the network configuration file of the selected network interface in the nano text editor. Type the command below and just paste the name of the network at the end. 

nano /etc/sysconfig/network-scripts/ifcfg-[name-of-the-network]

Network Configuration File in Nano Editor

Step 4: Make sure that the value of BOOTPROTO is set to “dhcp” and ONBOOT is set to “yes” to enable the network when starting the system.

Step 5: Now add the network details such as IPADDR, NETMASK, GATEWAY, and DNS.

Network Configuration File in Nano Editor

The above screenshot displays the complete network configuration for DHCP.

Step 6: Now press Ctrl+O to save and Ctrl+X to exit.

Step 7: Now just restart the network by typing the following command.

systemctl restart

3. Configuring a Static IP

By modifying the network script, we can set up a static IP for the interface. The following are the steps for modification.

Step 1: First of all list all the available network devices by typing the following command.

nmcli d

 

Step 2: Copy the name of the network that we want to configure for DHCP.

Step 3: Now open the network configuration file of the selected network interface in the nano text editor. Type the command below and just paste the name of the network at the end.  

nano /etc/sysconfig/network-scripts/ifcfg-[name-of-the-network]

Step 4: Make sure that the value of BOOTPROTO is set to “static” to set a static IP for your network, and ONBOOT is set to “yes” to enable the network when starting the system.

Step 5: Now add the network details such as IPADDR, NETMASK, GATEWAY, and DNS. Multiple DNS can be added as well.

Network Configuration File in Nano Editor

The above screenshot displays the complete network configuration for setting up a static IP.

Step 6: Now press Ctrl+O to save and Ctrl+X to exit.

Step 7: Now just restart the network by typing the following command.

systemctl restart

Checking the Network Settings

After applying the changes to the network configuration file of a network interface we need to verify whether our network is working with the new settings or not. Type the command below to validate the network setting.

ip a show [name-of-the-network]

 

The above screenshot displays network interface information based on which we can verify that the applied changes are working.


Similar Reads

NTP Configuration in CentOS
NTP(Network Transfer Protocol) is a protocol that is used for the synchronization of time over a network. It provides the service of setting the current time on the client's request so that the client can set his clock on his system. There are three tiers of NTP servers: Tier 1: Connected to atomic clocks.Tier 2 and Tier 3: Carry the load of handli
3 min read
How to configure network interfaces in CentOS?
A network interface is a link between a computer and another network(Private or Public). The network interface is basically a card which is known as NIC or Network Interface Card, this does not necessarily have to be in a physical form instead, it can be inbuilt into the software. If we take the example of some loopback addresses such as 127.0.0.1(
5 min read
How to Add New Disk in Linux CentOS 7 Without Rebooting
Let's Say we hosted the DataBase on our Server Initially with 500GB given space and as we know Database should run 24/7 because the user's using it. One day it consumes space about 400GB only 100GB left Now we want to Increase the Space at the runtime only and In the case of static partitioning we need to restart the server but If we restart the se
3 min read
How to reset the root password of RedHat/CentOS Linux
RedHat Linux is a worldwide used OS in servers and networking devices. Red Hat lists Adobe, Ampersand and many among the top 500 fortune companies. They list Cisco, Dell, HP, and IBM as partners. Resetting the root password of RHEL is not a difficult task but rather you need to know 4 commands and you are into the root account! Root account in Linu
2 min read
How to Install Cockpit on Linux CentOS 7?
The cockpit is a free, open-source Linux Server Management Tool which provides you the facility to control your server using the mouse on the web-interface. The cockpit can be used to perform any server related task such as start containers, storage administration, and network configuration and much more. It has a very beautiful user interface alon
3 min read
How to Install CentOS
CentOS is a popular open-source Linux distribution aimed at servers and provides compatibility with Red Hat's RPM package manager. It is built with the goal of providing a stable operating system that provided great compatibility with the upstream RHEL (Red hat enterprise Linux) CentOS is therefore one of the best free Linux distributions to utiliz
2 min read
How to Upgrade Linux Kernel on CentOS 7
The kernel is a central component of an operating system that manages the operations of the computer and hardware. It basically manages operations of memory and CPU time. It is a core component of an operating system. Kernel acts as a bridge between applications and data processing performed at the hardware level using inter-process communication a
2 min read
How to Compile Linux Kernel on CentOS 7
The kernel is the core of a computer's operating system that has complete control over the system and provides basic services for all other parts. The default kernel available in any distribution cannot be customized. We cannot enable or disable any feature on it. Running a custom-compiled Linux Kernel becomes very helpful in cases when the hardwar
3 min read
How to Audit Linux Process Using ‘autrace’ on CentOS/RHEL
Autrace is a command line tool that is used for the purpose of auditing processes on Linux. The audit rules which are created by autrace are stored in the /var/www/audit/audit.log file. Before autrace can work perfectly all the previous audit logs must be deleted. The syntax of autrace is given below: Syntax: autrace -r program program-args Note: H
3 min read
Set up HAProxy as a load balancer for Nginx on CentOS
In this article, we are going to see how to set up HAProxy as a load balancer for Nginx on CentOS. What is Load balancing? Load balancing, commonly referred to as server farming or server pools is the process of efficiently dispersing incoming network traffic among a collection of backend servers. Modern high-traffic websites must quickly and relia
2 min read