Manage private networks

Private networks are simpler than VLAN networks, and are the recommended way to privately connect VMs.


It is possible to create private networks between VMware servers. This allows them to communicate directly with each other without sending traffic over the public internet, thereby enhancing the security of the information exchanged between the servers.

Private networks are also divided into segments. When you create a private network, you must also create one or more segments within that network. Each segment is a unified entity that encompasses resources belonging to the same platform and data center.

Private networks are the recommended way to connect VMs. If you also need to connect physical hardware to your VMs, consider using VLAN networks instead.

Create private networks using the control panel

You find private networks under Networking in the left-hand menu. Click Private networks, and then click Create to create a new private network.

In the next step, name the network, for instance, test-net.

Once the private network is created, the segments within the network are displayed. No segments exist initially in a new private network—you need to create them yourself. A segment is a subdivision of the private network that allows you to partition it into smaller sections. Here, click + Create segment.

In the next dialog box, configure the settings for the segment. In this example, we name the segment lab and change the platform to VMware. In the dropdown menu for the data center, select the data center where your VMware servers are located; in this case, Falkenberg.

Under IP addresses, specify the network segment—the network and subnet mask—that you wish to use. In this example, we choose 192.168.0.0/24. This setup provides 251 usable IPv4 addresses for servers (256 addresses minus the addresses .0, .1, .2, .3, and .255). The first three addresses, .1, .2, and .3, are reserved for routing traffic between segments in the private network.

The network is complete, and you can see it in the overview of Private networks.

Connect VMs to a private network

To connect your virtual machines to the private network, you first need to create a new network adapter on each VM that will communicate with the others. The newly created network adapter on each VM is then connected to the private network, and we assign it an IP address within the same network as the one specified in the segment.

To create a new network adapter on a VM, first select the VM under ComputeVirtual machines. Here, click on the server where we want to create the network adapter.

Next, select the Network adapters tab and click + Create Network Adapter. The network adapter already visible in the list is used for internet connectivity.

In the dialog box that opens, select the type of adapter (VMXNET 3 is good for most situations), the connection type (Private network), and which network segment it should be connected to. Also, select the speed of the network adapter. Finally, click Create.

Once the adapter is created, it appears in the overview of all adapters for the VM. The standard adapter for internet connectivity and the new adapter for the private network are now shown.

Assign an IP address to the adapter in the VM's operating system

Before using the private network, you must assign an IP address within the segment you specified when creating the network to the new network adapter on each VM's operating system. The method for doing this varies between different systems.

After adding the adapter to the VM, you need to determine the adapter's name in Ubuntu. The easiest way to do this is by checking dmesg. Enter the following command:

The line you are looking for should resemble something like this:

This means the new adapter has been assigned the name ens224 in the system.

If, for some reason, the adapter cannot be found in the output from dmesg, it is also possible to list all adapters using the command ip addr. The adapter without an IP address is most likely the new one.

Once you know the adapter's name, add it to the file /etc/netplan/50-cloud-init.yaml. We must add the configuration for the new adapter ens224, and keep the configuration for ens192 as is.

Here, we assign ens224 the IP address 192.168.0.6 with the subnet mask /24 (255.255.255.0). Since this is a private network, assigning a gateway or DNS to the adapter is unnecessary.

The file should look like this (note that ens224 must be indented with the same amount of spaces as ens192):

Save the file and test the configuration with sudo netplan try. If you see the countdown timer, the file is likely correct; in this case, press the Enter key to confirm.

Next, we make sure the adapter has been assigned an IP address:

Finally, to prevent the settings from being overwritten by cloud-init, you must also execute the following command:

Finally, after all the servers have been assigned an IP address, you can ping them:

Delete a private network

To delete a private network, you must first delete all the network adapters that are connected to it. Then, you must delete the segments within the network. Finally, you can delete the network.

Start by deleting the network adapter from each VM that is connected to the private network. Click on the virtual machine in the overview, select the Network adapters tab, click the three dots next to the adapter connected to the private network's segment, and click Delete.

A dialog window will open where you need to confirm the deletion by typing the name of the adapter and clicking Delete.

Next, delete the segment within the network. Click Private networks in the left-hand menu to open an overview of all your private networks. Click on the network for which you want to delete the segment.

Delete the segment by clicking the three dots next to the segment name and selecting Delete.

In the next dialog box, confirm the deletion of the segment by typing the segment's name in the text field and clicking Delete.

Finally, delete the entire private network by clicking the three dots at the top of the network overview and selecting Delete.

In the next dialog box, confirm the deletion by typing the network's name in the text field and selecting Delete.

Create a private network using the API

To create a private network using the API, follow the same pattern as when creating a private network using the control panel.

  1. Create a new private network using the privatenetwork/create endpoint.

  2. Create a new segment within the private network, using the privatenetwork/createsegment endpoint.

  3. List the segments within the private network using privatenetwork/listsegments endpoint to get the ID of the segment.

  4. Create a new network adapter for the VM, using the networkadapter/create endpoint. For the network ID, use the segment ID from point 3 above.

Manage private networks using the API

Last updated

Was this helpful?