Help Center/ Elastic Cloud Server/ Troubleshooting/ Configuring the Network/ What Can I Do If /etc/resolv.conf Is Restored After an ECS Running Ubuntu Is Restarted?
Updated on 2024-08-15 GMT+08:00

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.

Figure 1 Symptom

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.

  1. Log in to the ECS as user root.
  2. Disable the systemd-resolved service.

    systemctl stop systemd-resolved

    systemctl disable systemd-resolved

  3. Delete the default soft link in /etc/resolv.conf and create it as a common file.

    rm -rf /etc/resolv.conf

  4. 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
  5. 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.

  1. Disable the systemd-resolved service.

    systemctl stop systemd-resolved

    systemctl disable systemd-resolved

  2. 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
  3. Delete the default soft link in /etc/resolv.conf and create it as a common file.

    rm -rf /etc/resolv.conf

  4. Restart NetworkManager and update the /etc/resolv.conf file.

    systemctl restart NetworkManager

  5. 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.