What Can I Do If /etc/resolv.conf Is Restored After an ECS Running Ubuntu Is Restarted?
Symptom
After an ECS running Ubuntu or network-related services are restarted, the /etc/resolv.conf file is updated, and the nameserver field is restored to 127.0.0.53.
Possible Cause
By default, Ubuntu uses systemd-resolved service for DNS maintenance. If ECSs or network-related services are restarted, the IP address of nameserver is updated to 127.0.0.53.
Solution
You are advised to disable the systemd-resolved service before handling the issue.
Solution 1: Manually modify the /etc/resolv.conf file.
- Log in to the ECS as user root.
- Disable the systemd-resolved service.
systemctl stop systemd-resolved
systemctl disable systemd-resolved
- Delete the default soft link in /etc/resolv.conf and create it as a common file.
rm -rf /etc/resolv.conf
- Edit /etc/resolv.conf and add related DNS configuration to it.
vim /etc/resolv.conf
Configure the nameserver parameter to add the DNS configuration as follows:
nameserver 100.125.1.250 nameserver 100.125.129.250
- Lock /etc/resolv.conf to prevent it from being modified by DHCP or other services.
chattr +i /etc/resolv.conf
Solution 2: Use NetworkManager to maintain the /etc/resolv.conf file based on the DNS information (configured in the VPC subnet) obtained through DHCP.
- Disable the systemd-resolved service.
systemctl stop systemd-resolved
systemctl disable systemd-resolved
- Edit the NetworkManager configuration file and add the dns=default configuration.
vim /etc/NetworkManager/NetworkManager.conf
[main] plugins=ifupdown,keyfile dns=default [ifupdown] managed=true [device] wifi.scan-rand-mac-address=no
- Delete the default soft link in /etc/resolv.conf and create it as a common file.
rm -rf /etc/resolv.conf
- Restart NetworkManager and update the /etc/resolv.conf file.
systemctl restart NetworkManager
- Check the DNS configuration in the /etc/resolv.conf file.
- If the DNS configuration is the same as that of the subnet which the ECS belongs to, the modification is successful.
You can log in to the ECS console and click the target ECS name. On the ECS details page, click the primary NIC name in the NICs area to switch to the subnet console. On the displayed page, check the DNS Server Address in the Gateway and DNS Information area.
- If they are inconsistent, submit a service ticket to contact technical support.
- If the DNS configuration is the same as that of the subnet which the ECS belongs to, the modification is successful.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot