Skip to content
eripaPublic

About

Run multiple Minecraft (Bedrock) servers on a single LAN host.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

104 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

rustmine: Minecraft Bedrock multiplexer

ci release

Puts every world on your Bedrock server into one LAN Games list, without proxying gameplay. Under the hood it is a NetherNet LAN discovery and signaling multiplexer for Bedrock Dedicated Server (BDS) 1.26.50 and later.

rustmine restores what manymine provided under RakNet. Bedrock clients discover LAN worlds over UDP 7551; a world replies with an opaque advertisement and no address or port, and the client then signals to the pong's source address. rustmine answers one discovery request with one pong per configured world, from a dedicated socket per world, and relays the encrypted SDP (Session Description Protocol) offer/answer/candidate datagrams by network ID.

It is not a game proxy: each world's own BDS still terminates its WebRTC connection, and gameplay traffic flows directly from the client to that world. rustmine never decrypts, rewrites, or forwards gameplay packets.

How it works

The diagram shows two worlds; every configured world follows the same path.

sequenceDiagram
    autonumber
    participant C as Game client
    participant R as rustmine
    participant A as World A (BDS)
    participant B as World B (BDS)

    Note over R,B: every probe_interval, over a socket per world
    R->>A: discovery request (UDP 7551)
    A-->>R: advertisement, cached
    R->>B: discovery request
    B-->>R: advertisement, cached

    C->>R: discovery request, broadcast UDP 7551
    R-->>C: A's cached pong, from A's socket
    R-->>C: B's cached pong, from B's socket

    C->>R: SDP offer to A's pong source port
    R->>A: relayed verbatim
    A-->>R: SDP answer and candidates
    R-->>C: relayed verbatim

    C->>A: WebRTC connects to A directly, using that answer
    Note over C,A: gameplay now flows from client to world,<br/>and rustmine is not on that path
Loading

The client learns where to signal from the pong's source port, not from the advertisement, which is why the router needs one socket per world.

Install

Prebuilt Linux binaries (x86_64 and aarch64) are attached to every release, with a SHA256SUMS file. The example below pins v0.1.0; substitute the current tag.

curl -LO https://github.com/eripa/rustmine/releases/download/v0.1.0/rustmine-v0.1.0-x86_64-unknown-linux-gnu.tar.gz
tar xzf rustmine-v0.1.0-x86_64-unknown-linux-gnu.tar.gz
cd rustmine-v0.1.0-x86_64-unknown-linux-gnu
./rustmine check --config rustmine.yaml

The same tag publishes the container image to GHCR:

docker run --rm ghcr.io/eripa/rustmine:v0.1.0 check --config /config/rustmine.yaml

From source (Rust 1.88 or newer):

git clone https://github.com/eripa/rustmine.git
cd rustmine
cargo build --release

The submodules under vendor/ are agent skills, not build inputs — a plain clone builds. just init fetches them if you also want the chat skills.

Quick start

cargo run -- check --config config/rustmine.yaml   # validate and exit
cargo run -- run   --config config/rustmine.yaml   # run the router

The binary takes --config or RUSTMINE_CONFIG (default /etc/rustmine/config.yaml).

While running:

  • GET http://127.0.0.1:9101/healthz — 200 once the discovery socket is bound.
  • GET http://127.0.0.1:9101/readyz — 200 once every enabled provider has reconciled at least once.
  • GET http://127.0.0.1:9101/status — JSON: version, listen address, providers, backends (network ID, reachability, last-seen age), and counters. Advertisement fields are not parsed in v1, so advertisement is omitted; a backend's identity comes from its network ID and address.

Observability

Metrics

GET http://127.0.0.1:9101/metrics — Prometheus text exposition, served on status_listen next to the endpoints above. It is loopback-bound exactly like /status; moving status_listen is how you expose it. The endpoint has no authentication, so anything that can reach the listener can read every series.

