All Products
Search
Document Center

:Configure a custom DNS server for an ECS instance

Last Updated:Apr 27, 2026

The default ECS DNS servers (100.100.2.136 and 100.100.2.138) resolve only public and Alibaba Cloud internal domain names. Configure a custom DNS server to resolve private domain names.

Procedure

Option 1: Configure DNS with a DHCP options set (recommended)

A DHCP options set centrally configures DNS server IP addresses and domain names for all ECS instances in a VPC. Instances can then communicate by using hostnames or FQDNs without fixed IP addresses. This method is OS-independent, supports centralized management and dynamic updates, and reduces manual effort.

Option 2: Configure DNS manually on the instance

Alibaba Cloud Linux, CentOS, and Red Hat

  1. Log on to the ECS instance.

    1. Go to ECS console - Instances. In the top-left corner, select the region and resource group for the target resource.

    2. Go to the instance details page. Click Connect and select Workbench. Follow the on-screen prompts to log on.

  2. Add the following line to the top of /etc/resolv.conf, replacing <DNS_IP> with your DNS server IP address. The system prioritizes the first listed DNS server.

    nameserver <DNS_IP>
  3. Lock /etc/resolv.conf to prevent overwriting on system or network restarts.

    To unlock the file, run chattr -i /etc/resolv.conf.
    sudo chattr +i /etc/resolv.conf
  4. Verify the DNS configuration. Confirm that the Server address in the output matches the IP address you configured.

    If nslookup is not installed, run sudo yum install bind-utils.
    sudo nslookup <domain_name>

Windows Server

This example uses Windows Server 2022.

  1. Log on to the ECS instance.

    1. Go to ECS console - Instances. In the top-left corner, select the region and resource group for the target resource.

    2. On the instance details page, click Connect and select Workbench. Set the connection method to Terminal. Enter your username (for example, Administrator) and password.

  2. Open Set and go to Network & Internet.

  3. Select Ethernet, click Network, and then click Edit in the DNS server assignment area.

  4. In the Edit DNS settings dialog box, set the mode to Manual and enable IPv4.

  5. In the Preferred DNS field, enter your custom DNS address. In the Alternate DNS field, enter 100.100.2.136 to ensure Alibaba Cloud internal services resolve correctly. Click Save.