How to Configure Networking on CentOS (7 & 8): An Expert’s Guide

configure networking on CentOS

A dedicated IP is literally an IP address that is only assigned to you, whereas a VPS, or Virtual Private Server, is a complete server with its own operating system, offering you full control over your hosting environment. When comparing dedicated IP vs VPS, it’s important to understand that they serve different purposes but work best together in professional hosting setups.

In real-world scenarios, especially when you configure networking on CentOS, both a VPS and a dedicated IP play a crucial role. A VPS provides the server environment where you manage network settings, applications, and security, while a dedicated IP ensures a unique identity for your server, improving reliability, email reputation, and secure access configurations.

Going a step further, having a dedicated IP also offers you the advantage of having your online presence exclusively linked to your own IP address, which is crucial when dealing with email services, websites, and other secure settings, such as SSL, without having to rely on a shared environment. As far as the dedicated IP vs VPS debate is concerned, having an IP ensures your unique identity and reputation, whereas having a VPS ensures that you have the best infrastructure and performance to run your applications in the most efficient way possible.

Deep Dive: How Networking Works in CentOS

CentOS relies on a layered networking architecture that ensures efficient communication between hardware, the operating system, and external networks. Understanding these layers helps you diagnose issues faster and build a more stable server environment.

Core Networking Layers

  • Kernel Level:
    The Linux kernel is responsible for low-level networking operations such as packet routing, traffic handling, and communication with network drivers. It processes incoming and outgoing packets using protocols like TCP/IP and ensures data reaches the correct destination.
  • Network Interfaces:
    These are the actual connection points, either physical (NICs) or virtual interfaces. Virtual interfaces are commonly used in VPS, containers, and cloud environments, allowing multiple isolated networks on a single physical machine.
  • NetworkManager:
    A powerful service that simplifies network configuration and management. It dynamically handles connections, detects network changes, and allows administrators to configure settings using tools like nmcli the command line and text UI.
  • Configuration Files:
    Persistent settings are stored in system files, ensuring configurations remain intact after reboots. In CentOS 7, these are typically found in /etc/sysconfig/network-scripts/CentOS 8 relies more on NetworkManager-managed profiles.

How Data Flows in CentOS Networking

When a request is made (for example, accessing a website):

  1. The application sends a request to the network stack
  2. The kernel processes the packet and determines the routing
  3. The packet is sent through the appropriate network interface
  4. DNS resolves the domain to an IP address
  5. The remote server responds, and the process reverses

This entire flow happens in milliseconds, making efficient configuration crucial for performance.

CentOS 7 vs CentOS 8 Networking Approach

  • CentOS 7:
    Supports both traditional network scripts and NetworkManager. Administrators can manually edit configuration files, offering more control but requiring deeper technical knowledge.
  • CentOS 8:
    Fully adopts NetworkManager as the default tool, providing a more modern, flexible, and automation-friendly approach. It reduces manual configuration errors and improves consistency across environments.

Role of Network Services

Virtualization and Networking

In VPS and cloud environments, networking becomes more abstract:

  • Virtual NICs are assigned to each VPS
  • Bridges connect virtual machines to physical networks
  • NAT (Network Address Translation) allows multiple systems to share public IPs

This is why understanding networking in CentOS is especially important for hosting environments.

Why This Architecture Matters

A clear understanding of CentOS networking architecture allows you to:

  • Troubleshoot connectivity issues quickly
  • Optimize server performance
  • Secure your infrastructure effectively
  • Scale your network for growing applications

Understanding Network Interface Naming

Modern Linux systems use predictable network interface names:

  • ens33 → Ethernet interface
  • enp0s3 → PCI-based interface
  • eth0 → Legacy naming

Check details:

ip link show

Static vs Dynamic IP: When to Use What

Static IP (Recommended for Servers)

  • Required for hosting websites and applications
  • Needed for DNS mapping
  • Ensures consistent access

Dynamic IP (DHCP)

  • Ideal for testing environments
  • Used in temporary setups
  • Automatically assigned

Advanced Static IP Configuration (Persistent)

In production environments, always verify persistence after reboot:

nmcli connection reload
nmcli connection show

Also, disable DHCP fallback:

nmcli con mod eth0 ipv4.never-default yes

Network Bonding for High Availability

Bonding combines multiple interfaces into one logical interface.

Benefits:

  • Fault tolerance
  • Increased throughput
  • Load balancing

Example:

nmcli con add type bond ifname bond0 mode balance-rr
nmcli con add type ethernet ifname eth0 master bond0
nmcli con add type ethernet ifname eth1 master bond0

Bridged Networking (For Virtualization)

Used when running virtual machines (KVM, VMware, etc.).

nmcli con add type bridge ifname br0
nmcli con add type ethernet ifname eth0 master br0

Use Case:

  • VPS hosting environments
  • Container networking
  • Cloud infrastructure

Advanced DNS Configuration

Instead of editing /etc/resolv.conf manually, configure DNS permanently:

nmcli con mod eth0 ipv4.dns "1.1.1.1 8.8.8.8"
nmcli con mod eth0 ipv4.ignore-auto-dns yes

Best DNS Providers:

  • Google DNS: 8.8.8.8
  • Cloudflare DNS: 1.1.1.1

