Creating a Subnet in a Net
You can create one or more Subnets in a Net to be able to launch resources into it. Subnets are placed on Subregions of the Region of your Net.
Once your Subnet is created, it is recommended to create a security group and a route table dedicated to it. For more information, see Creating a Security Group and Creating a Route Table.
Creating a Subnet Using Cockpit v2
Before you begin:
|
-
In the Nets dashboard, click the image:IconView.svg{} details icon of the Net in which you want to create a Subnet.
The Subnet panel appears. -
Click Create Subnet.
The CREATE SUBNET dialog box appears. -
In the Name field, type a name for the Subnet.
This action adds a Name tag of 255 characters maximum. You can use any character, including accented letters.
-
In the IP range field, type the range of IPs for the Subnet, in CIDR notation.
-
The Subnet CIDR block must be part of the Net CIDR block.
-
If you create several Subnets in a Net, their CIDR blocks must not overlap.
-
-
In the Subregion list, select the Subregion in which you want to create the Subnet.
-
Click Create Subnet.
The Subnet is created in the Net.
Creating a Subnet Using OSC CLI
Before you begin:
|
The CreateSubnet command creates a Subnet in an existing Net.
To create a Subnet in a Net, you have to provide the ID of the Net and the IP range for the Subnet (its network range). Once the Subnet is created, you cannot modify its IP range.
For more information, see About Nets.
$ osc-cli api CreateSubnet --profile "default" \
--NetId "vpc-12345678" \
--IpRange "10.0.0.0/18"
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. -
IpRange
: The IP range in the Subnet, in CIDR notation (for example,10.0.0.0/16
).
The IP range of the Subnet can be either the same as the Net one if you create only a single Subnet in this Net, or a subset of the Net one. In case of several Subnets in a Net, their IP ranges must not overlap. The smallest Subnet you can create uses a /29 netmask (eight IPs). For more information, see About Nets. -
NetId
: The ID of the Net for which you want to create a Subnet. -
SubregionName
: (optional) The name of the Subregion in which you want to create the Subnet.
The CreateSubnet command returns the following elements:
-
ResponseContext
: Information about the context of the response.-
RequestId
: The ID of the request.
-
-
Subnet
: Information about the Subnet.-
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.
-
-
{
"Subnet": {
"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"
}
}
Creating a Subnet Using oapi-cli
Before you begin:
|
The CreateSubnet command creates a Subnet in an existing Net.
To create a Subnet in a Net, you have to provide the ID of the Net and the IP range for the Subnet (its network range). Once the Subnet is created, you cannot modify its IP range.
For more information, see About Nets.
$ oapi-cli --profile "default" CreateSubnet \
--NetId "vpc-12345678" \
--IpRange "10.0.0.0/18"
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. -
IpRange
: The IP range in the Subnet, in CIDR notation (for example,10.0.0.0/16
).
The IP range of the Subnet can be either the same as the Net one if you create only a single Subnet in this Net, or a subset of the Net one. In case of several Subnets in a Net, their IP ranges must not overlap. The smallest Subnet you can create uses a /29 netmask (eight IPs). For more information, see About Nets. -
NetId
: The ID of the Net for which you want to create a Subnet. -
SubregionName
: (optional) The name of the Subregion in which you want to create the Subnet.
The CreateSubnet command returns the following elements:
-
ResponseContext
: Information about the context of the response.-
RequestId
: The ID of the request.
-
-
Subnet
: Information about the Subnet.-
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.
-
-
{
"Subnet": {
"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"
}
}
Creating a Subnet Using AWS CLI
Before you begin:
|
To create a subnet, use the create-subnet command following this syntax:
$ aws ec2 create-subnet \
--profile YOUR_PROFILE \
--vpc-id vpc-12345678 \
--cidr-block 10.1.0.0/24 \
--availability-zone eu-west-2a \
--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. -
vpc-id
: The ID of the VPC in which you want to create the subnet. -
cidr-block
: The range of IPs for the subnet, in CIDR notation.-
The subnet CIDR block must be part of the VPC CIDR.
-
If you create several subnets in a VPC, their CIDR blocks must not overlap.
-
-
(optional)
availability-zone
: The AZ in which you want to create the subnet.If you do not specify any Subregion, the Subregion A is used by default.
-
endpoint
: The endpoint corresponding to the Region you want to send the request to. For more information, see Installing and Configuring AWS CLI.
The create-subnet command returns the following elements:
-
Subnet
: Information about the newly created subnet. 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 subnet. 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.
-
{
"Subnet": {
"VpcId": "vpc-12345678",
"CidrBlock": "10.1.0.0/24",
"State": "available",
"AvailabilityZone": "eu-west-2a",
"SubnetId": "subnet-87654321",
"AvailableIpAddressCount": 242
}
}
The subnet is created.
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.