Metric Type Labels Meaning
rustmine_discovery_requests_total counter — Valid discovery requests received.
rustmine_responses_sent_total counter — Cached discovery responses sent to clients.
rustmine_signals_forwarded_total counter — Signaling datagrams forwarded.
rustmine_signals_dropped_total counter reason Signaling datagrams dropped, by reason.
rustmine_provider_reconcile_errors_total counter provider Provider reconciles that failed.
rustmine_connector_start_errors_total counter provider Connectors that could not be started.
rustmine_backend_address_conflicts_total counter provider Backends dropped because another backend owns their address.
rustmine_network_id_conflicts_total counter — Backends that reported a network ID another backend already claimed.
rustmine_probe_send_errors_total counter backend, provider Probe sends that failed.
rustmine_backend_reachable gauge 0/1 backend, provider Whether the backend is currently advertised.
rustmine_backend_last_seen_timestamp_seconds gauge backend, provider Unix time of the backend's last answer.
rustmine_provider_ready gauge 0/1 provider Whether the provider has reconciled at least once.
rustmine_provider_backends gauge provider Backends the provider last reported.
rustmine_ready gauge 0/1 — Whether every enabled provider has reconciled.
rustmine_build_info gauge, always 1 version Build information.
process_* gauge / counter — From ProcessCollector; Linux builds only.

reason is one of rate_limited, unknown_network_id, unknown_client, unexpected_source, unexpected_response, unparseable or send_failed; /status reports signals_dropped as the sum over reasons. send_failed counts both a datagram the router could not send over its socket and one a connector channel refused to accept (backpressure or a stopped connector). A backend removed from its provider loses its series instead of sticking at its last value, and a backend whose connector never started has no rustmine_backend_reachable series at all — only rustmine_connector_start_errors_total records it.

Example alerts:

max_over_time(rustmine_backend_reachable[5m]) == 0
rustmine_provider_ready == 0
rate(rustmine_provider_reconcile_errors_total[5m]) > 0
sum by (reason) (rate(rustmine_signals_dropped_total[5m])) > 0

Logs

The filter defaults to info; RUSTMINE_LOG overrides it with a tracing EnvFilter (RUSTMINE_LOG=debug adds per-datagram detail). log_format picks json or pretty.

Each backend lifecycle edge logs one info line, message backend added or backend removed, carrying backend, provider, address, network_id, event and reason:

event reason Meaning
added discovered A backend the router had not seen — at startup, every world with a running connector.
added reachable Answered again after going quiet.
removed unreachable Stopped answering; still in its provider's set.
removed gone Left its provider's set.

A world's first answer after added/discovered is not logged, so startup stays one line per world. network_id is empty ("") until that answer.

A steady world logs nothing. A world whose network ID changes after a restart reads as removed/unreachable followed by added/reachable — but only if the restarted world stays silent past unreachable_after; a faster restart logs nothing. Player names, XUIDs and SDP are never logged.

Configuration

YAML with unknown keys rejected, so typos fail at startup.

Key Default Meaning
listen 0.0.0.0:7551 Client-facing NetherNet LAN listener (IPv4 only).
status_listen 127.0.0.1:9101 Status/health HTTP listener.
probe_interval 1s How often each backend is probed.
unreachable_after 3s Silence after which a world is unadvertised.
client_ttl 5m Client routing entry lifetime.
log_format json json or pretty. RUSTMINE_LOG sets the filter.
advertise_address unset Source IPv4 for per-backend sockets (multi-homed hosts).
docker.* see below Docker label provider.
static[] empty { name, address } backends.
kubernetes.enabled false Rejected with a clear error in v1.

docker settings: enabled (false), socket (/var/run/docker.sock), labels (rustmine.enable=true, manymine.enable=true), interval (2s), network (preferred network, unset), port (7551), published_ports (false), name_label (rustmine.name), port_label (rustmine.port).

Providers

Docker (v1). Running containers carrying any configured enable label. The address is the container's IP on the preferred network (else the first network by name) at UDP 7551. rustmine.port overrides the port and rustmine.name the display name. Host-network containers are skipped: they cannot share 7551 with the router.

With published_ports: true the address is instead 127.0.0.1 and the host port the container publishes for port/udp; containers that publish nothing keep their container address. Reach for it when the container runtime proxies container addresses: a NetherNet signaling request carries a ~1.8 KB SDP offer, so it arrives as IP fragments, and OrbStack on macOS drops exactly those through its direct-IP path while its port forwarding carries them. A probe succeeds and the join fails, which is what the lab hit. The address is the host's, so the router must share the host's network namespace: a process on the host, or host networking in a container.

Static (v1). A configured list of host:port endpoints. A static entry must be a distinct listener; pointing one at the router's own address and port is a startup error.

Kubernetes (post-v1). The provider interface exists; enabling it in v1 is a startup error that names the milestone.

Docker deployment

