All Products
Search
Document Center

HostName

Last Updated: Aug 21, 2020

We recommend that you set an easy-to-recognize hostname for your Elastic Compute Service (ECS) instance to facilitate code development, testing, and production within enterprises. For more information about how to set a hostname for an ECS instance, see ECS hostnames.

You can use PrivateZone to quickly generate internal Domain Name System (DNS) records of hostnames for ECS instances deployed in a Virtual Private Cloud (VPC) of a specified region, so that you can easily access, monitor, or test the ECS instances by using the ping command, Secure Shell (SSH) protocol, or HTTP protocol.

Prerequisites

PrivateZone is activated. After being activated, PrivateZone automatically obtains the hostname configuration of each specified ECS instance and generates hostname records based on the hostname.

Generate the hostname records

To generate hostname records for ECS instances in VPCs, follow these steps:

1 . Log on to the Alibaba Cloud DNS console.
2 . In the left-side navigation pane, click PrivateZone. The All Zones tab appears.
3 . Click Add Zone. In the Add PrivateZone dialog box that appears, enter a zone name in the Zone Name field, for example, host.prvz, and click OK.
hostname-1
4 . Click the name of the created private zone in the Zone Name column. On the Resolution Settings page that appears, click the Hostname tab. On the Hostname tab, click Automatic Synchronization.
hostname-2
5 . In the Automatically synchronize hostnames dialog box, select the region in which the target ECS instances reside and click Confirm.
hostname-4
Note:

  • Alibaba Cloud DNS automatically obtains the hostname configuration of ECS instances in the selected region and updates the hostname records at an interval of 1 minute.
  • By default, Alibaba Cloud DNS displays the hostnames of all ECS instances in the selected region. You can delete a hostname record from the list.
    hostname-5

6 . Go to the PrivateZone page. Find the target private zone and click Bind VPC in the Actions column.

Note: You must associate a private zone with the VPCs in which the target ECS instances reside. Then, the hostname records take effect.
bind-vpc
7 . In the Bind VPC dialog box that appears, select one or more VPCs in which the target ECS instances reside and click Confirm.
hostname-7
After you configure a private zone to generate the hostname records, you can verify a hostname record.

Verify a hostname record

After the host records are generated, you can access a specified ECS instance by using a fully qualified domain name (FQDN). In this example, the FQDNs are privatezone-test.host.local and privatezone-test3.host.local. Connect to one of the ECS instances, such as privatezone-test2 in this example, in the VPC. Then, run the ping or SSH command to check whether the hostname record for another ECS instance, such as privatezone-test3 in this example, has taken effect.

  • Run the ping command to verify the hostname record
    hostname-8
  • Run the SSH command to verify the hostname record
    hostname-9
    Note: For more information about how to connect to an ECS instance, see Connect to an ECS instance.

If you find it inconvenient to use an FQDN, you can modify the DNS configuration to use hostnames instead. In this example, hostnames are specified as privatezone-test3 and privatezone-test1.

  1. On the ECS instance, run the vim /etc/resolv.conf command to open the DNS configuration file .

  2. Enter the search command search host.prvz in the file and set the DNS record suffix host.prvz as the prioritized search domain.

Now you can access the target ECS instance by using the hostname. Example:

  • Run the ping command to access the ECS instance
    hostname-11
  • Run the SSH command to access the ECS instance
    hostname-12

ECS hostnames

What is an ECS hostname

An ECS hostname is the hostname that you specify for an ECS instance. As the entry for network connection, an ECS hostname is usually used in ping probing and during the logon through SSH.

By default, the instance ID is set as the hostname of a newly purchased ECS instance, for example, iZwz94jhjs732w3fq4i7wbh7Z. You can modify the hostname to reflect the use of the ECS instance, for example, webhost001-huanan1.

Set an ECS hostname

Method 1 (recommended): Purchase an ECS instance and specify a hostname in the System Configurations step.
hostname-13
Method 2 (recommended): Modify the hostname of a purchased ECS instance in the console. To modify the ECS hostname, follow these steps: Log on to the ECS console. In the left-side navigation pane, choose Instances & Images > Instances. On the Instances page, find the target ECS instance and choose More > Instance Settings > Modify Instance Attributes in the Actions column. In the Modify Instance Attributes dialog box that appears, modify the name in the HostName field.
hostname-14
Method 3: Temporarily modify the hostname of a purchased ECS instance. To temporarily modify the ECS hostname, run the hostname webhost001-huanan1 command on the target ECS instance or modify the hostname by editing the /etc/sysconfig/network file.
Note: You can only temporarily modify an ECS hostname by using method 3. The hostname recorded in the instance information will not be changed.

Naming rule of ECS hostnames

We recommend that you specify an informative hostname for an ECS instance. For example, you can use the naming rule of business number-product line-region on hostnames to declare the function of each ECS instance and differentiate among different ECS instances. Examples:

  • The hostname app001-live-huanan1 indicates a live streaming application running on the ECS instance 001 that resides in China (Shenzhen).
  • The hostname jack001-dev-huabei2 indicates that the ECS instance 001 which resides in China (Beijing) is used by the employee Jack.

What is FQDN

An FQDN consists of the name and exact location of the involved host. The exact location specifies all domain levels. An FQDN specifies the exact location of the involved host in the DNS hierarchy. It is a full form of a hostname.

For example, the FQDN for the website of company xxxcompany can be xxxcompany.. If the sales website of the company resides in the sales subdomain, the FQDN for the sales website can be sales.xxxcompany. An FQDN appears as xxxcompany., whereas hostnames are usually in the format ofxxxcompany.A period (.) is required at the end of a FQDN to indicate the DNS root domain.