When you create multiple ECS instances at once, they are assigned the same instance name and hostname by default. To distinguish, categorize, and manage your instances more easily, you can customize their names and hostnames during creation by applying sorting rules. This practice standardizes instance naming and improves management efficiency.
Specify a sequence for instance names or hostnames
When you create multiple ECS instances, you can configure their instance names or hostnames to follow a numeric sequence.
Specify a sequence
This method generates sequential instance names and hostnames based on a specific parameter format. The sequential number in the format differentiates the names across multiple ECS instances.
To use this method, enter the formatted string directly in the instance name or hostname field when you create ECS instances. The system then automatically generates the names by incrementing the numeric value. The parameter format is name_prefix[begin_number,bits]name_suffix. The following tables describe the parameters and provide examples.
Procedure
This example shows how to create three ECS instances. Their instance names and hostnames start with the prefix k8s-node- and a numeric sequence that begins with 6. The hostnames also include the suffix -ecshost.
The instance name and hostname that you enter must meet the following requirements:
Instance name: The name must be 2 to 128 characters long, start with a letter or a Chinese character, and contain only letters, Chinese characters, digits, periods (.), underscores (_), colons (:), or hyphens (-).
Hostname:
Windows: The hostname must be 2 to 15 characters long. It can contain letters, digits, and hyphens (-). The hostname cannot start or end with a hyphen. It also cannot contain consecutive hyphens or consist only of digits.
Other operating systems, such as Linux: The hostname must be 2 to 64 characters long. You can use periods (.) to separate the name into segments. Each segment can contain letters, digits, and hyphens (-). The hostname cannot start or end with a period or a hyphen. It also cannot contain consecutive periods or hyphens.
Console
For detailed instructions on how to create an ECS instance, see Custom launch ECS instances. When you create the instances, complete the following settings:
Quantity: On the Custom Launch page, in the Quantity section on the right, click the plus icon to set the quantity to 3.

To batch set instance names or hostnames, use the format
name_prefix[begin_number,bits]name_suffix. For more information about the rules, see Specify a sequence.ImportantThis example is only for specifying a sequence. The Sequential Suffix option is not selected.
Instance Name: Enter the desired instance name. In this example, the names for the three new ECS instances start with
k8s-node-and a numeric sequence beginning with 6. Therefore, set Instance Name tok8s-node-[6,4].Hostname: Select Custom Sequential Hostname below Custom Sequential Hostname, and then enter the desired hostname. In this example, the hostnames for the three new ECS instances start with
k8s-node-, have a numeric sequence beginning with 6, and end with-ecshost. Therefore, set Hostname tok8s-node-[6,4]-ecshost.

After you configure the instances and click Create Order, you can go to the Console to view the instance information:
You can view the new instances in the instance list. Based on this example, the generated instance names are k8s-node-0006, k8s-node-0007, and k8s-node-0008.

On the Instance Details page, in the Other Information section, you can view the hostnames of the new instances. Based on this example, the generated hostnames are k8s-node-0006-ecshost, k8s-node-0007-ecshost, and k8s-node-0008-ecshost.
API
You can call the RunInstances operation to create ECS instances and specify their instance names and hostnames. The following section describes the parameter settings for specifying a sequence.
The format for the InstanceName (instance name) and HostName (hostname) parameters is name_prefix[begin_number,bits]name_suffix. For more information about the rules, see Specify a sequence.
This example creates three instances. Their instance names and hostnames start with k8s-node- and a sequence that begins at 6, and their hostnames end with -ecshost. The parameter settings are as follows:
Amount: 3
InstanceName: k8s-node-[6,4]
HostName: k8s-node-[6,4]-ecshost
This example only uses the sequence specification method. The UniqueSuffix parameter is not enabled and uses its default setting.
Based on this example, the generated instance names are k8s-node-0006, k8s-node-0007, and k8s-node-0008, and the generated hostnames are k8s-node-0006-ecshost, k8s-node-0007-ecshost, and k8s-node-0008-ecshost.
Automatic sorting for instance names or hostnames
When you create multiple ECS instances at once, you can use the automatic sorting feature to add a sequential suffix to their instance names and hostnames.
Automatic sorting
The automatic sorting feature adds a three-digit sequential suffix to instance names and hostnames. When you enable this feature, the suffix starts from 001 and increments for each instance, up to a maximum of 999. This suffix differentiates the names across the instances.
Automatic sorting is disabled by default. To use this feature, you must enable it when you create ECS instances. After you enter an instance name and hostname, the system automatically appends a sequential suffix to generate the final names.
The following naming formats are supported when you enable automatic sorting.
If you want to use the sequence specification method in combination with automatic sorting, you must include a name_suffix in the format string. Otherwise, the automatic sorting feature does not take effect. For more information about the rules for specifying a sequence, see Specify a sequence.
Procedure
This example shows how to create three instances with the instance name ecs and the hostname ecshost. The system automatically adds a sequential suffix to each name.
The instance name and hostname that you enter must meet the following requirements:
Instance name: The name must be 2 to 128 characters long, start with a letter or a Chinese character, and contain only letters, Chinese characters, digits, periods (.), underscores (_), colons (:), or hyphens (-).
Hostname:
Windows: The hostname must be 2 to 15 characters long. It can contain letters, digits, and hyphens (-). The hostname cannot start or end with a hyphen. It also cannot contain consecutive hyphens or consist only of digits.
Other operating systems, such as Linux: The hostname must be 2 to 64 characters long. You can use periods (.) to separate the name into segments. Each segment can contain letters, digits, and hyphens (-). The hostname cannot start or end with a period or a hyphen. It also cannot contain consecutive periods or hyphens.
Console
For detailed instructions on how to create an ECS instance, see Custom launch ECS instances. When you create the instances, complete the following settings:
Quantity: On the Custom Launch page, in the Quantity section on the right, click the plus icon to set the quantity to 3.

Batch set instance names or hostnames: For more information about the rules for automatic sorting, see Automatic sorting.
Instance Name: Enter the desired instance name. In this example, the base name for the three new ECS instances is ecs. Set Instance Name to
ecs.Hostname: Enter the desired hostname. In this example, the base hostname for the three new ECS instances is ecshost. Set Hostname to
ecshost.Sequential Suffix: Select this option to automatically append a sequential suffix to the instance names and hostnames.

After you configure the instances and click Create Order, you can go to the Console to view the instance information:
You can view the new instances in the instance list. Based on this example, the generated instance names are ecs001, ecs002, and ecs003.
On the Instance Details page, in the Other Information section, you can view the hostnames of the new instances. Based on this example, the generated hostnames are ecshost001, ecshost002, and ecshost003.
API
You can call the RunInstances operation to create ECS instances and specify their instance names and hostnames. The following section describes the parameter settings for automatic sorting.
Set the UniqueSuffix parameter to true. The system then automatically appends a sequential suffix to the InstanceName and HostName. This suffix starts at 001 and increments for each instance. For more information about the rules for automatic sorting, see Automatic sorting.
This example shows how to create three instances with automatic sorting. The parameter settings are as follows:
Amount: 3
InstanceName: ecs
HostName: ecshost
UniqueSuffix: true
Based on this example, the generated instance names are ecs001, ecs002, and ecs003, and the generated hostnames are ecshost001, ecshost002, and ecshost003.
Related documents
To modify the properties of an ECS instance, such as its name, hostname, or description, see Modify instance attributes.
To learn more about managing and using your ECS instances, see Manage and configure instances or Manage instance configurations.
To learn how to build a website with Alibaba Cloud ECS, see Build a website (for beginners) or Summary of website building methods.