[Network] There is no network port file under /etc/sysconfig/network-scripts/|The difference between network and NetworkManager

Table of contents

Table of contents

The difference between network and NetworkManager

The conflict between network and NetworkManager

RHEL 9 bids farewell to network.service and embraces NetworkManager (the reason why there is no network port file under /etc/sysconfig/network-scripts/)

detail

How to change interface settings

What happened to ifcfg-rh?

CentOS7 uses nmcli and nmtui to configure the network IP address, the default is to generate the network configuration file, in the network-scripts folder


The difference between network and NetworkManager

 The default network service in versions above RHEL7/CentOS 7 is provided by NetworkManager (referred to as NM), which is a daemon process for dynamically controlling and configuring the network. It is used to keep the current network devices and connections in working condition, and also supports the traditional ifcfg type of configuration file.

NetworkManager can configure network aliases, IP addresses, static routes, DNS, VPN connections, and many other special parameters. NetworkManager can be controlled with the command line tool nmcli. The function of nmcli is more powerful and complex than that of ifconfig.
nmcli is the NetworkManager tool of the command line, which automatically writes the configuration to the /etc/sysconfig/network-scripts/ directory. The network management before RHEL7 and CentOS 7 is to configure the management interface (device) through the ifcfg file, but now it is to manage the connection (connection) through the NetworkManager service.

An interface (device) can have multiple connections (connection), but only one connection (connection) is allowed to be active at the same time. But there is a problem. After restarting the server, the connection is activated by default. I haven't found any relevant information. If it is a server, it is suggested that one network port is used for one connection.
A simple understanding is that a connection is a configuration file in the /etc/sysconfig/network-scripts/ directory, and an interface (device) is a physical device. A physical setting can have multiple configuration files, but only one The configuration file belongs to the use (active) state; the generation and use state of the configuration file are controlled by NetworkManager. Of course, the ifcfg file configuration management network is still supported, but it is not recommended.


Typical uses include:
Scripts: Leverage NetworkManager via nmcli instead of manually managing network connections. nmcli supports a concise output format more suitable for script processing. Note that NetworkManager can also execute scripts called "scheduler scripts" in response to network events.
Servers, headless machines, and terminals: nmcli can be used to control NetworkManager without a GUI, including creating, editing, starting and stopping network connections, and viewing network status.

Original link: https://blog.csdn.net/qq_50573146/article/details/126797116

NetworkManager service

NetworkManager must remain open when using nmcli.
Related commands of NetworkManager:

systemctl status NetworkManager View running status
ystemctl start NetworkManager Start
ystemctl restart NetworkManager Restart
systemctl stop NetworkManager Close
systemctl is-enabled NetworkManager Check whether to start
systemctl enable NetworkManager Start
systemctl disable NetworkManager Disable booting
 

The conflict between network and NetworkManager

Conflicts arise when network and NetworkManager work together

Network card solves the conflict between network and NetworkManager - BiGpeng's Blog - CSDN Blog

After centos8, the default is to use NetworkManager to manage the network, and after centos9, the network is completely abandoned.

NetworkManage is similar to the function of network, both are used to manage the network. NetworkManage provides two tools, nmctl and nmtui, both of which are used to manage the network, but there is a premise: the nmctl networking status must be enabled, otherwise the device status is unmanaged, which will cause the network to fail to start! ! ! !
View as follows

[root@master03 ~]# nmcli networking
enabled

Solution
When the network cannot be started, check whether there is a problem with the configuration. If it is a server (multiple network ports), check whether the network cable is plugged into the network port you started and check whether your NetworkManage is started. If it is started, you can refer to the
method The solution
is simple and rude: close the NetworkManage service, and cancel the startup (if you use the bit command line mode and there is no useful graphical interface, you can use this method with confidence. If you use the graphical interface, it is recommended to check it yourself) Troubleshooting NetworkManage: -
Check
nmctl Whether the networking status is enabled, if not, execute the command to enable it

[root@master03 ~]# nmcli networking on
[root@master03 ~]# systemctl restart NetworkManager
[root@master03 ~]# systemctl restart network

[root@master03 ~]# nmcli device
DEVICE   TYPE      STATE      CONNECTION
ens33    ethernet  connected  ens33
docker0  bridge    unmanaged  --
lo       loopback  unmanaged  --
[root@master03 ~]#
insert image description here

- Check if the connection is enabled

[root@master03 ~]# nmcli connection
NAME   UUID                                  TYPE      DEVICE
ens33  4d574cba-a63e-49ae-8cb2-d663a8dd796e  ethernet  ens33

if not enabled

insert image description here

Note: My connection name is ens33, edit it according to your own situation, and execute after all operations are completed
[root@master03 ~]# systemctl restart NetworkManager
[root@master03 ~]# systemctl restart network
Otherwise it may not take effect
 

Original link: https://blog.csdn.net/weixin_41539438/article/details/120994954

