Create a virtual machine on a private network¶
This guide provides an example of how to create a virtual machine (VM) instance on a private network.
Create a virtual machine on a public network provides an example for creating a virtual machine instance and connecting it directly to the PublicEphemeral
network (a shared public network resource).
In this guide, you'll learn how to connect a virtual machine (running Ubuntu-22.04) to a private network. Creating a virtual machine on a private network lets you isolate your cloud resources from external networks and control ingress and egress to specific components such as the virtual machine.
You'll use the PublicStatic
external network to connect the private network to the internet. Since PublicStatic
does not allow the direct attachment of virtual machines, the network will connect using a router.
You'll learn how to:
- Create a network and subnet
- Create a router
- Create a security group
- Create a virtual machine instance using an Ubuntu image
- Add a floating IP address
- Access the virtual machine
- Tear down the setup
This guide assumes that:
- You're signed into Rumble Cloud
- You've created or uploaded an SSH key pair
If you haven't created a key pair, follow the instructions in Add an SSH Key Pair.
Create a network and subnet¶
- In the Rumble Cloud console, go to Network > Networks > Create Network.
- Give the network a name (for example,
howtoprivate
). You can optionally add a description. - Select the option to create a subnet. A subnet is used to attach the virtual machine to the network.
- Give the subnet a name (for example,
howtosubnet
). - Select
ipv4
for IP version. - CIDR is a method for allocating IP addresses. Since this example is creating a private network, it will use a well-known set of IP addresses that are only used privately (that is, not exposed to the internet or external networks). The default value suggested in the user interface (
198.168.0.0/24
) is part of range of well-known private addresses. For this example, use the value198.168.200.0/24
. - For DNS, use the valid public DNS server. For example, you can use
1.1.1.1
, which is Cloudflare's DNS resolver, or8.8.8.8
, which is a DNS server available from Google. - Select OK to create the network.
- You'll see the new network in the Networks dashboard under the Current Project Networks tab. Select the new network to view network details. From here you can see the subnet that was created (under the Subnets tab).
- You'll also see that a new port was created (under the Ports tab).
Create a router¶
- Go to Network > Routers > Create Router.
- Provide a name (for example,
howtorouter
). - Make sure
Attach to Public Network
is enabled. - The router will be attached to the
PublicStatic
network, which enables access to the public internet. - You'll see the new router listed in the Routers dashboard. Select More > Connect Subnet.
- Under the Current Project Networks tab, select the new network and the associated subnet. Select OK to connect the router to the subnet.
Create a security group¶
- Go to Network > Security Groups > Create Security Group. This security group will define ingress rules for port 22 on the virtual machine.
- You'll see the new security group in the dashboard. Select More > Create Rule.
- Provide the following values for the rule definitions. In this example, select
SSH
to enable SSH connection on port22
. All traffic will be allowed.- Protocol:
SSH
- Direction:
Ingress
- Ether Type:
IPv4
- Source:
All Traffic
-- this sets the remote IP prefix to0.0.0.0
and allows all traffic
- Protocol:
Create a virtual machine instance¶
- Select Compute > Instances.
- Select Create Instance.
- Select "us-east-1a" for the availability zone.
- Select "c2a.large" for the specification.
- Select "Ubuntu-22.0" for the operating system.
- Select "Flash_Premium" for the system disk type. Note that for the Ubuntu operating system, you’ll need at least 2.20 GiB for the image size. Select 10 GiB for Size. Adding the additional size will give you some extra space to make sure everything works.
- Check
Deleted with the instance
. The system disk is a storage volume that is attached to the instance at the time of creation. This value specifies that the storage volume is deleted when you delete the instance. - Click Next: Network Config.
- Select the new network list under the Current Project Networks tab.
- For subnets, select the option
Automatically Assigned Address
for the network. - For security group, select the default and the new security group (you can stack groups; default is always available).
- Select Next: System Config.
- For login, select
Keypair
and confirm your choice. Add your key pair for authentication. - Select Next: Confirm Config. You'll see a review of your virtual machine configuration. Select Confirm to create the virtual machine.
- You'll see the new VM in the Instances dashboard.
Add a floating IP address (FIP)¶
- Adjacent to the new virtual machine, select More > Related Resources > Associate Floating IP.
- For the instance IP, select the IP address listed with the new network.
- Select an allocated floating IP address. If there are no IP addresses available, select
+ Allocate IP
. - Select OK. You'll see the floating IP address listed in the Instances dashboard adjacent to the new virtual machine.
Use SSH to access the virtual machine¶
- From the Instances dashboard, copy the Floating IP address for the new instance.
-
Open the Terminal application. Type the following command, using the floating IP address you copied:
-
You’ll see a message about continuing. Type "yes". The command line prompt should now read:
-
Type
logout
to close the session.
Tear down the virtual machine instance and network¶
When removing cloud components from your project, you'll typically reverse the order of component creation. For this example, follow these steps.
- Delete the virtual machine.
- Release (de-allocate) the floating IP address.
- Disconnect the router from the subnet.
- Detach the router from the public network.
- Delete the router.
- Delete the network.