# Private network with WireGuard

Connect your app on Estiba to a database on your own server, your home network or your other apps, encrypted, with WireGuard. Your agent sets it up.

## What it is for

WireGuard is a private, encrypted link between computers. With it, your app reaches addresses that are not on the internet, as if it were in the same room:

- **A database or a service on a server of yours**, at home or rented elsewhere, without opening its port to the whole internet.
- **Your home network**: a NAS, a printer, a computer that should stay private.
- **Your other apps on Estiba**, over a network only they share.

There is nothing extra to pay: traffic is free.

## Set it up

1. Ask your agent: "connect this app to my WireGuard network". If you already have one, give it a configuration for the app (a `.conf` file, from your WireGuard server or a panel such as wg-easy or WireGuard's own app). If not, your agent can write one for each side and tells you what to add on your server.
2. Your agent puts the configuration in the app's settings and deploys it. Every time the app starts, Estiba brings the tunnel up inside it, in `wg0`.
3. Your app reaches the other side by its private address, such as `10.8.0.1:3306` for a MySQL server on your network.

A configuration looks like this:

```
[Interface]
PrivateKey = <the app's private key>
Address = 10.8.0.2/24

[Peer]
PublicKey = <your server's public key>
Endpoint = vpn.example.com:51820
AllowedIPs = 10.8.0.0/24
PersistentKeepalive = 25
```

The configuration is stored encrypted. You see it in the dashboard, under Advanced, and so does your agent; a change applies when the app is deployed again.

## What your agent keeps in mind

- Only the networks in `AllowedIPs` go through the tunnel. The rest of the app's traffic, and its domains and ports, work as before; `0.0.0.0/0` and `::/0` do not send everything through it.
- `Address` and `MTU` apply. `DNS`, `Table`, `SaveConfig` and the `PreUp`, `PostUp`, `PreDown` or `PostDown` commands do not: the app uses the private IPs.
- Keep `PersistentKeepalive`, so the tunnel stays open from the app's side.
- The tunnel comes up a moment after the app starts, so the app should try its first connection again if it fails.
- If the configuration cannot be loaded, the app still runs, without the tunnel, and the reason is in its logs. Your agent reads them and fixes it.

## Between apps on Estiba

Apps on Estiba reach each other only at the ports they publish. To give two or more a private network of their own, each one publishes a UDP port, listens on it (`ListenPort`) and lists the others as peers at their Estiba address and public port, which stay the same when an app moves to another server. Each app lists every app it talks to: one does not pass traffic on to another.

For a database that only your apps on Estiba use, you don't need any of this: they reach it at its port. See [Deploy an app](https://estiba.cloud/docs/deploy-an-app).
