Comprehensive Guide to Network Card Configuration in Linux: Covering Mainstream and Domestic Systems

This article will provide a detailed explanation of the network card configuration methods for major mainstream Linux distributions and domestic operating systems (such as UOS and Kylin), along with an in-depth analysis of each configuration parameter to help you master various configuration formats.

Comprehensive Guide to Network Card Configuration in Linux: Covering Mainstream and Domestic Systems

[Special Note] Most domestic operating systems such as Tongxin UOS, Kylin V10, and openEuler are developed based on mainstream Linux distributions, and their network card configuration methods are similar to their underlying systems, which will be specifically noted below.

Comprehensive Guide to Network Card Configuration in Linux: Covering Mainstream and Domestic SystemsComprehensive Guide to Network Card Configuration in Linux: Covering Mainstream and Domestic SystemsComprehensive Guide to Network Card Configuration in Linux: Covering Mainstream and Domestic Systems

1. Detailed Configuration for CentOS/RHEL Series

1.1 CentOS6/RHEL6: Classic ifcfg File Configuration

Configuration File Location:

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

Core Parameter Explanation:

DEVICE=eth0              # Network interface identifier, must match the actual device name
HWADDR=00:0C:29:3E:53:7E # Device MAC address (optional), used to bind to specific hardware
TYPE=Ethernet            # Network connection type, generally Ethernet
UUID=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx # Device unique identifier (optional)

ONBOOT=yes               # Whether to start with the system, yes for automatic enablement
BOOTPROTO=static         # Network configuration method: static, dhcp, none
IPADDR=10.0.0.100        # Fixed IP address
NETMASK=255.255.255.0    # Network mask
GATEWAY=10.0.0.2         # Network gateway
DNS1=8.8.8.8             # Primary DNS server
DNS2=114.114.114.114     # Secondary DNS server

Application Configuration Command:

service network restart

1.2 CentOS7/RHEL7: Transition Configuration Between Traditional and Modern

Configuration File Location:

/etc/sysconfig/network-scripts/ifcfg-ens33

In this version, the network card name adopts a predictable network naming mechanism (predictable network names), such as ens33, enp0s3, etc.

Main Configuration Content:

TYPE=Ethernet           # Network type
BOOTPROTO=none          # Protocol type, none is synonymous with static
NAME=ens33              # Connection name
DEVICE=ens33            # Device name, must match the actual network card
ONBOOT=yes              # Automatically start the network card on boot
IPADDR=10.0.0.100       # Static IP address
PREFIX=24               # Subnet prefix length (equivalent to 255.255.255.0)
GATEWAY=10.0.0.2        # Default gateway address
DNS1=8.8.8.8            # Primary DNS server
DNS2=1.1.1.1            # Secondary DNS server

Configuration Activation Command:

systemctl restart network

1.3 CentOS8/RHEL8/RHEL9: Modern Network Management Tools

This version recommends using <span>nmcli</span> or <span>nmtui</span> for configuration (while retaining support for ifcfg files).

Using nmcli Tool to Configure Static IP:

nmcli con add con-name <connection name> ifname <network card name> type <connection type> ipv4.method manual ipv4.addresses <IP address/mask> ipv4.gateway <gateway address> ipv4.dns <DNS server>

nmcli con mod static-ens33 ipv4.dns "8.8.8.8 1.1.1.1"
nmcli con mod static-ens33 ipv4.method manual
nmcli con up static-ens33
nmcli con down static-ens33 

Parameter Explanation:

  • <span>con-name</span>: Custom connection identifier name
  • <span>type</span>: Network type, common types include ethernet, wifi, etc.
  • <span>ifname</span>: Actual network card interface name
  • <span>ipv4.addresses</span>: IP address and mask prefix
  • <span>ipv4.gateway</span>: Gateway address
  • <span>ipv4.dns</span>: DNS server list
  • <span>ipv4.method manual</span>: Manual configuration mode

Additionally, <span>nmtui</span><span> provides an interactive graphical interface, suitable for users unfamiliar with the command line.</span>

2. Configuration Methods for Debian/Ubuntu Series

2.1 Ubuntu 16.04 and Debian Versions Before 9

Configuration File Location:

/etc/network/interfaces

Configuration Example and Parameter Analysis:

auto eth0                  # eth0 interface starts automatically with the system
iface eth0 inet static     # Define eth0 as static IPv4 configuration, choose dhcp if no further configuration is needed
    address 10.0.0.100     # Static IP address
    netmask 255.255.255.0  # Subnet mask
    gateway 10.0.0.2       # Default gateway
    dns-nameservers 8.8.8.8 114.114.114.114  # DNS server list

Apply Configuration:

sudo systemctl restart networking

2.2 Ubuntu 18.04+/Ubuntu 20.04+/Ubuntu 22.04+/Debian 10+/Debian 11+/Debian 12+: YAML Format Configuration

Configuration File Location:

/etc/netplan/01-netcfg.yaml

These versions use YAML format configuration, with strict requirements for indentation and format specifications.

YAML Configuration Example:

network:
  version: 2                # netplan syntax version, fixed to 2
  renderer: networkd        # Renderer selection, optional networkd or NetworkManager
  ethernets:
    ens33:                  # Network card interface name
      dhcp4: no             # Disable DHCP automatic acquisition
      addresses:
        - 10.0.0.100/24     # IP address and mask prefix
      gateway4: 10.0.0.2    # Default gateway
      nameservers:
        addresses:
          - 8.8.8.8         # Primary DNS
          - 223.5.5.5       # Secondary DNS

