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
-
Log on to the ECS instance.
-
Go to ECS console - Instances. In the top-left corner, select the region and resource group for the target resource.
-
Go to the instance details page. Click Connect and select Workbench. Follow the on-screen prompts to log on.
-
-
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> -
Lock
/etc/resolv.confto prevent overwriting on system or network restarts.To unlock the file, run
chattr -i /etc/resolv.conf.sudo chattr +i /etc/resolv.conf -
Verify the DNS configuration. Confirm that the
Serveraddress in the output matches the IP address you configured.If
nslookupis not installed, runsudo yum install bind-utils.sudo nslookup <domain_name>
Windows Server
This example uses Windows Server 2022.
-
Log on to the ECS instance.
-
Go to ECS console - Instances. In the top-left corner, select the region and resource group for the target resource.
-
On the instance details page, click Connect and select Workbench. Set the connection method to Terminal. Enter your username (for example, Administrator) and password.
-
-
Open Set and go to Network & Internet.
-
Select Ethernet, click Network, and then click Edit in the DNS server assignment area.
-
In the Edit DNS settings dialog box, set the mode to Manual and enable IPv4.
-
In the Preferred DNS field, enter your custom DNS address. In the Alternate DNS field, enter
100.100.2.136to ensure Alibaba Cloud internal services resolve correctly. Click Save.