Operations 15 min read

Master Linux Network Configuration: From IP Setup to Netplan and NetworkManager

This guide explains Linux network management, covering IP address and routing configuration, interface naming rules, GRUB tweaks for CentOS and Ubuntu, file‑based setups for CentOS 7, Ubuntu 16.04, Ubuntu 18.04+ with netplan, and graphical configuration via NetworkManager, plus service differences.

MaGe Linux Operations
MaGe Linux Operations
MaGe Linux Operations
Master Linux Network Configuration: From IP Setup to Netplan and NetworkManager

Network Configuration

Network configuration process

1. User‑space tools configure IP address, netmask, routes, etc., then invoke system calls to pass the information to the kernel.

2. The kernel stores the received configuration in its network‑stack data structures (e.g., device structures for IP address, netmask).

3. During communication the kernel looks up the interface name (eth0, wlan0, …) to select the appropriate driver, which converts kernel packets to the proper format and sends them through the physical NIC.

Network‑interface naming rules

ethX naming (eth0, eth1…) was deprecated because the name could change with boot order.

Hardware‑based names such as ensX (e.g., ens33) or enpXsY (e.g., enp2s0).

MAC‑address based names: enx…

Hardware‑path names: enoX, ensX, etc.

The actual name of a NIC on a Linux host is defined by udev rules under /lib/udev/rules.d/.

If you prefer the old ethX naming, you can disable the new scheme via the GRUB configuration.

If using CentOS

1. Edit the GRUB configuration file

sudo vim /etc/default/grub

2. Modify the kernel command line

# modify this line
GRUB_CMDLINE_LINUX="spectre_v2=retpoline rhgb quiet net.ifnames=0"

3. Generate a new GRUB configuration

# CentOS uses grub2
grub2-mkconfig -o /boot/grub/grub.cfg   # or update-grub

4. Reboot the system

sudo reboot

If using Ubuntu

1. Edit the GRUB configuration file

sudo vim /etc/default/grub

2. Modify the kernel command line

# modify this line
GRUB_CMDLINE_LINUX="net.ifnames=0"

3. Regenerate the GRUB configuration sudo grub-mkconfig -o /boot/grub/grub.cfg 4. Reboot the system

sudo reboot

Configure network via configuration files

This method is typically used on headless Linux systems.

CentOS 7 network configuration

Modify the interface file under /etc/sysconfig/network-scripts/ifcfg-IFACE and restart the appropriate service.

1. Edit the configuration file

# configuration file path: /etc/sysconfig/network-scripts/ifcfg-IFACE
# the name can be arbitrary, but using the same name as the NIC simplifies management

2. Add required variables

TYPE – device type (e.g., Ethernet, Bridge)

NAME – descriptive name, usually same as the NIC name

DEVICE – kernel device name (eth0, ens33, …)

BOOTPROTO – address acquisition method (dhcp, static, none, bootp)

IPADDR – IPv4 address

NETMASK – subnet mask in dotted decimal

PREFIX – CIDR prefix (alternative to NETMASK)

GATEWAY – default gateway

ONBOOT – activate on boot (yes/no)

DNS1, DNS2 – primary and secondary DNS servers

Example: static IP configuration

TYPE="Ethernet"
BOOTPROTO="none"
NAME="eth0"
DEVICE="eth0"
ONBOOT="yes"
IPADDR="10.0.0.7"
PREFIX="24"
GATEWAY="10.0.0.2"
DNS1="180.76.76.76"

Example: dynamic IP configuration

TYPE="Ethernet"
BOOTPROTO="dhcp"
NAME="eth0"
DEVICE="eth0"
ONBOOT="yes"

3. Restart the network service to apply changes

CentOS 6: service network restart CentOS 7: systemctl restart network (or systemctl restart NetworkManager.service for NetworkManager)

CentOS 8:

systemctl restart NetworkManager.service

Ubuntu 16.04 network configuration

Primary file: /etc/network/interfaces Static IP example

auto eth0
iface eth0 inet static
    address 192.168.1.10
    netmask 255.255.255.0
    gateway 192.168.1.1
    dns-nameserver 180.76.76.76

Dynamic IP example

auto eth0
iface eth0 inet dhcp

Restart networking service

sudo systemctl restart networking

Ubuntu 18.04 and later (netplan)

Network is configured via YAML files under /etc/netplan/. The renderer key selects the backend (networkd or NetworkManager).

Static IP example (networkd renderer)

network:
  version: 2
  renderer: networkd
  ethernets:
    eth0:
      addresses:
        - 192.168.8.10/24
        - 10.0.0.10/8
      gateway4: 10.0.0.2
      nameservers:
        addresses:
          - 180.76.76.76
          - 8.8.8.8
          - 1.1.1.1

Dynamic IP example

network:
  version: 2
  renderer: networkd
  ethernets:
    eth0:
      dhcp4: yes

Apply the configuration sudo netplan apply When renderer: NetworkManager is used, Netplan forwards the configuration to NetworkManager; when renderer: networkd is used, it is handled by systemd‑networkd.

Graphical network configuration

Desktop‑oriented distributions use NetworkManager. GUI tools modify connections that are stored in /etc/NetworkManager/system-connections/.

Ubuntu 16.04 GUI steps (illustrated)

Open System Settings from the top‑right corner.

Select “Network”.

Choose the wired connection.

Click “Options” to edit IP settings.

Ubuntu 18.04 GUI configuration file

When using the GUI, Netplan creates /etc/netplan/01-network-manager-all.yaml with the following content:

network:
  version: 2
  renderer: NetworkManager

Difference between network and NetworkManager

network service – traditional init scripts that configure interfaces.

NetworkManager daemon – modern background service that manages connections, suitable for desktops and mobile devices.

CentOS 6 used the network service by default; CentOS 7 switched to NetworkManager while keeping the network service available; CentOS 8 removed the network service entirely. Ubuntu has used NetworkManager for many years, but still supports legacy /etc/network/interfaces for compatibility.

LinuxSystem AdministrationNetwork ConfigurationCentOSUbuntuNetworkManagerNetplan
MaGe Linux Operations
Written by

MaGe Linux Operations

Founded in 2009, MaGe Education is a top Chinese high‑end IT training brand. Its graduates earn 12K+ RMB salaries, and the school has trained tens of thousands of students. It offers high‑pay courses in Linux cloud operations, Python full‑stack, automation, data analysis, AI, and Go high‑concurrency architecture. Thanks to quality courses and a solid reputation, it has talent partnerships with numerous internet firms.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.