Configuration Activation Command:

sudo netplan apply

3. Configuration for Domestic Operating Systems

3.1 Tongxin UOS System (Based on Debian)

Tongxin UOS is a domestic operating system developed based on Debian, and its network card configuration method is the same as Debian.

Desktop Version UOS (V20/Home/Professional):

# Configuration file path: /etc/netplan/01-network-manager-all.yaml
# Configuration format is completely consistent with Ubuntu 18.04+/Debian 10+

network:
  version: 2
  renderer: NetworkManager
  ethernets:
    enp3s0:
      dhcp4: no
      addresses: [192.168.1.100/24]
      gateway4: 192.168.1.1
      nameservers:
        addresses: [114.114.114.114, 8.8.8.8]

Server Version UOS: Same configuration as the professional version, but the default renderer is usually set to networkd.

3.2 Zhongbiao Kylin System

3.2.1 Zhongbiao Kylin V7/Galaxy Kylin V10 (Based on CentOS/RHEL 7)

Configuration File Path:

/etc/sysconfig/network-scripts/ifcfg-eno1

Configuration content is identical to CentOS 7, using ifcfg file format.

3.2.2 Galaxy Kylin V4 (Based on Debian)

Configuration File Path:

/etc/network/interfaces

Format is the same as Debian 9 and earlier versions.

3.3 OpenEuler (Huawei Open Source)

OpenEuler is a server operating system open-sourced by Huawei, based on CentOS architecture:

OpenEuler 20.03+: Configuration method is completely consistent with CentOS 8, recommending the use of nmcli tool and NetworkManager.

# Example of using nmcli configuration
nmcli con add con-name static-eno1 ifname eno1 type ethernet ipv4.method manual ipv4.addresses 192.168.1.100/24 ipv4.gateway 192.168.1.1 ipv4.dns "114.114.114.114 8.8.8.8"
nmcli con up static-eno1

Traditional ifcfg file configuration is also supported.

3.4 Deepin Operating System

Deepin 20+ (Based on Debian): Uses the same netplan configuration method as Debian 10+.

# Configuration file path: /etc/netplan/01-network-manager-all.yaml
network:
  version: 2
  renderer: NetworkManager
  ethernets:
    enp0s3:
      dhcp4: no
      addresses: [192.168.1.100/24]
      gateway4: 192.168.1.1
      nameservers:
        addresses: [114.114.114.114, 8.8.8.8]

4. General Temporary Configuration Methods

The following <span>ip</span> commands are applicable to all Linux distributions (including domestic systems) and are commonly used for temporary testing:

ip addr add 192.168.1.100/24 dev ens33  # Add temporary IP
ip link set ens33 up                    # Enable network card
ip route add default via 192.168.1.1    # Set temporary default route

⚠️ Note: This configuration will be lost after a reboot and is only suitable for temporary testing.

5. Configuration Method Comparison Table for Various Versions

System Version Configuration Method Configuration File or Tool
CentOS/RHEL 6 ifcfg <span><span>/etc/sysconfig/network-scripts/ifcfg-*</span></span>
CentOS/RHEL 7 ifcfg + NetworkManager Same as above + <span><span>nmcli</span></span> / <span><span>nmtui</span></span>
CentOS/RHEL 8/9 Recommended NetworkManager <span><span>nmcli</span></span> / Optional ifcfg file
Ubuntu 16.04 interfaces <span><span>/etc/network/interfaces</span></span>
Ubuntu 18.04/20.04/22.04 netplan <span><span>/etc/netplan/*.yaml</span></span>
Debian 9 and earlier interfaces <span><span>/etc/network/interfaces</span></span>
Debian 10/11/12 netplan <span><span>/etc/netplan/*.yaml</span></span>
Tongxin UOS netplan <span><span>/etc/netplan/*.yaml</span></span>
Galaxy Kylin V10 ifcfg <span><span>/etc/sysconfig/network-scripts/ifcfg-*</span></span>
Galaxy Kylin V4 interfaces <span><span>/etc/network/interfaces</span></span>
OpenEuler NetworkManager <span><span>nmcli</span></span> / Optional ifcfg file
Deepin 20+ netplan <span><span>/etc/netplan/*.yaml</span></span>

General Network Card Status Viewing Commands:

ifconfig    # Traditional command, applicable to all Linux systems
ip addr     # Modern command, more powerful

Above are the comprehensive network card configuration methods for mainstream Linux distributions and domestic operating systems. Mastering this knowledge will allow you to navigate any Linux environment with ease!

If you like it, please like and follow, more Linux technical content will be continuously updated~

Deep insights, DeepSeek one-click data analysis reconstruction!

Learn AI filmmaking in one book!

– EOF –Recommended Reading Click the title to jump

1. Don’t Touch! The Top Ten Taboo and Emergency Self-Rescue Manual for Server Operations

2. Mining Virus Disposal (Linux Edition) – From Entry to Abandonment

3. Ansible Batch Adding Crontab to 100 Servers

4. How to List USB Devices in Linux

5. Eight Recommended Linux Remote Connection Tools, Very Practical

6. 35 Commonly Used Frontline Operation and Maintenance Shell Scripts Reorganized (Classic)

7. Linux Troubleshooting Ideas and Common Commands (Collection)

Did you gain something from this article? Please share it with more people

Recommended to follow “Linux Operation and Maintenance Advancement Road” to enhance Linux skills

Comprehensive Guide to Network Card Configuration in Linux: Covering Mainstream and Domestic Systems❤️Like & Watch❤️, Server uptime for three years

Leave a Comment