Resolving private domain names within your enterprise is a common requirement in hybrid or multi-cloud environments. The default DNS servers for an Elastic Compute Service (ECS) instance (100.100.2.136 and 100.100.2.138) resolve only public domain names and Alibaba Cloud internal domain names. To resolve private domain names on an ECS instance, configure a custom DNS server.
Procedures
Option 1: Automatically configure DNS by using a DHCP options set (recommended)
A DHCP options set centrally configures the DNS server IP addresses and domain names for all ECS instances within a virtual private cloud (VPC). After configuration, instances can communicate with each other by using hostnames or fully qualified domain names (FQDNs), eliminating the need for fixed IP addresses. This method supports centralized management, dynamic configuration updates, is independent of the operating system, and reduces manual effort and the risk of errors.
Option 2: Manually configure DNS on the instance
Alibaba Cloud Linux, CentOS, and Red Hat
Log on to the ECS instance.
Go to ECS console - Instance. In the top navigation bar, select the target region and resource group.
Go to the details page of the target instance. Click Connect and select Workbench. Follow the on-screen prompts to log on and access the terminal page.
Add the following line to the top of the
/etc/resolv.conffile, replacing<DNS_IP>with your DNS server's IP address. The system prioritizes the DNS server listed first.nameserver <DNS_IP>Lock the
/etc/resolv.conffile to prevent it from being overwritten on system or network restarts.To unlock the file, run the
chattr -i /etc/resolv.confcommand.sudo chattr +i /etc/resolv.confVerify the DNS configuration. In the command output, confirm that the
Serveraddress matches the IP address you configured.If
nslookupis not installed, runsudo yum install bind-utilsto install it.sudo nslookup <domain_name>
Windows Server
This example uses Windows Server 2022.
Log on to the ECS instance.
Go to ECS console - Instance. In the top navigation bar, select the target region and resource group.
On the details page of the target instance, click Connect and select Workbench. The connection method is Terminal. Follow the on-screen prompts to enter your username (for example, Administrator) and password.
Open Settings and go to the Network & Internet interface.
Select Ethernet, click Network, and then click Edit in the DNS server assignment area.
In the Edit DNS settings dialog box, switch the pattern to Manual and enable IPv4.
In the Preferred DNS field, enter a custom DNS address. To ensure that internal Alibaba Cloud services are resolved correctly, enter
100.100.2.136in the Alternate DNS field. Click Save.