# Virtual Networks

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


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://pascalgolla.gitbook.io/knowledge/network/virtual-networks.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