docker run --network host \
  --cap-drop=ALL --security-opt=no-new-privileges \
  --group-add "$(stat -c '%g' /var/run/docker.sock)" \
  -v /var/run/docker.sock:/var/run/docker.sock:ro \
  -v "$PWD/config/rustmine.yaml:/config/rustmine.yaml:ro" \
  ghcr.io/eripa/rustmine:v0.1.0

just docker builds the same image locally as rustmine:dev if you have modified your checkout.

--network host is required to receive LAN broadcasts on UDP 7551 and to reach the worlds' bridge addresses. The image runs as a non-root user, so when the Docker provider is on it must join the socket's group (--group-add, or group_add in Compose); the socket is mounted read-only. No capabilities are needed.

The image already contains the repository's config/rustmine.yaml at /config/rustmine.yaml, so the config -v is optional: it is how you override the shipped default.

Each world keeps its own public UDP range for gameplay (SERVER_UDP_PORTS=<public-ip>:<public-port>:<local-port>) and publishes that UDP port. Do not publish TCP 19132 or UDP 7551 for LAN play.

NixOS deployment

The flake exposes packages.<system>.rustmine, packages.<system>.default, devShells.<system>.default, and nixosModules.default. The module supplies its own package, so a host configuration never names one.

Wire the flake input:

{
  inputs.rustmine.url = "github:eripa/rustmine";

  outputs = { self, nixpkgs, rustmine, ... }: {
    nixosConfigurations.nixos-host = nixpkgs.lib.nixosSystem {
      modules = [
        rustmine.nixosModules.default
        ./hosts/nixos-host.nix
      ];
    };
  };
}

Minimal host configuration:

{ ... }:
{
  services.rustmine = {
    enable = true;
    openFirewall = true;        # UDP 7551 for LAN discovery
    settings = {
      docker.enabled = true;    # discover worlds by label
      static = [ ];
    };
  };

  virtualisation.docker.enable = true;
  virtualisation.oci-containers.backend = "docker";
}

A complete nine-world example — world template, per-world SERVER_UDP_PORTS, published UDP ranges, labels — is in docs/nixos-example.nix.

Migrating from manymine

  • If set, drop TRANSPORT. NetherNet is the default in BDS 1.26.50+, and the RakNet pin existed only to keep manymine working.
  • Stop publishing 19132:19132/udp. Under NetherNet that is signaling, and clients reach it through the router.
  • Set SERVER_UDP_PORTS = "<lan-ip>:<public-range>:<local-range>" and publish the same UDP range. Each world needs its own range with at least one port per player (MAX_PLAYERS).
  • Keep manymine.enable=true if you like: the Docker provider accepts it as an alias for rustmine.enable=true.
  • Keep worlds on bridge networking. rustmine runs on host networking, must own UDP 7551, and reaches each world's bridge address at UDP 7551.
  • The image's stock healthcheck speaks RakNet and will report each world unhealthy under NetherNet; disable it (--no-healthcheck) or replace it with a probe of GET /v1/join, or Netdata's docker_container_unhealthy alarm will return nightly.
  • The Docker provider needs the Docker Engine API: use the docker backend, or point settings.docker.socket at another Docker-compatible socket.
  • Remove the manymine container and its 19132:19132/udp mapping.

The module renders settings to YAML, runs on normal host networking, adds the service user to the docker group when the Docker provider is enabled, orders after docker.service, and applies NoNewPrivileges, ProtectSystem = strict, PrivateTmp, PrivateDevices, restricted address families and namespaces.

Nix verification status. Verified in a nixos/nix container: devShells.aarch64-darwin.default and devShells.x86_64-linux.default evaluate, packages.x86_64-linux.default evaluates, nix build .#rustmine builds on aarch64-linux, nixosModules.default evaluates to a module, and a NixOS system combining the module with the nine-world example evaluates — its rendered YAML is accepted by rustmine check. Not yet verified: entering nix develop on macOS, and running the systemd unit on a real NixOS host. flake.lock is committed.

Development with Nix

No dev container needed:

nix develop
cargo test
cargo run -- check --config config/rustmine.yaml
cargo run -- run   --config config/rustmine.yaml

The shell provides Rust with clippy, rustfmt, rust-analyzer, just, the Docker CLI, curl, jq, and the build helpers some crates expect. just lab also needs a reachable Docker daemon (see the two-world lab). nix run .# -- check --config config/rustmine.yaml runs the packaged binary without a shell.

Two-world lab

./scripts/lab-check.sh

