# Printers and legacy systems

_For tartan 0.9.36._

Printers, servers and appliances that can't run an agent are reached by name through a site gateway.

Printers, servers and appliances that can't run an agent are reached by name through a site gateway.

Each one is a **NAT resource**: a LAN IPv4 address at a site. By default it gets its own IPv6 address and a name,
such as `printer.acme.tartan.net`, and the site's gateways translate to the LAN with NAT64. Your IPv4 LANs keep
running as they are.

## Before you start

- The Owner or Admin role.
- A [site](add-site.md) whose LAN ranges hold the device's address.
- A [gateway](gateway-pairs.md) at that site, built with the NAT64 translator. Until one checks in, the resource is
  saved but unreachable, and `nat add` says so.

## 1. Add the resource

In the console, open **NAT** and choose **Add a NAT resource**. Pick the **Site**, enter the **LAN address** and a
**Name**, set its **Zone** and **Profiles**, then choose **Add**.

With the CLI (here the printer at 192.168.20.50 becomes `printer.acme.tartan.net`, reachable on 9100 and 631). When it
steps up, your passkey approves it.

```sh
tartan nat add --org acme --site warehouse --lan_ip 192.168.20.50 --name printer --ports 9100,631 --icon printer
```

- `--ports` are plain port numbers.
- `--zone` and `--profiles` place it in the firewall like any device: [Zones and firewall rules](firewall.md).
- `--icon` is how the console draws it: `printer`, `scale`, `camera` and others.
- Add `--dry-run` to see the change without making it.

An organization's first IPv6 NAT resource also gives the organization its IPv6 NAT address range, at once: nothing to
approve first. **New IPv6 NAT ranges come from `fd14:4fbb:fff0::/44`,** a block of Tartan's own address space set
aside for NAT, so other networking tools can keep clear of it. Each range is a random /64 from it, never used twice, and
each site gets its own part of it. An organization that already has a range keeps using it for new sites.

## 2. Many at once

Ten printers at one site can go in one batch, under one passkey prompt when it steps up. Put one command per line in a
file, `printers.txt`:

```text
nat add --site warehouse --lan_ip 192.168.20.50 --name printer-1 --ports 9100
nat add --site warehouse --lan_ip 192.168.20.51 --name printer-2 --ports 9100
```

```sh
tartan batch run --file printers.txt --dry-run
tartan batch run --file printers.txt
```

A batch runs 2 to 20 writes in your signed-in organization. The site must exist before the batch that adds its
resources.

## 3. An HTTPS front (optional)

A device's web page on the LAN (a printer's admin page on port 80) can be served over HTTPS under its name. The
gateways answer on 443 with their own certificate and pass the request to that port. When it steps up, your passkey
approves it.

```sh
tartan nat set --org acme --id <nat id> --https 80:http
```

`--https` is the LAN port and how the device speaks on it (`http` or `https`). `--no_https` removes the front.

## 4. Change or remove one

When it steps up, your passkey approves each change.

```sh
tartan nat list --org acme
tartan nat set --org acme --id <nat id> --ports 9100
tartan nat remove --org acme --id <nat id>
```

`--ports` and `--profiles` replace the whole list. A resource keeps its kind: to change between IPv6 and the older
IPv4 one-to-one path (`--ipv4`, no name), remove it and add it again.

A NAT resource stays inside your organization: it is never shared with a partner organization.

## 5. The IPv4 one-to-one path (optional)

Most organizations never need it: IPv6, the default, needs no IPv4 range. An `--ipv4` resource has no name and takes
an address from its site's IPv4 NAT range, and that range needs your organization's own IPv4 range.

An organization without one gets it from the Owner, from Tartan's pool: a /24 by default, `--size 23` or `22` for
more. It is a certificate-authority rotation: the Owner's passkey approves the request, then the new authority's
trust document, which the Owner finishes; then an Owner or Admin switches to it. The answer's `next` names each step.
Nothing changes until the switch; each device takes its IPv4 address at its next check-in.

```sh
tartan org v4 add --org acme
tartan approval approve --org acme --id <approval id>
tartan trust finish --org acme --approval <approval id>
tartan ca flip --org acme
```

After the switch (`tartan org show --org acme` lists `v4_prefix`; until then it shows `v4_staged`, and a second
`org v4 add` is refused), give the site its IPv4 NAT range (on its own, clear of your other ranges; `''` removes it while no IPv4 resource
uses it) and add the resource. Your passkey approves each:

```sh
tartan site set --org acme --site warehouse --nat_slice 198.51.100.0/24
tartan nat add --org acme --site warehouse --lan_ip 192.168.20.60 --ipv4 --ports 502
```

## Check it worked

```sh
tartan nat list --org acme
```

Each resource shows its address, name and site. From a device on your network, the name resolves and the port
answers. If it doesn't, check that the site's gateway is up ([Gateways in pairs](gateway-pairs.md)) and that the
device is on at that LAN address.

## Next

- [Gateways in pairs](gateway-pairs.md)
- [Add a site](add-site.md)
- [Site relays](site-relays.md)
