Getting Information About Your Subnets
You can get information about one or more of your Subnets, like the Net in which they are, their CIDR block or their Subregion.
Information about your Subnets is also available from within the associated virtual machines (VMs) themselves. For more information, see Accessing the Metadata and User Data of a VM.
Getting Information About Your Subnets Using OSC CLI
The ReadSubnets command lists one or more of your Subnets.
If you do not specify any Subnet ID, this action describes all of your Subnets.
$ osc-cli api ReadSubnets --profile "default" \
--Filters '{
"NetIds": ["vpc-12345678"]
}'
$ osc-cli api ReadSubnets --profile "default" \
--Filters '{
"States": ["available", "pending"],
"SubregionNames": ["eu-west-2a"]
}'
This command contains the following attributes that you need to specify:
-
DryRun
: (optional) If true, checks whether you have the required permissions to perform the action. -
Filters
: (optional) One or more filters.-
AvailableIpsCounts
: (optional) The number of available IPs. -
IpRanges
: (optional) The IP ranges in the Subnets, in CIDR notation (for example,10.0.0.0/16
). -
NetIds
: (optional) The IDs of the Nets in which the Subnets are. -
States
: (optional) The states of the Subnets (pending
|available
|deleted
). -
SubnetIds
: (optional) The IDs of the Subnets. -
SubregionNames
: (optional) The names of the Subregions in which the Subnets are located. -
TagKeys
: (optional) The keys of the tags associated with the Subnets. -
TagValues
: (optional) The values of the tags associated with the Subnets. -
Tags
: (optional) The key/value combination of the tags associated with the Subnets, in the following format: "Filters":{"Tags":["TAGKEY=TAGVALUE"]}.
-
-
NextPageToken
: (optional) The token to request the next page of results. Each token refers to a specific page. -
ResultsPerPage
: (optional) The maximum number of logs returned in a single response (between1
and1000
, both included). By default,100
.
The ReadSubnets command returns the following elements:
-
NextPageToken
: The token to request the next page of results. Each token refers to a specific page. -
ResponseContext
: Information about the context of the response.-
RequestId
: The ID of the request.
-
-
Subnets
: Information about one or more Subnets.-
AvailableIpsCount
: The number of available IPs in the Subnets. -
IpRange
: The IP range in the Subnet, in CIDR notation (for example,10.0.0.0/16
). -
MapPublicIpOnLaunch
: If true, a public IP is assigned to the network interface cards (NICs) created in the specified Subnet. -
NetId
: The ID of the Net in which the Subnet is. -
State
: The state of the Subnet (pending
|available
|deleted
). -
SubnetId
: The ID of the Subnet. -
SubregionName
: The name of the Subregion in which the Subnet is located. -
Tags
: One or more tags associated with the Subnet.-
Key
: The key of the tag, with a minimum of 1 character. -
Value
: The value of the tag, between 0 and 255 characters.
-
-
{
"Subnets": [
{
"Tags": [],
"SubregionName": "eu-west-2a",
"SubnetId": "subnet-12345678",
"AvailableIpsCount": 16379,
"IpRange": "10.0.0.0/18",
"MapPublicIpOnLaunch": false,
"State": "available",
"NetId": "vpc-12345678"
}
],
"ResponseContext": {
"RequestId": "0475ca1e-d0c5-441d-712a-da55a4175157"
}
}
Getting Information About Your Subnets Using oapi-cli
The ReadSubnets command lists one or more of your Subnets.
If you do not specify any Subnet ID, this action describes all of your Subnets.
$ oapi-cli --profile "default" ReadSubnets \
--Filters '{
"NetIds": ["vpc-12345678"]
}'
$ oapi-cli --profile "default" ReadSubnets \
--Filters '{
"States": ["available", "pending"],
"SubregionNames": ["eu-west-2a"]
}'
This command contains the following attributes that you need to specify:
-
DryRun
: (optional) If true, checks whether you have the required permissions to perform the action. -
Filters
: (optional) One or more filters.-
AvailableIpsCounts
: (optional) The number of available IPs. -
IpRanges
: (optional) The IP ranges in the Subnets, in CIDR notation (for example,10.0.0.0/16
). -
NetIds
: (optional) The IDs of the Nets in which the Subnets are. -
States
: (optional) The states of the Subnets (pending
|available
|deleted
). -
SubnetIds
: (optional) The IDs of the Subnets. -
SubregionNames
: (optional) The names of the Subregions in which the Subnets are located. -
TagKeys
: (optional) The keys of the tags associated with the Subnets. -
TagValues
: (optional) The values of the tags associated with the Subnets. -
Tags
: (optional) The key/value combination of the tags associated with the Subnets, in the following format: "Filters":{"Tags":["TAGKEY=TAGVALUE"]}.
-
-
NextPageToken
: (optional) The token to request the next page of results. Each token refers to a specific page. -
ResultsPerPage
: (optional) The maximum number of logs returned in a single response (between1
and1000
, both included). By default,100
.
The ReadSubnets command returns the following elements:
-
NextPageToken
: The token to request the next page of results. Each token refers to a specific page. -
ResponseContext
: Information about the context of the response.-
RequestId
: The ID of the request.
-
-
Subnets
: Information about one or more Subnets.-
AvailableIpsCount
: The number of available IPs in the Subnets. -
IpRange
: The IP range in the Subnet, in CIDR notation (for example,10.0.0.0/16
). -
MapPublicIpOnLaunch
: If true, a public IP is assigned to the network interface cards (NICs) created in the specified Subnet. -
NetId
: The ID of the Net in which the Subnet is. -
State
: The state of the Subnet (pending
|available
|deleted
). -
SubnetId
: The ID of the Subnet. -
SubregionName
: The name of the Subregion in which the Subnet is located. -
Tags
: One or more tags associated with the Subnet.-
Key
: The key of the tag, with a minimum of 1 character. -
Value
: The value of the tag, between 0 and 255 characters.
-
-
{
"Subnets": [
{
"Tags": [],
"SubregionName": "eu-west-2a",
"SubnetId": "subnet-12345678",
"AvailableIpsCount": 16379,
"IpRange": "10.0.0.0/18",
"MapPublicIpOnLaunch": false,
"State": "available",
"NetId": "vpc-12345678"
}
],
"ResponseContext": {
"RequestId": "0475ca1e-d0c5-441d-712a-da55a4175157"
}
}
Getting Information About Your Subnets Using AWS CLI
Before you begin: Install and configure AWS CLI. For more information, see Installing and Configuring AWS CLI. |
To get information about one or more of your subnets, use the describe-subnets command following this syntax:
$ aws ec2 describe-subnets \
--profile YOUR_PROFILE \
--subnet-ids NOT_SPECIFIED \
--filters [
{
"Name": "vpc-id",
"Values": "vpc-12345678"
},
{
"Name": "state",
"Values": "available"
}
] \
--endpoint https://fcu.eu-west-2.outscale.com
This command contains the following attributes that you need to specify:
-
(optional)
profile
: The named profile you want to use, created when configuring AWS CLI. For more information, see Installing and Configuring AWS CLI. -
(optional)
subnet-ids
: One or more IDs of subnets.If you do not specify any subnet ID, all your subnets or all the subnets matching the specified filters (if any) are described.
-
(optional)
filters
: One or more filters, in the "Name=X,Values=Y" format.You can specify several values for a same filter using the "Name=X,Values=Y, Z" format.
The following filters are available:
-
subnet-id
: The ID of the subnet. -
vpc-id
: The ID of the VPC in which the subnet is. -
state
: The state of the subnet. For more information, see About Nets. -
cidr
: The exact CIDR block of the subnet (similar tocidr-block
). -
cidr-block
: The exact CIDR block of the subnet (similar tocidr
). -
available-ip-address-count
: The number of available IPs in the subnet. -
availability-zone
: The AZ in which the subnets are located.
-
-
endpoint
: The endpoint corresponding to the Region you want to send the request to. For more information, see Installing and Configuring AWS CLI.
The describe-subnets command returns the following elements:
-
Subnets
: Information about one or more subnets. This element contains the following information:-
VpcId
: The VPC in which the subnet is. -
CidrBlock
: The range of IPs for the subnet, in CIDR notation. -
State
: The state of the VPC. For more information, see About Nets. -
AvailabilityZone
: The AZ in which the subnet is. -
SubnetId
: The ID of the subnet. -
AvailableIpAddressCount
: The number of unused IPs in the subnet. -
MapPublicIpOnLaunch
: Specifies whether a public IP is assigned to the instances launched in the subnet.
-
{
"Subnets": [
{
"VpcId": "vpc-12345678",
"CidrBlock": "10.0.1.0/24",
"State": "available",
"AvailabilityZone": "eu-west-2a",
"SubnetId": "subnet-1234abcd",
"AvailableIpAddressCount": 242,
"MapPublicIpOnLaunch": false
},
{
"VpcId": "vpc-12345678",
"CidrBlock": "10.0.2.0/24",
"State": "available",
"AvailabilityZone": "eu-west-2b",
"SubnetId": "subnet-4321dcba",
"AvailableIpAddressCount": 243,
"MapPublicIpOnLaunch": false
}
]
}
Related Pages
Corresponding API Methods
AWS™ and Amazon Web Services™ are trademarks of Amazon Technologies, Inc or its affiliates in the United States and/or other countries.