Networking Guide¶
Configure hostname-based routing for your Minecraft servers using nip.io, mDNS, and mc-router.
Overview¶
The platform supports three connection methods:
| Method | URL Example | Client Setup | Works Remotely |
|---|---|---|---|
| nip.io (Recommended) | myserver.192.168.1.100.nip.io:25565 |
None | Yes |
| mDNS | myserver.local:25565 |
avahi/Bonjour | LAN only |
| Direct IP | 192.168.1.100:25565 |
None | Yes |
nip.io Magic DNS¶
Recommended for all users.
nip.io is a magic DNS service that automatically resolves hostnames containing IP addresses:
myserver.192.168.1.100.nip.io → 192.168.1.100
creative.192.168.1.100.nip.io → 192.168.1.100
modded.192.168.1.100.nip.io → 192.168.1.100
How It Works¶
- Client connects to
myserver.192.168.1.100.nip.io:25565 - DNS query goes to nip.io service
- nip.io extracts
192.168.1.100from hostname - Returns
192.168.1.100as the IP address - Client connects to
192.168.1.100:25565 - mc-router receives connection with hostname
myserver.192.168.1.100.nip.io - mc-router routes to the correct server based on hostname
Configuration¶
Set your host IP in .env:
When you create a server, mcctl automatically configures both nip.io and mDNS hostnames:
mcctl create myserver
# Hostnames:
# - myserver.192.168.1.100.nip.io:25565 (nip.io)
# - myserver.local:25565 (mDNS)
Benefits¶
- No client configuration - Works immediately
- Works remotely - Accessible from any network with internet
- Simple setup - Just set HOST_IP in .env
- Multiple servers - Each server gets a unique hostname
Requirements¶
- Internet access for DNS resolution
- HOST_IP correctly set in .env
- mc-router must be running
mDNS (Multicast DNS)¶
mDNS allows .local hostnames to work on local networks.
How It Works¶
- avahi-daemon broadcasts hostname on local network
- Clients with mDNS support discover the hostname
- No manual /etc/hosts configuration needed
Server Setup¶
Install avahi-daemon¶
Register Hostnames¶
mcctl automatically registers hostnames when creating servers:
Manual registration:
# Add entry
echo "192.168.1.100 myserver.local" | sudo tee -a /etc/avahi/hosts
# Restart avahi
sudo systemctl restart avahi-daemon
Client Setup¶
| OS | Setup Required |
|---|---|
| Linux | Install avahi-daemon (usually pre-installed) |
| macOS | None (Bonjour built-in) |
| Windows | Install Bonjour (iTunes or Bonjour Print Services) |
Windows Client¶
- Download Bonjour Print Services
- Install and restart
.localhostnames will resolve
Linux Client¶
# Ubuntu/Debian
sudo apt install avahi-daemon libnss-mdns
# Verify nss-mdns is configured
grep mdns /etc/nsswitch.conf
# Should show: hosts: files mdns4_minimal [NOTFOUND=return] dns
Troubleshooting mDNS¶
# Check if avahi is running
systemctl status avahi-daemon
# List registered hostnames
cat /etc/avahi/hosts
# Test resolution
avahi-resolve -n myserver.local
# Check network interface
avahi-daemon --check
mc-router Configuration¶
mc-router handles hostname-based routing and auto-scaling.
Router Management with mcctl¶
# Check router status
mcctl status router
# Start router
mcctl router start
# Restart router (after config changes)
mcctl router restart
# Stop router
mcctl router stop
Docker Labels¶
Each server uses Docker labels for mc-router discovery. These are automatically configured by mcctl create:
# servers/myserver/docker-compose.yml (auto-generated)
services:
mc-myserver:
labels:
mc-router.host: "myserver.local,myserver.192.168.1.100.nip.io"
Auto-scaling Settings¶
Configure in ~/minecraft-servers/.env:
# Auto-scaling configuration
AUTO_SCALE_UP=true # Start servers on connect
AUTO_SCALE_DOWN=false # Stop idle servers (see note)
DOCKER_TIMEOUT=120 # Wait time for server startup (seconds)
Then restart the router:
AUTO_SCALE_DOWN
Auto scale down is fully enabled and supported since mc-router v1.39.1. Servers will automatically stop after the configured idle timeout (default: 10 minutes). The race condition that previously caused player disconnections has been fixed. See mc-router #507 for details.
Multiple Hostnames¶
To allow connections from multiple networks (LAN + VPN), configure multiple IPs:
This creates hostnames for each IP:
- myserver.192.168.1.100.nip.io (LAN)
- myserver.100.64.0.5.nip.io (VPN)
HOST_IP vs HOST_IPS
HOST_IP: Single IP address (default)HOST_IPS: Comma-separated multiple IPs (for VPN mesh)
When HOST_IPS is set, it takes precedence over HOST_IP.
VPN Mesh Networks¶
Using a VPN mesh like Tailscale or ZeroTier allows access to your server from anywhere.
Why Use VPN Mesh?¶
| Scenario | Solution |
|---|---|
| Friends on different networks | VPN mesh creates virtual LAN |
| Access home server remotely | VPN access without port forwarding |
| Connect from multiple locations | Multiple IPs support all networks |
Tailscale Setup¶
Tailscale is a free VPN mesh service.
1. Install Tailscale¶
2. Get Tailscale IP¶
3. Configure Multiple IPs in mcctl¶
4. Recreate Servers or Update Labels¶
# New servers automatically get multiple hostnames
mcctl create myserver
# For existing servers, run migration script
cd ~/minecraft-servers
./scripts/migrate-nip-io.sh
5. Client Connection¶
Have friends install Tailscale and invite them to your network, then:
ZeroTier Setup¶
ZeroTier is another free VPN mesh service.
1. Install ZeroTier¶
2. Create and Join Network¶
- Create network at my.zerotier.com
- Copy Network ID (e.g.,
8056c2e21c000001) - Join the network:
3. Get ZeroTier IP¶
4. Configure Multiple IPs in mcctl¶
Using Multiple VPNs Simultaneously¶
You can use both Tailscale and ZeroTier at the same time:
# ~/minecraft-servers/.env
# LAN + Tailscale + ZeroTier
HOST_IPS=192.168.1.100,100.64.0.5,10.147.20.1
Accessible from all networks:
- myserver.192.168.1.100.nip.io:25565 (LAN)
- myserver.100.64.0.5.nip.io:25565 (Tailscale)
- myserver.10.147.20.1.nip.io:25565 (ZeroTier)
VPN Mesh Troubleshooting¶
# Check Tailscale status
tailscale status
# Check ZeroTier status
sudo zerotier-cli listnetworks
# Verify hostname labels
docker inspect mc-myserver | grep mc-router.host
# Check mc-router logs for hostname
docker logs router 2>&1 | grep myserver
When VPN IP Changes
If your VPN IP changes, update .env and run ./scripts/migrate-nip-io.sh again.
Debug Mode¶
Enable mc-router debug output in .env:
Then restart:
Network Architecture¶
Docker Network¶
All Minecraft containers run on a shared Docker network:
# docker-compose.yml
networks:
minecraft-net:
name: ${MINECRAFT_NETWORK:-minecraft-net}
driver: bridge
ipam:
config:
- subnet: ${MINECRAFT_SUBNET:-172.28.0.0/16}
Port Mapping¶
Only mc-router exposes port 25565:
Individual Minecraft servers don't expose ports - they're accessed through mc-router.
Container Discovery¶
mc-router uses the Docker socket to discover containers:
Custom Domain Setup¶
For production deployments, use your own domain.
DNS Configuration¶
Add A records pointing to your server:
Server Configuration¶
Update the mc-router.host label:
HTTPS/TLS¶
Minecraft uses its own protocol, not HTTPS. TLS is not needed for the game connection.
Firewall Configuration¶
Required Ports¶
| Port | Protocol | Purpose |
|---|---|---|
| 25565 | TCP | Minecraft client connections |
| 5353 | UDP | mDNS (local network only) |
UFW (Ubuntu)¶
firewalld (CentOS/RHEL)¶
sudo firewall-cmd --permanent --add-port=25565/tcp
sudo firewall-cmd --permanent --add-service=mdns
sudo firewall-cmd --reload
Troubleshooting¶
Connection Refused¶
-
Check mc-router is running:
-
Check hostname is configured:
-
Test DNS resolution:
Server Not Starting¶
-
Check Docker timeout in
.env: -
Check server logs:
mDNS Not Working¶
- Verify avahi is running on server
- Check client has mDNS support
- Ensure same network subnet
- Check firewall allows port 5353/udp
See Also¶
- Quick Start - Basic server setup
- Environment Variables - All configuration options
- mc-router Documentation - Full mc-router reference