Virtual Networks

A guide of how to create virtual networks with the new ubuntu netplan

Setting up a network

This example uses a pre-created vNet of the server provider. Two servers are connected to the same vnet. However, this is only the interface. Every other setting must be done manually.

Finding the interface and enable it

ifconfig -a

ifconfig eth1 up

Addressing a static IP and a subnet

ifconfig eth1 10.0.1.2/24

Setting it to the config

The previous settings are temporary. To make it static update the configuration found in /etc/netplan/[somefile].yml.

The file should look similar to this:

/etc/netplan/[file].yml
network:
  version: 2
  renderer: networkd
  ethernets:
    eth0:
      addresses:
        - 10.10.10.2/24
      gateway4: 10.10.10.1
      nameservers:
          search: [mydomain, otherdomain]
          addresses: [10.10.10.1, 1.1.1.1]

We will now add our vnet.

/etc/netplan/[file].yml
network:
  version: 2
  renderer: networkd
  ethernets:
    eth0:
      addresses:
        - 10.10.10.2/24
      gateway4: 10.10.10.1
      nameservers:
          search: [mydomain, otherdomain]
          addresses: [10.10.10.1, 1.1.1.1]
    eth1:
      addresses:
        - 10.0.1.2/24

Then apply the "netplan"

sudo netplan apply

Last updated