RHEL 9 bids farewell to network.service and embraces NetworkManager (the reason why there is no network port file under /etc/sysconfig/network-scripts/)

Network configuration for RHEL 9: goodbye ifcfg configuration file, hello keyfile

NetworkManager saves the new network configuration in key-file format to /etc/NetworkManager/system-connections/

Starting with RHEL 9.0, RHEL stores new network configurations in /etc/NetworkManager/system-connections/ in key-file format. Connections whose configuration is stored in /etc/sysconfig/network-scripts/ in the old format will still work fine. Modifications to existing configuration sets will continue to update older files.

detail

In RHEL 9, ifcfg (also known as file) will no longer be the main storage for network configuration files. While the ifcfg style is still available, it is no longer the default location for NetworkManager to store new network configuration files.

Let's see:
/etc/sysconfig/network-scripts ifcfg

# NetworkManager --print-config

# NetworkManager configuration: /etc/NetworkManager/NetworkManager.conf (etc: 20-keyfiles.conf, sdn.conf)

[main]
# plugins=keyfile,ifcfg-rh
# rc-manager=auto
# auth-polkit=true
# dhcp=internal
# iwd-config-path=
dns=none
configure-and-quit=no

[keyfile]
path=/etc/NetworkManager/system-connections

[logging]
# backend=journal
# audit=false

[device]
# wifi.backend=wpa_supplicant
match-device=interface-name:br-int;interface-name:br-local;interface-name:br-nexthop,interface-name:ovn-k8s-*,interface-name:k8s-*;interface-name:tun0;interface-name:br0;interface-name:ovn0;interface-name:mirror0;driver:veth
managed=0

[device]
# wifi.backend=wpa_supplicant
match-device=interface-name:br-int;interface-name:br-local;interface-name:br-nexthop,interface-name:ovn-k8s-*,interface-name:k8s-*;interface-name:tun0;interface-name:br0;interface-name:ovn0;interface-name:mirror0;driver:veth
managed=0

# no-auto-default file "/var/lib/NetworkManager/no-auto-def

This refers to different storage locations such as "keyfile" and "ifcfg-rh". It first looks for the keyfile file and then for the ifcfg-rh file. You can find details about key files in the NetworkManager documentation and the RHEL 9 documentation. NetworkManager looks for key files in various places, but this article focuses on the files in .
/etc/NetworkManager/system-connections

With the default configuration, you can
continue to use the ifcfg-rh file in /etc/sysconfig/network-scripts, but you need to pay attention to:

  • In the default configuration, NetworkManager will prioritize critical files. For example, if both the keyfile and the ifcfg file have an interface configuration with the same UUID, NetworkManager will use the keyfiles configuration for that interface.

  • When creating a new network interface configuration using the tools of the NetworkManager API, such as nmcli, nmtui, gnome-control-center, anaconda, cockpit, nmstate, RHEL System Role for networking or network-manager-applet, they will use the keyfiles file for configuration .

Although the ifcfg- and key-file formats do not have the same syntax, they primarily represent similar data about interface configuration. Here is a comparison of the two formats:

How to change interface settings

Regardless of whether you decide to continue using ifcfg-rh files (although not recommended) or keyfiles, you can change interface settings (such as IP) by either:

  • Tool-based : You can use graphical tools such as the nm connection editor or the "nmcli" command-line tool. One advantage is that these tools allow you to check the syntax of commands compared to modifying files directly. You can find some good examples in, for example: man nmcli

nmcli con mod enp2s0 ipv4.addr "10.0.0.4/24"nmcli con down enp2s0nmcli con up enp2s0

  • File-based : You can also use a text editor to edit the keyfiles file in or the ifcfg-rh file in , and then notify NetworkManager of the changes. For example: /etc/NetworkManager/system-connections/etc/sysconfig/network-connections

vi /etc/NetworkManager/system-connections/<name>.nmconnectionnmcli connection load \  /etc/NetworkManager/system-connections/<name>.nmconnectionnmcli connection up filename \  /etc/NetworkManager/system-connections/<name>.nmconnection

The "nmcli connection load [..]" command will reload only one specific NetworkManager configuration file; alternatively, you can use the command "nmcli connection reload" to reload all configuration files, or the "nmcli general reload" command to reload set; this behaves like Network Manager's signal hangup (SIGHUP).

What happened to ifcfg-rh?

Historically, various Linux distributions have spread out the interface configuration in many places: traditionally used by Debian and its derivatives, used by CentOS and related distributions, and so on. With more and more distributions adopting NetworkManager, keyfiles have become the canonical location for networking on Linux. /etc/network/interfaces,
/etc/sysconfig/network-scripts, /etc/NetworkManager/system-connections

This change landed in Fedora 33, and now it's in RHEL 9. A new major release of RHEL (like RHEL 9) is where breaking changes like this can be implemented that can break existing scripts and workflows. Since RHEL's current plan is to deliver 10-year minor releases, it's wise to familiarize yourself with this change and start incorporating it into the code.