Starts the two itzg/minecraft-bedrock-server worlds from docker-compose.lab.yaml and runs the router from the current source on the host — target/debug/rustmine run --config config/rustmine.lab.yaml — then polls /status until both worlds are reachable and prints the backend list.

The router runs on the host rather than in a container because the lab exists to prove LAN discovery, and that needs the router to own the machine's real interfaces. On macOS a container sits inside OrbStack's or Docker Desktop's VM and cannot do that. The worlds stay up between runs, so a second just lab rebuilds the binary and restarts only the router; the worlds are reused. The router is left running on success, so a real client can be pointed at it, with its log at target/lab-router.log.

just lab-container runs the router from the packaged image instead (docker-compose.lab-router.yaml merged with the worlds), which is the §9.1 deployment shape from the design spec: distroless, nonroot, cap_drop: [ALL], host networking, and the Docker socket's group. It only makes sense where a container can share the LAN interface. That variant needs DOCKER_GID; the script fills it in from rustmine docker-socket-gid, which reads the group from inside a container because a container runtime on macOS serves the socket from a VM, where the host's group number does not apply. A DOCKER_GID exported in the shell is ignored when it disagrees.

A provider that never reconciles cannot recover by waiting, so both scripts report it after twenty seconds (LAB_PROVIDER_GRACE) with the router's log instead of polling until LAB_TIMEOUT.

just lab-down (or ./scripts/lab-down.sh) stops the router — native or container — both worlds, and the compose network. The worlds keep no volumes, so their data is discarded; extra arguments go to docker compose down, e.g. just lab-down --rmi local to drop the images too.

Each world also publishes its discovery listener on loopback as UDP 27551 / 27552, and config/rustmine.lab.yaml sets docker.published_ports: true, so the router reaches the worlds over loopback rather than through their container addresses — the workaround for the fragmentation problem described under Providers.

