copyright | lastupdated | ||
---|---|---|---|
|
2018-07-03 |
{:shortdesc: .shortdesc} {:new_window: target="_blank"} {:codeblock: .codeblock} {:pre: .pre} {:screen: .screen} {:tip: .tip} {:download: .download}
This guide shows you how to create and configure an {{site.data.keyword.cloud}} IBM Virtual Private Cloud (VPC) using {{site.data.keyword.cloud_notm}} console.
Follow these steps to create and configure your VPC:
- Create a VPC and subnet to define the network.
- Configure an access control list (ACL) to limit the subnet's inbound and outbound traffic. By default, all traffic is allowed.
- Create a virtual server instance.
- Configure a security group to define the inbound and outbound traffic that is allowed for the instance.
- Reserve and associate a floating IP address to enable your instance to communicate with the Internet.
Ensure that you have sufficient permissions to create and manage resources in your VPC. For a list of required permissions, see Granting permissions needed for VPC users.
Generate an SSH key, which will be used to connect to the virtual server instance. For example, generate an SSH key on your Linux server by running the command ssh-keygen -t rsa -C "user_ID"
. That command generates two files. The generated public key is in the <your key>.pub
file.
Go to the VPC Getting Started page in {{site.data.keyword.cloud_notm}} console.
To create a VPC and subnet:
- Click Create VPC on the Getting Started page.
- Enter a name for the VPC, such as
my-vpc
. - Select or create the default ACL for new subnets in this VPC. In this tutorial, let's create a new default ACL. We'll configure rules for the ACL later.
- Enter a name for the new subnet in your VPC, such as
my-subnet
. - Select a location for the subnet. The location consists of a region and a zone. For this Beta release, only one location is available.
- Enter an IP range for the subnet in CIDR notation, for example:
10.240.0.0/22
. The value must be within the IP range that is listed for the selected location. - Select an ACL for the subnet. Let's select Use VPC default to use the default ACL that will be created for this VPC.
- Attach a public gateway to the subnet to allow all attached resources to communicate with the public Internet.
- Click Create virtual private cloud.
Tip: To create another subnet in this VPC, click the Subnets tab and click New subnet. When you define the subnet, make sure to select my_vpc
in the Virtual private cloud field.
You can configure the ACL to limit inbound and outbound traffic to the subnet. By default, all traffic is allowed.
Only one ACL can be attached to a subnet at any time. However, one ACL can be attached to multiple subnets.
To configure the ACL:
- On the VPC and subnets page, click the Subnets tab.
- Click the subnet that you created.
- In the Subnet details area, click the name of the ACL.
- Click Add rule to configure inbound and outbound rules that define what traffic is allowed in or out of the subnet. For each rule, specify the following information:
- Specify the rule's priority. Rules with lower numbers are evaluated first and override rules with higher numbers. For example, if a rule with priority 2 allows HTTP traffic and a rule with priority 5 denies all traffic, HTTP traffic is still allowed.
- Select whether to allow or deny the specified traffic.
- Specify a CIDR block to indicate the IP range that the rule applies to.
- Select which protocols and ports the rule applies to.
- When you finish creating rules, click the All access control lists breadcrumb at the top of the page.
For example, you can configure inbound rules that do the following:
- Allow HTTP traffic from the Internet
- Allow all inbound traffic from the subnet 10.10.20.0/24
- Deny all other inbound traffic
Then, configure outbound rules that do the following:
- Allow HTTP traffic to the Internet
- Allow all outbound traffic to the subnet 10.10.20.0/24
- Deny all other outbound traffic
To create a virtual server instance in the newly created subnet:
-
Click Virtual server instance in the navigation panel and click New instance.
-
Enter a name for the instance, such as
my-instance
. -
Select the VPC that you created.
-
Note the Location field (read-only) that shows the location of the subnet on which the instance is created.
-
Select an image (that is, operating system and version) such as Ubuntu 16.04.
-
Select one of the popular profiles, or click All profiles to choose a different core and RAM combination that is most appropriate for your workload.
-
Select an existing SSH key or add an SSH key that will be used to access the virtual server instance. To add an SSH key, click Add SSH key and name the key. After you enter your previously generated public key value, click Add SSH key.
-
Optional: Enter user data or metadata for the instance. This data is typically used with custom provisioning scripts. For more information, see User Data.
-
Note the boot volume. For the Beta release, 100 GB is allotted for the boot volume.
-
In the Network interfaces area, you can change the name and port speed of the interface. If you have more than one subnet in your VPC, you can select the subnet that you want to attach to the instance.
You can also select which security groups to attach to this instance. By default, the VPC's default security group is attached. The default security group allows inbound SSH and ping traffic, all outbound traffic, and all traffic between instances in the group. All other traffic is blocked; you can configure rules to allow additional traffic. If you later edit the rules of the default security group, those updated rules will apply to all current and future instances in the group.
-
Click Create virtual server instance.
You can configure the security group to define the inbound and outbound traffic that is allowed for the instance.
To configure the security group:
-
On the Virtual server instances page, click your new instance to view its details.
-
In the Network interfaces section, click the security group.
-
Click Add rule to configure inbound and outbound rules that define what traffic is allowed to and from of the instance. For each rule, specify the following information:
- Select which protocols and ports the rule applies to.
- Specify a CIDR block or IP address for the permitted traffic. Alternatively, you can specify a security group in the same VPC to allow traffic to or from all instances of the selected security group.
Tips:
- All rules are evaluated, regardless of the order in which they are added.
- Rules are stateful, which means that return traffic in response to allowed traffic is automatically permitted. For example, a rule that allows inbound TCP traffic on port 80 also allows replying outbound TCP traffic on port 80 back to the originating host, without the need for an additional rule.
- Optional: If you want to attach this security group to other instances, click Attached interfaces in the navigation panel and select additional interfaces.
- When you finish creating rules, click the All security groups breadcrumb at the top of the page.
For example, you can configure inbound rules that do the following:
- Allow all SSH traffic (TCP port 22)
- Allow all ping traffic (ICMP type 8)
Then, configure outbound rules that allow all TCP traffic.
Reserve and associate a floating IP address to enable your instance to be reachable from the Internet.
Tip: Your instance must be running before you can associate a floating IP address. It can take a few minutes for the instance to be up and running.
To reserve and associate a floating IP address:
- In the left navigation pane, click Floating IP.
- Click Reserve floating IP.
- Select the instance that you just created and its network interface that you want to associate with the floating IP address.
- Click Reserve IP. The new IP address is displayed on the Floating IPs page.
Using the floating IP address that you created, ping your instance to make sure it's up and running:
ping <public ip address>
Since you provisioned your instance with a public SSH key, you can now connect to it directly by using your private key:
ssh -i <path to your private key file> root@<public ip address>
You've successfully created and configured a VPC and subnet, an ACL, a virtual server instance, security group, and floating IP address. You can continue to develop your VPC by adding more instances, subnets, and other resources.