Overview
This topic describes the impacts of using traditional network script network services and systemd-networkd network services, and how to change the related configuration of instances running Alibaba Cloud Linux 2.
Background information
Please note the following points.
Before performing high-risk operations such as changing instance settings or data, it is recommended to verify the disaster recovery and fault tolerance capabilities of the instance to ensure data security.
You can change the settings and data of instances, including ECS (Elastic Compute Service) and ApsaraDB RDS instances. It is recommended to create snapshots or enable RDS log backup before changing instance settings or data.
If you authorize or submit sensitive information such as login accounts or passwords in the Alibaba Cloud Management Console, it is recommended to change the information in a timely manner.
Network services used by Alibaba Cloud Linux 2 instances
By default, the network services of instances using the following versions of Alibaba Cloud Linux 2 images are switched from systemd-networkd to network scripts to improve compatibility with configuration habits. Existing instances running Alibaba Cloud Linux 2 use the systemd-networkd network configuration mode because these existing instances cannot automatically switch their network services. For more information on how to switch the network services of existing instances running Alibaba Cloud Linux 2 to network-scripts network services, see the section "How to switch network services from systemd-networkd to network-scripts" in this topic.
Base image: aliyun_2_1903_x64_20G_alibase_20210208.vhd
AMD-compatible image: aliyun_2_1903_x64_20G_uefi_alibase_20210218.vhd
Local image: aliyun_2_1903_x64_20G_nocloud_alibase_20210218.vhd
Trusted image: aliyun_2_1903_x64_20G_secured_alibase_20210218.vhd
Quick start image: aliyun_2_1903_x64_20G_qboot_alibase_20210218.vhd
MLPS 2.0 Level 3 image: aliyun_2_1903_x64_20G_dengbao_alibase_20210218.vhd
How to switch network services from systemd-networkd to network-scripts
Impacts of switching network services
Impact on existing instances When purchasing a new instance, the network configuration mode of existing instances differs from that of the new instance. It is recommended to switch the network services of existing instances from systemd-networkd to network-scripts.
Impact on startup speed
Instances configured with traditional network script network services use shell scripts to configure the network. This reduces execution efficiency. If no special settings are applied to the network interface controller (NIC) of these instances, they take 2 to 4 seconds longer to start during the instance startup process from instance creation to instance login using SSH compared to instances configured with systemd-networkd network services.
If you cannot accept lower startup speed and can accept network configuration modes incompatible with network scripts, you can switch to systemd-networkd by going to the section "How to switch network services from network-scripts to systemd-networkd" in this topic. For more information on issues related to systemd-networkd, see the section "Common issues and solutions for systemd-networkd" in this topic.
Impact on the path of network configuration files Before switching network services, the original path is
/etc/systemd/network
. If you switch network services to network-scripts, you need to revert to the traditional path/etc/sysconfig/network-scripts/
. For more information on the differences in configuration items between the two configuration files, see the section "Differences in configuration items between network-scripts and systemd-networkd" in this topic.Impact on network service restart commands
For instances configured with systemd-networkd, run the following command to restart the network service:
sudo systemctl restart systemd-networkd
For instances configured with network scripts, run the following command to restart the network service:
sudo systemctl restart network
Switching network services of existing instances to network-scripts
Before performing the following operations, ensure that you understand the impacts of switching network services.
Note: The following operations involve network configuration. Accidental operations may cause network disconnection. To avoid data security and network risks caused by accidental operations, create a snapshot of the system disk of the Linux instance. For more information on how to create snapshots, see "Creating disk snapshots".
Run the following command to complete the configuration based on whether the original
resolv.conf
configuration file is retained.If the original
resolv.conf
configuration file is retained, perform the following operations.Run the following command to back up the
resolv.conf
symbolic link file:mv /etc/resolv.conf /etc/resolv.conf.bak
Run the following command to write the contents of the backup file to the new
resolv.conf
configuration file:cat /etc/resolv.conf.bak > /etc/resolv.conf
Run the following command to lock the
resolv.conf
configuration file and protect theresolv.conf
configuration file:chattr + i /etc/resolv.conf
If the original
resolv.conf
configuration file is not retained, perform the following operation to delete the originalresolv.conf
configuration file:rm /etc/resolv.conf
説明Note:
When network.service is enabled, a new resolv.conf file is automatically generated.
For more information about systemd-resolved, see "systemd-resolved domain name resolution service".
Run the following commands in sequence to switch network services:
systemctl enable network systemctl disable systemd-networkd systemctl disable systemd-resolved
Run the following command to restart the instance:
reboot
Run the following command to verify whether the network service of the instance has been switched to network-scripts:
systemctl status network
How to switch network services from network-scripts to systemd-networkd
If you want to speed up startup and specify known issues and risks of sitemd-networkd network services, you can perform the following operations to switch network services from network-scripts to systemd-networkd.
Note: The following operations involve network configuration. Accidental operations may cause network disconnection. To avoid data security and network risks caused by accidental operations, create a snapshot of the system disk of the Linux instance. For more information on how to create snapshots, see "Creating disk snapshots".
Run the following command to complete the configuration based on whether the original
resolv.conf
configuration file is retained.If the original
resolv.conf
configuration file is retained, perform the following operations.Run the following command to back up the
resolv.conf
symbolic link file:cp /etc/resolv.conf /etc/resolv.conf.bak
Run the following command to lock the
resolv.conf
configuration file and protect theresolv.conf
configuration file:chattr + i /etc/resolv.conf
If the original
resolv.conf
configuration file is not retained, perform the following operations.Run the following command to delete the original
resolv.conf
configuration file:rm /etc/resolv.conf
Run the following command to generate a symbolic link for the
resolv.conf
configuration file:ln -sf /Run /systemd/resolve/resolv.conf /etc/resolv.conf
Run the following command to ensure that the network interface configuration file exists and is valid:
cat /etc/systemd/networ k/10-eth0.net work
The command output similar to the following is returned:
Name=eth0 [Network] DHCP=yes [DHCP] UseDNS=yes
Run the commands in sequence to switch network services:
systemctl disable network.service systemctl enable systemd-networkd systemctl enable systemd-resolved
Run the following command to restart the instance:
reboot
Run the following command to verify that the systemd-networkd network service has started:
systemctl status systemd-networkd
Common issues and solutions for systemd-networkd
The following sections describe common issues and solutions when using systemd-networkd network services. You can select the corresponding solution based on the issue.
UDP port 5355 on systemd-resolved
Intermittent timeout of DNS domain name resolution
Failure of IP forwarding settings
Default route settings for multiple NICs
Description | Solution |
If the following network settings are used in the
| For more information, see the section "ENI settingsENI settings for instances running Alibaba Cloud Linux 2" in the topic "". Configure each NIC individually as needed to avoid automatically setting the default route on specified NICs. |
UDP port 5355 on systemd-resolved
Description | Solution |
By default, systemd-resolved allows the Domain Name System (DNS) service to listen on and occupy port 5355.
|
If you want to close port 5355, replace
説明 Note:
|
Intermittent timeout of DNS domain name resolution
Description | Cause | Solution |
|
|
|
Failure of IP forwarding settings
Description | Cause | Solution |
The default network forwarding setting of sysconfig is
|
Because the systemd-networkd configuration does not include
|
Perform the following operations to add a new IP forwarding setting and enable the forwarding function.
|
Differences in configuration items between network-scripts and systemd-networkd
Configuration item
|
network-scripts
|
systemd-networkd
|
Note
|
IP
|
Configuration file:
|
Configuration file:
|
|
Gateway
|
Configuration file:
|
Configuration file:
| N/A |
DNS
|
Configuration file:
|
Configuration file: 説明 Note: This file is a symbolic link pointing to the
|
For more information on how to change DNS, see "How to customize DNS settings for Alibaba Cloud Linux 2 instances using the /etc/resolv.conf file".
|
Scope of application
ECS