All Products
Search
Document Center

Alibaba Cloud Linux:Enable manual management for the /etc/resolv.conf file

Last Updated:Mar 31, 2026

By default, NetworkManager automatically manages /etc/resolv.conf in Alibaba Cloud Linux 3, overwriting the file whenever network parameters change. To set custom DNS configuration — such as specific nameservers or search domains — you must stop NetworkManager from overwriting the file. This topic explains how NetworkManager and systemd-resolved each handle the file, and walks you through enabling manual management.

How network management services manage /etc/resolv.conf

In Alibaba Cloud Linux 3, /etc/resolv.conf is a regular file (not a symbolic link). The two network management services handle it as follows:

  • NetworkManager creates the file the first time the system starts, after the primary network interface comes up and obtains an IP address. It updates the file whenever network interface controller (NIC) parameters change — device status, IP address, routes, DNS name, or hostname.

  • systemd-resolved reads the file but never writes to it.

How the file is managed in other Linux distributions

In other Linux distributions, /etc/resolv.conf may be a regular file or a symbolic link, and management policies vary accordingly:

ServiceConditionBehavior
NetworkManagerSymbolic link points to /run/NetworkManager/resolv.confManages the file through the symbolic link
NetworkManagerRegular file or file does not existCreates and automatically manages the file
systemd-resolvedSymbolic link points to /run/systemd/resolve/resolv.confManages the file through the symbolic link
systemd-resolvedAny other targetReads the file but does not update it

Disable automatic management

To set custom DNS parameters in /etc/resolv.conf, stop NetworkManager from overwriting it by creating a drop-in configuration file.

Prerequisites

Before you begin, ensure that you have:

  • sudo privileges on the Alibaba Cloud Linux 3 instance

Procedure

  1. Open the NetworkManager drop-in configuration file:

    sudo vim /etc/NetworkManager/conf.d/90-dns-none.conf
  2. Press I to enter Insert mode and add the following:

    [main]
    dns=none
  3. Press Esc, type :wq, and press Enter to save and close the file.

  4. Reload NetworkManager to apply the change:

    sudo systemctl reload NetworkManager
Important

If /etc/resolv.conf is not automatically created on system startup, the system cannot use the DNS server defined in the configuration file to perform DNS resolution. For more information, see the /etc/resolv.conf is not created after system startup section.

Re-enable automatic management

To let NetworkManager manage /etc/resolv.conf again, delete or comment out the [main] / dns=none block you added, then reload the service:

sudo systemctl reload NetworkManager

Troubleshooting

/etc/resolv.conf is not created after system startup

NetworkManager creates /etc/resolv.conf on first boot. If the file is missing, NetworkManager likely failed to start, which prevents DNS resolution.

  1. Check the NetworkManager status:

    sudo systemctl status NetworkManager

    The following output indicates that NetworkManager is running as expected.

    image

    If the status shows anything other than active (running), proceed to the next step.

  2. View the startup logs to identify the failure:

    sudo journalctl -u NetworkManager -b
  3. After resolving the issue based on the logs, start NetworkManager:

    sudo systemctl start NetworkManager

    Once NetworkManager starts successfully, /etc/resolv.conf is created automatically.