configure storage and configure ai-servers find machines only over mDNS, which stays on the LAN, so a laptop away from home finds nothing. This skill holds the plan for also looking at the Core's tailnet: a lib/tailnet.sh helper, probing tailnet peers in find_servers and find_storage, listing a machine found both ways once, tests, and what to check against headscale (MagicDNS, Online, the agent sandbox). Nothing is built yet. Written from the MiniServer session, which now runs Tailscale and joins the Core's headscale. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
7.7 KiB
name, description
| name | description |
|---|---|
| coredesktop-tailnet-discovery | Plan and progress for making configure storage and configure ai-servers find servers on the Core's tailnet (Tailscale/headscale) as well as over mDNS, so a laptop away from home still finds the MiniServer and the LLM box. Use when resuming, continuing, checking the status of, or changing tailnet discovery, configure.d/lib/tailnet.sh, find_storage or find_servers. |
Find servers on the tailnet, not only the LAN
Where things stand
This plan was written on 2026-11-17 from the MiniServer session, against
CoreDesktop ffbaf71. Nothing in it was built then. Check before starting:
git -C ~/Projects/coredesktop fetch && git -C ~/Projects/coredesktop log --oneline origin/main -10
ls ~/Projects/coredesktop/configure.d/lib/tailnet.sh 2>/dev/null
grep -n 'tailnet' ~/Projects/coredesktop/configure.d/50-ai-servers.sh ~/Projects/coredesktop/configure.d/60-storage.sh
Map what you find onto the steps below, tell the user which step is next, and confirm before starting it.
Why
configure storage and configure ai-servers find machines only over mDNS
(configure.d/lib/mdns.sh, Avahi). mDNS is multicast and stays on the LAN:
Tailscale carries no multicast, so a laptop at a café, or a Core's machines in
different places, see nothing.
MiniServer (~/Projects/MiniServer, commit fb1b6e1) now runs Tailscale and
joins the Core's headscale with configure tailscale, the same way
CoreDesktop's configure.d/15-tailscale.sh does
(--login-server https://headscale.<domain>). Its firewalld rules
(firewall.conf) apply on tailscale0 as on the LAN, so what it allows (SSH and
SFTP on 22, Cockpit on 9090, listed ports) is what a tailnet peer can reach.
MiniServer also advertises _ssh._tcp, _sftp-ssh._tcp and _https._tcp
over mDNS, which CoreDesktop's find_storage already picks up on the LAN.
What exists today (at ffbaf71)
configure.d/lib/mdns.sh:mdns_services("name|type|host|address|port|txt"),mdns_hosts(other machines'.localnames),mdns_own_host.configure.d/50-ai-servers.sh:is_installediscommand -v avahi-browse.find_serversprobes everymdns_hostsentry onLLM_PORTS(11434 1234 8080 8000) in parallel withserver_models(curl /v1/models), printing "host:port|model count".sandbox_allow host:portadds the server to the agents'allowedDomains.
configure.d/60-storage.sh:find_storageprints "kind|host|name" for_smb._tcpand_sftp-ssh._tcp.find_and_addlists them as%-26shost plus kind, then callsadd_<kind> host.mount_pointandadd_sftp's label strip only.localfrom the host.
configure.d/15-tailscale.sh:joined()checksTAILSCALE_DOMAINandtailscale status --json.BackendState == "Running".tests/network.batsstubs avahi-browse (machinesllm,basement= this machine,pi-star,lab), curl and smbclient.
Steps
1. configure.d/lib/tailnet.sh
#!/bin/bash
#
# Purpose : Find the other machines on the Core's tailnet, for the configure.d
# items that find servers (storage, ai-servers) beyond the LAN that
# mDNS reaches. Source this file.
# The other online computers on the tailnet, one MagicDNS name per line
# (box.tail.example). Phones and tablets are left out: nobody serves files or
# models from them, and each one costs a probe. Nothing if Tailscale isn't
# installed or running.
tailnet_hosts() {
command -v tailscale > /dev/null || return 0
tailscale status --json 2> /dev/null \
| jq -r 'select(.BackendState == "Running") | .Peer // {} | .[]
| select(.Online)
| select(.OS | IN("linux", "macOS", "windows", "freebsd"))
| .DNSName | rtrimstr(".") | select(. != "")' 2> /dev/null \
| sort -u
}
# true if host $1 takes TCP connections on port $2 within 2 seconds
port_open() {
timeout 2 bash -c ': < "/dev/tcp/$1/$2"' 2> /dev/null
}
# The name to show and to use in paths: box.tail.example -> box, box.local -> box
short_host() {
echo "${1%%.*}"
}
2. configure ai-servers
find_servers: loop overmdns_hostsandtailnet_hoststogether (after the de-duplication in step 4). The parallel probing is unchanged.is_installed: true ifavahi-browseortailscaleis there.- The intro/"nothing found" text: mention that servers on the Core's network
(Tailscale) are looked for too, or that
configure tailscalewould let it find them away from home. sandbox_allowneeds nothing new if a tailnet name works inallowedDomains(see "To verify").
3. configure storage
-
find_storage: after the mDNS results, probe each tailnet host in parallel:for host in $(tailnet_hosts); do ( port_open "$host" 22 && echo "sftp|$host|$(short_host "$host")" port_open "$host" 445 && echo "smb|$host|$(short_host "$host")" ) & done waitKeep the overall
| sort -u. -
mount_pointandadd_sftp's Files label: useshort_hostinstead of${1%.local}, so a tailnet server mounts at/mnt/box, not/mnt/box.tail.example. Existing.localmounts keep their paths, sinceshort_host box.localis alsobox. -
find_and_add: say where each was found, e.g.box (Tailscale); widen or drop the%-26scolumn if tailnet names don't fit. -
A port answering on 22 isn't proof of SFTP, but
add_sftpalready checks the key over ssh and says what's wrong, so that's enough.
4. One machine found both ways
A MiniServer on the LAN appears as box.local (mDNS) and box.tail.example
(Tailscale). Recommended: list it once, by its tailnet name, since that
keeps working when the laptop leaves home and Tailscale connects directly on
the same LAN. Match on short_host, case-insensitively. This is the
user's call; ask before building it. The other option is to keep both and
let the user pick.
5. Tests in tests/network.bats
Stub tailscale to print a status --json with: an online Linux peer
(llm.tail.example, also on mDNS as llm.local), an online Linux peer only
on the tailnet (nas.tail.example), an offline peer, an online iOS peer, and
"Self". Stub port_open (or bash's /dev/tcp via a function override) so
nas answers on 22. Tests:
tailnet_hostslists online computers only, without the trailing dot.tailnet_hostsprints nothing whentailscaleis missing, or whenBackendStateisn'tRunning.find_serversprobes tailnet hosts too, andllmonce.find_storageaddssftp|nas.tail.example|nasand listsllmonce.mount_point nas.tail.exampleis/mnt/nas.
Run make check.
6. README and the MiniServer side
- README sections for storage and AI servers: they also find servers on the
Core's network once
configure tailscaleis done. - MiniServer needs no change for this. If MiniServer later syncs this change
(its
.claude/skills/coredesktop-sync), it has noconfigure storage, so only the shared lib and any ai-servers part would apply.
To verify (unconfirmed when written)
- MagicDNS in headscale. Names like
box.tail.exampleresolve only withdns.magic_dns: truein headscale's config. If they don't, use the peer's firstTailscaleIPsaddress instead ofDNSName, and showHostName. Onlinefrom headscale. Believed to be filled in like Tailscale's own control server does; if headscale leaves it false or missing, drop theselect(.Online)and let the 2-second probes time out offline peers.- The sandbox and tailnet names. Check that an agent run through
sandbox/agentreachesbox.tail.example:11434once it's inallowedDomains, i.e. that srt's proxy resolves MagicDNS names outside the sandbox. If not, allow the100.xaddress. - How long
find_storagetakes on a tailnet with ten or more peers.