When you use Elastic Compute Service (ECS) instances in the development environment, test environment, and production environment of your enterprise, you must specify informative hostnames for the ECS instances. You can use Private DNS to generate intranet Domain Name System (DNS) records for the hostnames of specified ECS instances in a few clicks. In this way, you can ping the ECS instances, log on to the ECS instances over SSH, and access the ECS instances over HTTP.
You must activate Private DNS before you use Private DNS to automatically obtain the hostnames of the ECS instances and automatically generate DNS records based on the hostnames.
ECS hostnames
What is an ECS hostname?
An ECS hostname is an identifier of an ECS instance. Other clients that attempt to access the ECS instance can identify the ECS instance by the hostname. ECS hostnames can be used for specific operations, such as ping detection and SSH-based logon.
By default, the hostname of a new ECS instance is its instance ID, for example, iZwz94jhjs732w3fq4i7w****
. You can change the hostname of the ECS instance based on the purpose of the ECS instance. For example, you can change the hostname of the ECS instance to webhost001-huanan1
.
Configuration rules for ECS hostnames
We recommend that you specify a hostname that indicates the purpose of an ECS instance. In most cases, a mature operations and maintenance (O&M) system includes a set of complete numbering rules. For example, you can set a hostname in the format of service ID-product line-region. Example:
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.
Specify an ECS hostname
Method 1 (recommended)
To specify a hostname for a purchased ECS instance, log on to the ECS console and click Instances in the left-side navigation pane. On the Instances page, click the desired instance ID in the Instance ID/Name column. On the Instance Details tab, click the Modify icon below the Hostname parameter. In the Modify Instance Attributes dialog box, modify the value of the Hostname parameter and click Confirm.
Method 2 (not recommended)
Run the hostname webhost001-huanan1
command on an ECS instance or edit the /etc/sysconfig/network
file to temporarily change the ECS hostname.
This method can only be used to temporarily change the hostname of the ECS instance and does not change the hostname in the DNS record. You can use this method to specify a desired hostname, which does not affect the synchronization result of the DNS record.
Generate DNS records
To generate intranet DNS records for the hostnames of ECS instances, perform the following steps:
Log on to the Alibaba Cloud DNS console.
In the left-side navigation pane, click Private DNS (PrivateZone). In the upper-right corner of the Private DNS (PrivateZone) page, click Configuration Mode. On the Built-in Authoritative Module tab, click the User Defined Zones tab.
Click Add New Zone. In the Add Built-in Authoritative Zone panel, enter a built-in authoritative zone name, such as host.prvz, and click OK.
On the User Defined Zones tab, find the desired zone and click Resource Records Settings in the Actions column. Click the ECS Hostname tab and click Automatic Synchronization Settings.
In the Configure Hostname Automatic Synchronization panel, select the regions where the ECS instances are located for which you want to enable hostname synchronization, turn on Automatic Synchronization (once per minute), and then click OK.
The system automatically reads the hostnames of the ECS instances in the specified regions and updates DNS records at an interval of 1 minute.
By default, the system obtains the hostnames of all ECS instances in the specified regions. You can remove the ECS instances for which no DNS records are configured.
Return to the User Defined Zones tab, find the desired zone, and then click Effective Scope Settings in the Actions column. On the Zone Settings page, select one or more virtual private clouds (VPCs) as the effective scope of the zone and click OK.
You must associate the built-in authoritative zone with the VPCs in which the desired ECS instances are deployed. In this way, the DNS records for the hostnames of the ECS instances can take effect.
After the DNS records are generated, you can check whether the DNS records take effect.
Check whether a DNS record takes effect
After you use Private DNS to generate a DNS record for the hostname of an ECS instance, you can access the ECS instance by using a fully qualified domain name (FQDN) such as host001-test-huanan1.host.prvz or privatezone-test.host.prvz. Connect to an ECS instance in an intranet and run the ping or SSH command to verify whether the DNS record of another ECS instance, such as a host001-test-huanan1, takes effect. Example:
Run a ping command
Run an SSH command
For more information, see Connection method overview.
If you do not want to use a 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:
Open the DNS configuration file
vim /etc/resolv.conf
of the ECS instance.
Add the
search host.prvz
command to the file. In this way, the system prioritizes thehost.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. Examples:
Ping the ECS instance
Log on the ECS instance over SSH
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
rather than xxxcompany.
, the name indicates a hostname. A name suffixed with a period (.) indicates an FQDN. The period (.) indicates the root domain in a domain tree.