> For the complete documentation index, see [llms.txt](https://pascalgolla.gitbook.io/knowledge/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://pascalgolla.gitbook.io/knowledge/network/virtual-networks.md).

# 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

```bash
ifconfig -a

ifconfig eth1 up
```

### Addressing a static IP and a subnet

```bash
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:

{% code title="/etc/netplan/\[file].yml" lineNumbers="true" %}

```yaml
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]
```

{% endcode %}

We will now add our vnet.

{% code title="/etc/netplan/\[file].yml" lineNumbers="true" %}

```yaml
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
```

{% endcode %}

Then apply the "netplan"

```bash
sudo netplan apply
```
