Gateway (create a zone)
A zone is a subnet, with a gateway, behind which you connect as many machines as you like. The first gateway is installed from the administration workstation, set up next to it, without a coordination server.
darkone add gateway does everything from the administration workstation : pairing the machine, declaring it in etc/config.yaml, installation, recabling, checks. The manual variant remains possible.
Hardware
Section titled “Hardware”The gateway is ideally installed on a mini-computer that is always on, with at least two network interfaces: one to the ISP box (WAN), the others to the local network (LAN, ethernet or wifi).
Wiring
Section titled “Wiring”The gateway’s WAN connects to the box ; the entire local network is behind it.
- The box Wi-Fi remains outside the zone: its devices do not receive an address from the gateway.
- A Wi-Fi access point connects behind the gateway, without DHCP.
- The switch is optional : a workstation can be plugged into a LAN port.
Install with the wizard
Section titled “Install with the wizard”darkone add gateway runs on the administration workstation, in the project
(/etc/nixos). It only asks for the machine’s address and its code.
-
Connect
The gateway’s WAN to the box. The administration workstation stays on the box (cable or Wi-Fi).
-
Boot
On the generic ISO, written to a USB key, entry 2) Add this machine to an existing network from the menu (or
dnf-pair). The screen gives the address and the pairing code :- IP: 192.168.1.50Pairing code: 123456-7890 (10 min, a new one after) -
Run
Fenêtre de terminal cd /etc/nixosdarkone add gatewayThe wizard asks for the address, then the code. It probes the machine and suggests the name (
gw), the WAN (the card carrying the route to the box), the LAN (the other wired cards) and the disk (a question if there are several). -
Confirm
The summary names the disk to be erased and the final choices. Then comes the diff of
etc/config.yaml, with a second confirmation : nothing is written before that. -
Recable
At the prompt Now unplug this machine from the box and plug it into a LAN port of gw, connect the administration workstation to a LAN port of the gateway. The wizard resumes on its own, applies this workstation (
just apply-local) and checks the network.
The final message, Step 2 of 4 done, announces step 3.
The pairing code
Section titled “The pairing code”The code PPPPPP-FFFF proves that the typed address is the right machine before
any key is sent.
| Part | Role |
|---|---|
PPPPPP | nixos password, single-use, valid for 10 min |
FFFF | host key fingerprint, verified by the workstation |
The workstation computes FFFF from the key it reads on the network : if it
differs, nothing is sent. Otherwise it pushes its deployment key
(usr/secrets/nix.pub) and locks the password ; the screen displays
Paired. The verified host key is then kept until the end of the
installation. An already-paired machine does not ask for a code again.
Dry run, answers
Section titled “Dry run, answers”--dry-run pairs and probes the machine, then displays the plan, the diff of
etc/config.yaml and the commands of a real run. Nothing is written to the
project ; the machine itself stays paired.
An answers file replaces the questions. The pairing code never goes in it : it is typed on the terminal.
version: 1address: "192.168.1.50" # address displayed by the machinehost: hostname: "gw" # optionalnics: wan: "enp1s0" # optional : the card carrying the route lan: ["enp2s0"] # always to be givendisk: device: "/dev/disk/by-id/nvme-Example_SSD_256GB_S4EXAMPLE0001" # optional : a single disk ≥ 20 GBconfirm: true # required with --non-interactivedarkone add gateway --answers reponses.yaml --dry-rundarkone add gateway --answers reponses.yaml --non-interactiveconfirm: trueskips both confirmations (the diff is still displayed) ; without it,--non-interactiverefuses to start.- An unknown key is rejected ; all errors are listed at once.
Refusal
Section titled “Refusal”The wizard refuses before writing when :
| Case | What to do |
|---|---|
| Repository not clean | commit or stash |
| Gateway already there, or several zones | declare by hand |
| Box network in the zone | change the box network |
| Fewer than two wired cards | use a machine with two cards |
| Machine in BIOS | switch the firmware to UEFI |
The zone prefix is final : if the box overlaps it, the box is the one that
moves. The server-1-disk layout requires UEFI. Disks smaller than
20 GB (USB key) are not offered.
Written to the project
Section titled “Written to the project”After confirmation, the wizard writes to etc/config.yaml the zone’s gateway
block and the gw host (<zone>:1.1). The administration workstation receives
its fixed address (<zone>:2.1) and its mac if they are missing. Then just clean
and the commit chore(gateway): add gw.
Recovery after failure
Section titled “Recovery after failure”The failure message lists the remaining commands, in order.
| Failure | State | Recovery |
|---|---|---|
| Before writing | nothing changed | rerun |
just clean, commit | file written, nothing committed | continue by hand, or git stash --include-untracked then rerun |
just full-install | declaration committed | just full-install gw nixos <ip>, then just apply-local |
just apply-local | gateway installed | just apply-local |
| Checks | gateway installed | the remedy follows each check |
Once the declaration is committed, darkone add gateway refuses to replay (the
zone has its gateway) : recovery is done by hand, and asks the formatting
question again. The checks verify the default route (the gateway), the
resolution of gw and access to the Internet.
Manual variant
Section titled “Manual variant”Without the wizard, the same installation is done recipe by recipe : the
declaration in etc/config.yaml comes before just full-install.
Prepare the gateway
Section titled “Prepare the gateway”-
Connect
The gateway’s WAN to the box. The administration workstation stays on the box (cable or Wi-Fi).
-
Boot
On the ISO, written to a USB key. The screen gives what needs to be declared :
- IP: 192.168.1.50- MAC: aa:bb:cc:dd:ee:01Network cards (wan.interface, lan.interfaces):NAME MAC LINK IPV4 NOTEenp1s0 aa:bb:cc:dd:ee:01 up 192.168.1.50/24 default route (WAN)enp2s0 aa:bb:cc:dd:ee:02 down -Disks (disko.devices), installation medium left out:/dev/disk/by-id/nvme-Example_SSD_256GB_S4EXAMPLE0001239G Example SSD 256GB [nvme0n1]Line Used for - IP:just full-installNetwork cards wan.interface,lan.interfacesDisks disko.devices(path to copy)The card marked default route (WAN) carries the route to the box : that is the WAN, the other wired ones are the LAN.
dnf-netinforedisplays the screen. With the generic ISO, the menu entry 2) Add this machine to an existing network displays the same tables.The screen also displays the pairing code (
Pairing code: PPPPPP-FFFF) :just full-installasks for it at step 4, nothing to authorize before. Thejust build-isoimage already carries the key : no code.
Declare the zone
Section titled “Declare the zone”Everything is declared before installation : the gateway is born with the administration workstation’s reservation, which receives its fixed address as soon as it is recabled.
-
Declare
In
etc/config.yaml: the zone’sgatewayblock, thegwhost, and a fixed address for the administration workstation.etc/config.yaml zones:main:description: "Main network"ipPrefix: "10.0" # zone in 10.0.0.0/16gateway:wan:interface: "enp1s0" # card to the boxlan:interfaces: ["enp2s0"] # cards to the local networkhosts:- hostname: "gw"name: "Passerelle"zone: "main:1.1" # fixed IP 10.0.1.1profile: "gateway"disko:profile: "server-1-disk"devices:main: "/dev/disk/by-id/nvme-Example_SSD_256GB_S4EXAMPLE0001"- hostname: "admin" # the administration workstationzone: "main:2.1" # was "main" : fixed IP 10.0.2.1mac: "aa:bb:cc:dd:ee:ff" # unchanged# … the rest is unchangedNo
macfor the gateway : its LAN address is fixed (1.1) and its WAN address comes from the box.Fenêtre de terminal just cleangit add . && git commit -m "host(gw): passerelle"
Install the gateway
Section titled “Install the gateway”-
Install
Fenêtre de terminal just full-install gw nixos 192.168.1.50gw: declared hostname.nixos: the ISO’s user.192.168.1.50: the- IP:line of the screen.
Before the formatting question, the recipe announces the recabling : get the cable ready now. The disk is then formatted, the system installed, then the gateway reboots.
If the box network overlaps the zone’s (the box in
10.0.0.0/16), the recipe refuses before any formatting : WAN and LAN would be on the same network.Cannot install gw on 10.0.0.50: the box network (10.0.0.0/24 on enp1s0) overlapszone 'main' (10.0.0.0/16), so its WAN and LAN would share one network.The zone prefix is final : change the box network (subnet or DHCP range), reboot the ISO, start over.
-
Recable
At the prompt Now unplug this machine from the box and plug it into a LAN port of gw, unplug the administration workstation from the box and plug it into a LAN port of the gateway (or of the switch). Nothing to press : the recipe waits up to 30 minutes for
10.0.1.1to respond, then runsconfigure,applyand a final reboot.No response after 30 minutes :
Fenêtre de terminal just configure gw 10.0.1.1just apply gwThis pause only happens if the gateway keeps its SSH closed on the box side (coordination inactive, or
gateway.vpn.ipv4already declared) : see SSH access according to role. -
Finish
Fenêtre de terminal just apply-localThe administration workstation takes its fixed address (
10.0.2.1).
Disk encryption
Section titled “Disk encryption”For a first gateway, prefer a plain disk (server-1-disk) :
it reboots on its own after a power outage, otherwise the network stays
down until someone types the passphrase. Encryption and
remote unlocking are described in
Disk encryption (LUKS).
Installing from another zone
Section titled “Installing from another zone”A gateway is often prepared elsewhere than at its destination. Connect its WAN interface to the local network of the host zone : it receives there the gateway address that this zone reserves for it based on its MAC. Here, the gateway’s mac key (the - MAC: line on the ISO screen) remains useful.
Three conditions :
- the gateway’s
mackey is declared inetc/config.yaml; - the host zone’s gateway has been redeployed from this declaration;
- the administration machine too, so that SSH reads the redirection set up during installation.
Then, just full-install gw needs no address : the tooling computes the target and follows it from start to finish. The principle is described in Machines outside their zone.
Installing remotely
Section titled “Installing remotely”Someone on site connects the gateway to the box and starts it on the just build-iso image (it carries the deployment key) ; the administrator installs over SSH. This path requires active coordination (HCS) and gateway.vpn.ipv4 not declared : otherwise SSH stays closed on the box side once the gateway is installed.
- Redirect port 22 of the box to the gateway.
- Install with the box’s public IP address :
just full-install gw nixos <ip-publique>. - Remove the redirection after declaring
gateway.vpn.ipv4and applying : the gateway no longer responds from the Internet, access goes through the VPN (just enter gw).
Enroll the gateway on the VPN
Section titled “Enroll the gateway on the VPN”A gateway is a Tailscale client: it advertises its zone’s subnet in the
tailnet. As long as it is not enrolled
there, the other zones cannot see it. just full-install enrolls it on the
way ; otherwise, or to check :
just tailnet-enroll gwAll that remains is to declare its tailnet address: see Enregister a gateway.
Connecting other machines
Section titled “Connecting other machines”- Linux hosts: see Add a machine.
- Smartphones, tablets, third-party PCs: connect automatically to the gateway’s network.
Replacing the hardware
Section titled “Replacing the hardware”Replacing the computer of a gateway in service is a distinct procedure : the machine is new, but its state is not. See Migrating a gateway’s hardware.
A typo in the code?
Section titled “A typo in the code?”A wrong code costs 10 seconds of waiting (PAM delay), and the wizard allows three attempts. A wrong code and an expired code give the same refusal : reread the screen. After six 10-minute codes, pairing closes ; the machine’s dnf-pair command generates a new one.
“not the machine whose screen shows this code”?
Section titled ““not the machine whose screen shows this code”?”The FFFF fingerprint of the code does not match the machine responding at this address : another device on the network, incorrectly recorded address. Nothing was sent ; check the address on the screen.