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:

  1. Create a Net. For more information, see Creating a Net.

  2. (optional) To disable the network enhancement allowing virtual machines (VMs) of a same Subnet to communicate with one another without security group rules required, add a tag to your Net with osc.fcu.enable_lan_security_groups as key. For more information about how to add a tag, see Adding or Removing Tags. For more information about this network enhancement, see About VPCs > Subnet Routing and Security.

    • This tag must be added to your Net before creating Subnets into it.

    • The value of this tag is not taken into account, you can therefore specify any value for this tag.

  1. In the Nets dashboard, click the ID of the Net in which you want to create a Subnet.
    The Subnet panel appears.

  2. Click IconAddFull Create Subnet.
    The CREATE SUBNET dialog box appears.

  3. 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.

  4. 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.

  5. In the Subregion list, select the Subregion in which you want to create the Subnet.

  6. Click Create Subnet.
    The Subnet is created in the Net.

Creating a Subnet Using OSC CLI

Before you begin:

  1. Create a Net. For more information, see Creating a Net.

  2. (optional) To disable the network enhancement allowing virtual machines (VMs) of a same Subnet to communicate with one another without security group rules required, add a tag to your Net with osc.fcu.enable_lan_security_groups as key. For more information about how to add a tag, see Adding or Removing Tags. For more information about this network enhancement, see About VPCs > Subnet Routing and Security.

    • This tag must be added to your Net before creating Subnets into it.

    • The value of this tag is not taken into account, you can therefore specify any value for this tag.

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.

Request sample
$ 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.

  • Subnet: Information about the Subnet.

Result sample
{
  "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:

  1. Create a VPC. For more information, see Creating a Net.

  2. (optional) To disable the network enhancement allowing instances of a same subnet to communicate with one another without security group rules required, add a tag to your VPC with osc.fcu.enable_lan_security_groups as key. For more information about how to add a tag, see Adding or Removing Tags. For more information about this network enhancement, see About VPCs > Subnet Routing and Security.

    • This tag must be added to your VPC before creating subnets into it.

    • The value of this tag is not taken into account, you can therefore specify any value for this tag.

To create a subnet, use the create-subnet command following this syntax:

Request sample
$ 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.

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.

Result sample
 {
    "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.