Alibaba Cloud-Get instance metadata

Introduction to instance metadata

The instance metadata contains the basic information of the ECS instance in the Alibaba Cloud system, such as the instance ID, IP address, network card MAC address, and operating system type. Instances also support dynamic instance metadata items. Dynamic instance metadata is data generated or customized after the instance is first started. It currently includes system events, instance identifiers, and instance custom data.

Get instance metadata

1. Remote connection instance

2. Execute the following command to access the root directory of metadata,

curl http://100.100.100.200/latest/meta-data/

3, add specific metadata name in the URL can get specific metadata details, see examples of metadata list.

E.g:

  • Execute the following command to obtain the instance ID.
    curl http://100.100.100.200/latest/meta-data/instance-id
  • Execute the following command to obtain the image ID used when creating the instance.
    curl http://100.100.100.200/latest/meta-data/image-id
  • Execute the following command to obtain active system events.
    curl http://100.100.100.200/latest/maintenance/active-system-events
  • Execute the following command to obtain the instance identification document.
    curl http://100.100.100.200/latest/dynamic/instance-identity/document
  • Execute the following command to obtain instance custom data.
    curl http://100.100.100.200/latest/user-data

Instance metadata list

The following table contains the basic instance metadata items currently available for ECS instances:

 
Instance metadata item Description Introduced version
/dns-conf/nameservers The DNS configuration of the instance. 2016-01-01
/ eipv4 The flexible public IP (IPv4 type) mounted on the instance's primary network card. 2016-01-01
/hostname The host name of the instance. 2016-01-01
/instance/instance-type Instance specifications. 2016-01-01
/image-id The image ID used when creating the instance. 2016-01-01
/image/market-place/product-code The commodity code mirrored by the mirror market. 2016-01-01
/image/market-place/charge-type The billing method for mirroring in the mirror market. 2016-01-01
/instance-id The instance ID. 2016-01-01
/mac The MAC address of the instance. If the instance has multiple network cards, only the MAC address on eth0 is displayed. 2016-01-01
/network-type Network type. Only VPC type instances are supported. 2016-01-01
/network/interfaces/macs The MAC address list of the network card. 2016-01-01
/network/interfaces/macs/[mac]/network-interface-id The identification ID of the network card, where the [mac] parameter needs to be replaced with the instance MAC address. 2016-01-01
/network/interfaces/macs/[mac]/netmask The subnet mask corresponding to the network card. 2016-01-01
/network/interfaces/macs/[mac]/vswitch-cidr-block The IPv4 CIDR segment of the virtual switch to which the network card belongs. 2016-01-01
/network/interfaces/macs/[mac]/vpc-cidr-block The VPC IPv4 CIDR segment to which the network card belongs. 2016-01-01
/network/interfaces/macs/[mac]/private-ipv4s List of private network IPv4 addresses allocated by the network card. 2016-01-01
/network/interfaces/macs/[mac]/vpc-ipv6-cidr-blocks The VPC IPv6 CIDR segment to which the NIC belongs only supports VPC instances that have been configured with IPv6. 2016-01-01
/network/interfaces/macs/[mac]/vswitch-id The virtual switch ID of the security group to which the NIC belongs. 2016-01-01
/network/interfaces/macs/[mac]/vpc-id VPC ID of the security group to which the NIC belongs. 2016-01-01
/network/interfaces/macs/[mac]/primary-ip-address The main private IP address of the network card. 2016-01-01
/network/interfaces/macs/[mac]/gateway The IPv4 gateway address corresponding to the network card. 2016-01-01
/instance/max-netbw-egress The maximum bandwidth of the internal network in the outbound direction of the instance specification. Unit: Kbit/s. 2016-01-01
/instance/max-netbw-ingerss The maximum bandwidth of the intranet in the inbound direction of the instance specification. Unit: Kbit/s. 2016-01-01
/network/interfaces/macs/[mac]/ipv6s The IPv6 address list assigned by the network card only supports VPC instances that have been configured with IPv6. 2016-01-01
/network/interfaces/macs/[mac]/ipv6-gateway IPv6 gateway address of the VPC to which the network card belongs. 2016-01-01
/network/interfaces/macs/[mac]/vswitch-ipv6-cidr-block The IPv6 CIDR segment of the virtual switch to which the network card belongs can only support VPC instances that have been configured with IPv6. 2016-01-01
/private-ipv4 实例主网卡的私网IPv4地址。 2016-01-01
/public-ipv4 实例主网卡的公网IPv4地址。 2016-01-01
/ntp-conf/ntp-servers NTP服务器地址。 2016-01-01
/owner-account-id 实例拥有者的阿里云账号ID。 2016-01-01
/public-keys 当前实例所有公钥的列表。 2016-01-01
/region-id 实例所属地域。 2016-01-01
/zone-id 实例所属可用区。 2016-01-01
/serial-number 实例所对应的序列号。 2016-01-01
/source-address Linux实例的包管理软件(主要为Yum源或者apt源)获取更新的镜像库。 2016-01-01
/kms-server Windows实例的KMS激活服务器。 2016-01-01
/wsus-server/wu-server Windows实例的更新服务器。 2016-01-01
/wsus-server/wu-status-server Windows实例的更新状态监控服务器。 2016-01-01
/vpc-id 实例所属VPC ID。 2016-01-01
/vpc-cidr-block 实例所属VPC CIDR段。 2016-01-01
/vswitch-cidr-block 实例所属虚拟交换机CIDR段。 2016-01-01
/vswitch-id 实例所属虚拟交换机ID。 2016-01-01
/ram/security-credentials/[role-name] 实例RAM角色策略所生成的STS临时凭证。只有在实例指定了RAM角色后,您才能获取STS临时凭证。其中[role-name]参数需要替换为实例RAM角色的名称。

说明 STS临时凭证更新时间早于凭证失效前半小时,在这半小时内,新旧STS临时凭证均可以使用。

2016-01-01
/instance/spot/termination-time 抢占式实例的操作系统设置的停机释放时间,时区标准为UTC+0,格式为yyyy-MM-ddThh:mm:ssZ。例如,2018-04-07T17:03:00Z。 2016-01-01
/instance/virtualization-solution ECS虚拟化方案,支持Virt 1.0和Virt 2.0。 2016-01-01
/instance/virtualization-solution-version 内部Build号。 2016-01-01
/instance-identity/pkcs7 实例标识签名。 2016-01-01

具体内容请参考:https://help.aliyun.com/document_detail/108460.html

Guess you like

Origin blog.csdn.net/Swallow_he/article/details/105712216