Routing Configuration (Advanced)

To add a static route:

nmcli con mod eth0 +ipv4.routes "192.168.2.0/24 192.168.1.1"

View routes:

ip route show

Firewall and Network Security

CentOS uses firewalld for managing rules.

Open Ports:

firewall-cmd --add-port=8080/tcp --permanent
firewall-cmd --reload

Block IP Address:

firewall-cmd --add-rich-rule='rule family="ipv4" source address="192.168.1.10" reject'

SELinux and Networking

SELinux can restrict network services.

Check status:

getenforce

Allow HTTP connections:

setsebool -P httpd_can_network_connect 1

Performance Optimization Tips

  • Use ethtool to optimize NIC performance:
ethtool -K eth0 tso off gso off
  • Monitor bandwidth:
nload
  • Check latency:
ping -c 5 google.com
  • Analyze traffic:
tcpdump -i eth0

Pro Tips for Real-World Usage

  • Persistent setup: Always set ONBOOT=yes or autoconnect yes to ensure your network starts on boot.
  • Name consistency: Use labels like ENP0 and ENP1 for clarity when managing multiple interfaces.
  • Avoid conflicts: When using both nmcli and ifcfg files, make sure NetworkManager isn’t trying to do double duty.
  • Multiple gateways: To control traffic routes, use a route-eth1 file or nmcli connection modify … ipv4.route... metric. This is excellent for complex setups or failover networking.

Troubleshooting Table

ProblemResolution
The interface doesn’t start on bootCheck ONBOOT=yes or autoconnect yes
IP didn’t change after editingRun systemctl restart NetworkManager
DNS issuesDouble-check /etc/resolv.conf or DNS lines in ifcfg-*
Firewall interferenceUse firewall-cmd --list-all to ensure network zones and ports are open

Final Thoughts

Configuring networking on CentOS 7 and 8 is more than just assigning an IP address; it’s about building a stable, secure, and high-performance foundation for your server environment. From understanding core networking layers to implementing advanced configurations, mastering these skills allows you to take full control of your infrastructure.

By choosing the right configuration method (static or DHCP), using modern tools, and following best practices, you can ensure consistent connectivity, improved security, and scalable performance. Regular testing and monitoring further help in maintaining reliability and avoiding unexpected downtime.

FAQs

Q1: Should I stick with nmcli or scripts?
For automation and modern environments, nmcli it is the better choice. For simple, single-server setups, traditional network scripts can be easier to edit and manage.

Q2: What should I do if my interface name changes unexpectedly?
Update the interface name in your configuration file and reload NetworkManager using:
systemctl reload NetworkManager

Q3: What if I need IPv6 configuration?
You can configure IPv6 just like IPv4. For example, use ipv6.method auto for automatic assignment or manually define ipv6.addresses.

Q4: Can I apply network changes without restarting the server?
Yes, most changes can be applied by restarting the interface or NetworkManager without requiring a full system reboot.

Q5: How do I make network settings persistent after a reboot?
Ensure your configuration files or nmcli settings are saved properly and that NetworkManager is enabled to start on boot.

Q6: What is the difference between nmcli and nmtui?
nmcli It is a command-line tool ideal for scripting and automation, while nmtui provides a user-friendly text interface for quick manual configurations.

Q7: Why is my network not connecting after configuration?
This could be due to incorrect IP settings, gateway issues, DNS misconfiguration, or firewall restrictions. Always verify each parameter carefully.

Q8: How can I check if my network is working properly?
Use commands like ping, ip a, and ip route to verify connectivity, IP assignment, and routing.

Q9: Can I configure multiple IP addresses on one interface?
Yes, CentOS supports multiple IPs on a single interface, which is useful for hosting multiple services or websites.

Q10: Is NetworkManager required in CentOS 8?
Yes, CentOS 8 primarily relies on NetworkManager, and it is recommended to use it for all network configurations.

Suggestions:

  1. https://mainvps.net/blog/linux-reseller-hosting/
  2. https://mainvps.net/blog/lifetime-web-hosting-2026/
  3. https://mainvps.net/blog/windows-reseller-web-hosting/
  4. https://mainvps.net/blog/best-wordpress-hosting-providers/
  5. https://mainvps.net/blog/linux-vps-hosting-india/
  6. https://mainvps.net/blog/low-cost-windows-vps-hosting-in-india/
  7. https://mainvps.net/blog/cheap-dedicated-server-hosting-providers/
  8. https://mainvps.net/blog/windows-server-guide-dde-dns-tls-1-2-uptime/
  9. https://mainvps.net/blog/dedicated-server-hosting-netherlands/
  10. https://mainvps.net/blog/dedicated-server-low-price/
  11. https://mainvps.net/blog/vps-hosting-in-los-angeles-us/
  12. https://mainvps.net/blog/dedicated-server-in-nedzone-nl/
  13. https://mainvps.net/blog/buy-linux-vps-hosting/
  14. https://mainvps.net/blog/managed-windows-vps-hosting/
  15. https://mainvps.net/blog/host-foundry-on-ubuntu-server/
  16. https://mainvps.net/blog/what-is-wmi-provider-host-complete-guide/