https://www.redhat.com/en/blog/rhel-9-networking-say-goodbye-ifcfg-files-and-hello-keyfiles

CentOS7 uses nmcli and nmtui to configure the network IP address, the default is to generate the network configuration file, in the network-scripts folder
 

(Reposted from: https://blog.csdn.net/kfepiza/article/details/127582327)

nmcli and nmtui are the commands attached to NetworkManager.
NetworkManager is a project launched by RedHat in 2004. They both allow Linux users to more easily handle modern network requirements, especially wireless networks, which can automatically discover network cards and configure IP addresses.

Both network.service and NetworkManager.service (NM for short) are supported on RHEL7 and CentOS7. Both services are enabled by default

Most of the Linux GUIs have enabled the NetworkManager.service service

In CentOS9, Fedora36, Ubuntu20, 22, etc., the network configuration files generated by nmcli ca and nmtui default to
xxx.nmconnection in the /etc/NetworkManager/system-connections/ folder.
However, in CentOS7, nmcli ca and nmtui generate The network configuration file defaults to
ifcfg-xxx in the /etc/sysconfig/network-scripts/ folder

Create a configuration named nm010 with nmtui and a configuration file named nmcli010 with nmcli
They are generated in the /etc/sysconfig/network-scripts/ folder

insert image description here

The configuration file name is related to the connection name, but after the configuration file is generated, if the connection name is modified, the configuration file name will not change

Corresponding content, (the content is available, but not standardized, only for demonstration)

insert image description here
correspond

TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=dhcp
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=ens33
UUID=477861f3-1631-4167-8540-e3dacd41698d
DEVICE=ens33
ONBOOT=yes
IPADDR=10.7.9.1
PREFIX=8
GATEWAY=10.82.10.12
DNS1=119.29.29.29
DNS2=114.114.114.114
DNS3=8.8.8.8
DNS4=9.9.9.9
DNS5=8.8.4.4
IPV6_PRIVACY=no
DOMAIN="qq.com ens33.ifcfg.network"
PEERDNS=no
IPADDR1=10.7.9.2
PREFIX1=16
IPADDR2=10.7.9.3
PREFIX2=24
DNS6=4.2.2.2
DNS7=1.1.1.1

The above ifcfg-ens33is there from the beginning, by nmtuimodifying


This is nmtuigenerated with

insert image description here

TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=none
IPADDR=10.7.9.1
PREFIX=24
IPADDR1=10.7.9.2
PREFIX1=24
GATEWAY=10.82.10.12
DNS1=180.76.76.76
DNS2=223.6.6.6
DNS3=119.29.29.29
DNS4=8.8.8.8
DNS5=9.9.9.9
DNS6=1.1.1.1
DNS7=223.5.5.5
DNS8=4.2.2.2
DNS9=4.2.2.1
DOMAIN="baidu.com nmtui010.nmtui"
DEFROUTE=yes
PEERDNS=no
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=nmtui010
UUID=95e52ced-7beb-4e67-90a6-e0bfe74e2686
DEVICE=ens33
ONBOOT=yes

This is nmcligenerated using
 

insert image description here

TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=dhcp
IPADDR=10.7.9.1
PREFIX=8
IPADDR1=10.7.9.2
PREFIX1=8
IPADDR2=10.7.9.3
PREFIX2=8
GATEWAY=10.82.10.12
DNS1=119.29.29.29
DNS2=223.6.6.6
DNS3=180.76.76.76
DNS4=8.8.8.8
DNS5=9.9.9.9
DNS6=1.1.1.1
DNS7=114.114.114.114
DOMAIN="qq.com nmcli010"
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=nmcli010
UUID=61dd866f-9b96-4181-a130-2039c2e20b99
DEVICE=ens33
ONBOOT=yes

 The files generated by nmtui and nmcli of CentOS9 attached to a CentOS9Stream
are not in the /etc/sysconfig/network-scripts/ folder but in the /etc/NetworkManager/system-connections/ folder, and the file name is not ifcfg-xxx but
xxx.nmconnection
insert image description here

Corresponding xxx.nmconnection

[connection]
id=nmtui010
uuid=99b644f2-c647-44c4-a444-fd7e3652bdf2
type=ethernet
interface-name=ens33

[ethernet]

[ipv4]
address1=10.9.1.1/8,10.82.10.12
address2=10.9.1.2/8
address3=10.9.1.3/8
dns=223.6.6.6;180.76.76.76;119.29.29.29;8.8.8.8;9.9.9.9;1.1.1.1;114.114.114.114;4.2.2.2;4.2.2.1;223.5.5.5;
dns-search=alibaba.com;nmtui010;
ignore-auto-dns=true
method=manual

[ipv6]
addr-gen-mode=stable-privacy
method=auto

[proxy]

Guess you like

Origin blog.csdn.net/bandaoyu/article/details/128156634