# Installation
## Download
```
HEADSCALE_VERSION="" # See above URL for latest version, e.g. "X.Y.Z" (NOTE: do not add the "v" prefix!)
HEADSCALE_ARCH="" # Your system architecture, e.g. "amd64"
wget --output-document=headscale.deb \
  "https://github.com/juanfont/headscale/releases/download/v${HEADSCALE_VERSION}/headscale_${HEADSCALE_VERSION}_linux_${HEADSCALE_ARCH}.deb"
```

## Install Headscale

```
apt install ./headscale.deb
```

## Enable service

```
systemctl enable headscale
```

## Config file

```
nano /etc/headscale/config.yaml
```

---

# Using Headscale
## Creating users

```
headscale users create matthiaspc
```

## Register machine (normal login)

On client:
```
tailscale up --login-server http://78.47.220.149:41111
```

On server:
```
headscale --user myfirstuser nodes register --key <YOUR_MACHINE_KEY>
```

## Register machine with pre auth key

On server:
```
headscale --user matthiaspc preauthkeys create --reusable --expiration 24h
```

On client:
```
tailscale up --login-server http://78.47.220.149:41111 --authkey <YOUR_AUTH_KEY>
```

---

# Exit Nodes
Setup client as exit node.

```
tailscale up --login-server http://78.47.220.149:41111 --advertise-exit-node
```

If client is allready registerd:
```
tailscale set --advertise-exit-node
```

On server:
```
headscale routes list
```

Für verfügbare Routen.
Route aktivieren:
```
headscale routes enable -r CLIENT_ID
```

## Set exit node

```
tailscale set --exit-node MACHINE_NAME
```

---