cargo run --example discovery-probe -- 255.255.255.255:7551 sends one discovery request, the way a client does, and prints the worlds that answer. Pass a second argument to send from a specific address (for example the machine's LAN address) to test that path instead of loopback.

Both scripts fill SERVER_UDP_PORTS with this machine's LAN address (LAB_ADVERTISE_IP overrides it), because that property is the address a joining client is told to use; the compose default is a documentation address that goes nowhere. They also disable the world's allow-list, which refuses every player while it is on and empty. On a Mac the address comes from route -n get default plus ipconfig getifaddr.

Because just lab puts the router on the host, it binds the machine's own interfaces: /status on 127.0.0.1:9101, UDP 7551 everywhere, and clients in the same broadcast domain find it. On macOS that is the Mac's interfaces, and OrbStack lets the router reach the worlds' container addresses (192.168.x.x) directly. The container variant is reachable from the Mac's localhost; check with lsof -nP -iUDP:7551 and the probe from another machine if you need it on the LAN.

Recorded run (BDS 1.26.66, Docker-in-Docker, 2026-11-22):

{"version":"0.1.0","listen":"0.0.0.0:7551",
 "providers":[{"name":"static","ok":true,"backends":0},
              {"name":"docker","ok":true,"backends":2}],
 "backends":[
   {"name":"rustmine-v1-world-a-1","provider":"docker","address":"172.18.0.3:7551","network_id":"597596646847865539","reachable":true,"last_seen_ms":13},
   {"name":"rustmine-v1-world-b-1","provider":"docker","address":"172.18.0.2:7551","network_id":"14099055111347343776","reachable":true,"last_seen_ms":13}],
 "counters":{"discovery_requests":0,"responses_sent":0,"signals_forwarded":0,"signals_dropped":0}}

One discovery request from a client socket produced two 176-byte pongs from distinct source ports:

pongs: 2
  ('127.0.0.1', 41644) 176 bytes
  ('127.0.0.1', 47129) 176 bytes

Real-client gate

Two worlds, one router, one real Minecraft client: both worlds appear in "LAN Games", each joins, and gameplay traffic does not pass through rustmine. The lab scripts prove discovery and reachability without a client; this gate needs one, and it needs a host where all three parties share a network:

  • the router must be on the client's broadcast domain to receive the discovery request and answer it;
  • the router must reach each world's UDP 7551 listener to probe it;
  • the client must reach the world's public UDP port directly, because rustmine relays only discovery replies and signaling — gameplay never goes through it.

On macOS the worlds have to run in a Linux VM (OrbStack, Docker Desktop) because BDS has no macOS build, so two things decide whether this gate can pass there:

  • Local Network permission. macOS denies a process access to the local network unless the app that launched it is allowed, and a denied send fails as No route to host, indistinguishable from a missing route. Check System Settings → Privacy & Security → Local Network for the terminal (and for the client). This bites the probe and the router equally.
  • Routing from the host to the VM. OrbStack and Docker Desktop keep container addresses inside the VM; some runtimes route them from the host, some proxy TCP only. Send a discovery request to a world's address from the host to find out. Answering does not settle it, though: a proxy that carries a 64-byte probe can still drop the offer of a real join. That is what docker.published_ports answers, as described under Providers.

Publishing the worlds' ports does not substitute for the Local Network permission, and it does not put the router on the network either: the router answers discovery from one socket per world on an ephemeral port, and a client sends its signaling to the source port of the pong it received, which no port forward can carry. What publishing does fix is the router's own path to the worlds.

The gate has passed both ways: on a Linux host, and on a Mac with OrbStack running the router as a host process against worlds in the VM with published_ports on.

What each lab shape proves: just lab (router on the host) is the one that can serve a real client. just lab-container proves the router finds and probes the worlds, but its sockets live in the VM's namespace, so a client on the LAN never sees it.

Troubleshooting

  • No worlds visible. Check /status: are the providers ok? A backend with reachable: false never answered a probe. Verify the world listens on UDP 7551 inside its container and that the router can reach its IP.
  • The docker provider is not ok. The router cannot reach the Docker socket, and it logs the socket's group next to its own groups. just lab runs as your user, so check that you can talk to Docker yourself. Under just lab-container the fix is the group_add entry, which that script fills from rustmine docker-socket-gid; a container created before a Docker restart also keeps the old socket inode, so recreate it: docker compose -f docker-compose.lab.yaml -f docker-compose.lab-router.yaml up -d --force-recreate rustmine.
  • A client sees the worlds but the join times out. Discovery and the worlds' UDP 7551 path are fine, so look at /status: signals_forwarded climbing means the router relayed the client's request, and signals_dropped climbing means replies are being discarded. With RUSTMINE_LOG=warn,rustmine=debug the router logs the signaling it relays (forwarding a client signal to its backend, relaying a backend signal to its client) and every datagram it could not parse — the rustmine=debug filter keeps hyper's chatter out. If signals_forwarded climbs and the world still never answers, the runtime is dropping the client's offer in transit: turn on docker.published_ports, as the lab does.
  • World visible but the join fails. Discovery and signaling work; the world's ICE candidates are unreachable. Set and publish SERVER_UDP_PORTS.
  • Wrong world answers. Two worlds must not report the same network ID; the registry keeps the first and logs the conflict.
  • Port already in use. The status listener or UDP 7551 is taken; startup fails with the address named.
  • discovery-probe says "No route to host" for 255.255.255.255. The datagram never left the machine: macOS does not always route the limited broadcast address (a VPN or several interfaces is enough). Send the subnet broadcast instead — ipconfig getifaddr en0 gives the address, so 192.168.1.255:7551 for a /24 — or pass an interface address as the probe's second argument.
  • Is the router really on the host network? ss -lun | grep 7551 lists the router's UDP socket: just lab runs it as a normal process, so it owns the machine's interfaces. just lab-container instead relies on Docker's host networking (docker inspect rustmine-rustmine-1 --format '{{.HostConfig.NetworkMode}}' prints host); if the container runtime serves the network from a VM, the client's broadcast never reaches it.

Protocol note

rustmine relays UDP 7551 discovery responses and signaling datagrams verbatim. It decrypts only enough to read the packet type, sender, and recipient network IDs, and it constructs only its own discovery requests. A signaling payload it cannot interpret — a world answering a rejected offer sends an empty one — is still relayed by recipient ID. SDP contents, player names, and XUIDs are never logged.

Contributing

Issues and pull requests are welcome. CONTRIBUTING.md covers the toolchain, the lab and the commit convention. Security problems go to SECURITY.md, not to the issue tracker.

License

This is free and unencumbered software released into the public domain under the Unlicense. Do what you like with it; there is no warranty.

Third-party components keep their own terms: the agent skills under vendor/ (superpowers, unslop) are MIT-licensed, and every crate in Cargo.lock carries its own license — deny.toml lists the permissive set this project accepts.

About

Run multiple Minecraft (Bedrock) servers on a single LAN host.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages