All Products
Search
Document Center

Alibaba Cloud DNS PrivateZone:Configure a DNS record for an ECS instance

Last Updated:Mar 30, 2023

When you use Elastic Compute Service (ECS) instances in the development environment, test environment, and production environment of an enterprise, you must specify informative hostnames for the instances. You can use Alibaba Cloud DNS PrivateZone to generate a private DNS record for the hostname of a specified ECS instance. This way, you can run ping commands, Secure Shell (SSH) commands, and HTTP commands to access services, probe, and log on to the ECS instance over a private network. For information about how to specify a hostname for an ECS instance, see ECS hostnames.

Before you use Alibaba Cloud DNS PrivateZone to automatically obtain the hostname of an ECS instance and generate a private DNS record for the hostname, you must Activate Alibaba Cloud DNS PrivateZone.

Configure a DNS record

To configure a private DNS record for an ECS instance, perform the following steps:

1 . Log on to the Alibaba Cloud DNS console.

2 . Choose PrivateZone > Authoritative Zones.

3 . Click Add Zone. In the Add Zone dialog box, enter a zone name (for example, host.prvz) and click OK.

4 . On the Authoritative Zones tab, click the zone name. On the Configure DNS Settings page, click Hostname Records. On the Hostname Records tab, click Configure Auto-synchronization.

5 . In the Configure Hostname Auto-synchronization panel, select one or more regions where ECS instances whose hostnames that you want to obtain reside. Then, click OK.

Note:

  • The system automatically reads the hostnames of the ECS instances in the specified regions and updates hostname records at an interval of 1 minute.

  • The system obtains the hostnames of the ECS instance in the specified regions. You can remove instances for which no DNS records are configured.

6 . Go to the Authoritative Zones tab, find the zone, and then click Associate VPC in the Actions column.

To enable the DNS record, you must associate the zone with the VPC where the ECS instance resides.

7 . In the Associate VPC panel, select the VPC where the ECS instance resides.

After the DNS record is configured, check whether the DNS record takes effect.

Check whether a DNS record takes effect

After you configure a DNS record for an ECS instance, you can use a fully qualified domain name (FQDN) to access the ECS instance. In this example, host001-test-huanan1.host.prvz and privatezone-test.host.prvz are used. For more information, see What is an FQDN? For example, if you want to check the DNS record of an ECS instance named host001-test-huanan1 in a private network, connect to another ECS instance named iz2zegrmuy7gugt0phtxtkz that resides in the same private network as host001-test-huanan1 and run a ping command or an SSH command.

  • Run a ping command

  • Run an SSH command

For more information, see Connect to an ECS instance.

If you do not want to use an FQDN to specify an ECS instance, you can use a hostname instead. Example: privatezone-test and host001-test-huanan1. To use a hostname to specify an ECS instance, perform the following steps:

  1. Open the DNS configuration file vim /etc/resolv.conf on the ECS instance.

  2. Add the search host.prvz command to the file. The system prioritizes the host.prvz domain and searches for the ECS instances in the domain.

After you perform the preceding operations, you can use the hostname to access the ECS instance. For example, you can run the following commands:

  • Ping <hostname>

  • SSH <hostname>

ECS hostnames

What is an ECS hostname?

An ECS hostname is an identifier that can be specified for an ECS instance. Other clients that attempt to access the ECS instance can identify the ECS instance by hostname. ECS hostnames can be used for specific operations, such as ping detection and SSH logons.

By default, the hostname of a new ECS instance is the ID of the ECS instance. Example: iZwz94jhjs732w3fq4i7wbh7Z. You can change a hostname for an ECS instance based on the purpose of the ECS instance. Example: webhost001-huanan1.

Specify a hostname for an ECS instance

Method 1 (recommended): When you purchase an ECS instance, specify a hostname for the ECS instance during the system configuration process. 图片1

Method 2 (recommended): On the Instances page, find the instance for which you want to specify a hostname and choose More > Instance Settings > Modify Information in the Actions column. 图片2

Method 3 (not recommended): Run the hostname <hostname> command on the ECS instance for which you want to specify a hostname or modify the /etc/sysconfig/network file to specify a temporary hostname. Replace <hostname> with an actual hostname. Example: webhost001-huanan1.

You can use Method 3 to specify a temporary hostname for an ECS instance. The hostname recorded in the information about the ECS instance remains unchanged. The temporary hostname is not synchronized and cannot be used for communication.

Rules for specifying a hostname

We recommend that you specify a hostname that can help you identify the purpose of the instance. In most cases, a mature maintenance system includes a set of complete numbering rules. Example: service ID-product line-region. Examples:

  • app001-live-huanan1 indicates that an ECS instance named 001 that hosts the live streaming app of an enterprise resides in the China (Shenzhen) region.

  • jack001-dev-huabei2 indicates that an ECS instance named 001 that is used for development by an enterprise employee named Jack resides in the China (Beijing) region.

What is an FQDN?

An FQDN consists of the hostname of a host and the name of the domain to which the host belongs. The domain name indicates the domain to which all domain members belong. An FQDN is a complete address for a host. The address indicates the accurate location where the host resides in a logical manner. The FQDN of a host indicates the location where the host resides in a domain tree.

For example, the FQDN of the web server of an enterprise named xxx company is xxxcompany.. If a sales host belongs to a sub-domain named Sales Department, the FQDN of the host is sales.xxxcompany. If a name is similar to xxxcompany instead of xxxcompany., the name indicates a host name. A name suffixed with a period (.) indicates an FQDN. The period (.) indicates the root domain in a domain tree.