Create your own VPC when you want to choose its address range or control which subnets reach the internet. A new VPC comes with a first subnet, so you add subnets only when you need more than one.
Before you begin
Creating VPCs and subnets doesn’t require a payment method.
Create the VPC
-
Create the VPC. Pass
--ipv4-cidrto choose the IPv4 range, or leave it out to get a random/16from172.16.0.0/12.terminal origin network create-vpc --project-urn <project-urn> \ --ipv4-cidr 10.0.0.0/16 -
Note the VPC’s URN from the output, and find its first subnet:
terminal origin network list-subnets --project-urn <project-urn> -
Verify the VPC with
get-vpc. Itsipv4Networkshows the range and the subnet size.terminal origin network get-vpc --vpc-urn <vpc-urn>
The VPC has no Internet Gateway. To give it internet access, see Internet access.
Add a subnet
-
Create the subnet.
--auto-assign-public-ipis required:truegives every instance launched into the subnet a Floating IP automatically,falsedoesn’t.terminal origin network create-subnet --vpc-urn <vpc-urn> \ --auto-assign-public-ip falseThe platform picks the subnet’s ranges from the VPC. If the VPC has no room left, the command is refused; see When address space runs out.
-
Verify the subnet. Its
ipv4Network,ipv4Routerandipv4DnsServersshow its range, gateway and resolver.terminal origin network get-subnet --subnet-urn <subnet-urn>
An automatic public IP is only useful if the VPC has an Internet Gateway. For how auto-assigned addresses behave, see Default VPC.
Change a subnet’s auto-assign setting
-
Set the new value with
trueorfalse:terminal origin network update-subnet-auto-assign-public-ip \ --subnet-urn <subnet-urn> --auto-assign-public-ip true -
Verify that the subnet’s
autoAssignPublicIpfield shows the new value:terminal origin network get-subnet --subnet-urn <subnet-urn>
The change applies only to instances launched afterwards. To give a running instance a public address, associate a Floating IP with its interface; see Floating IPs.
Next steps
- Launch an instance into the subnet with
--subnet-urn - Attach and detach an Internet Gateway