Do I need to Hairpin / Nat loop to access the server over LAN
Closed this issue · 5 comments
I set up two servers one modded and one vanilla. Both servers work great under my domain but now I have no way to access the server locally. Is there a way I can access the server on my LAN. Nat looping and hair pinning doesn’t seem to be working out for me and my limited knowledge of OpenWrt
The easiest "solution" for your local access is to expose port 25565 to a distinct host port each. When you're accessing from within the LAN you'll reference the docker host and mapped port.
Hello thanks for the reply. my docker compose is as follows.
version: '3.8'
services:
vanilla:
container_name: vanilla
image: itzg/minecraft-server
environment:
EULA: "TRUE"
INIT_MEMORY: 2G
MAX_MEMORY: 4G
RCON_PASSWORD: "cfg"
ports:
- '50:50'
volumes:
- ./vanilla/server:/data
- ./vanilla/plugins:/plugins
restart: unless-stopped
tty: true
stdin_open: true
mods:
container_name: mods
image: itzg/minecraft-server:java11
tty: true
stdin_open: true
ports:
- '48:48'
environment:
EULA: "TRUE"
TYPE: "FORGE"
VERSION: "1.16.5"
FORGE_VERSION: "36.2.34"
INIT_MEMORY: 4G
MAX_MEMORY: 16G
MTOD: |
RCON_PASSWORD: "cfg"
volumes:
# attach the relative directory 'data' to the container's /data path
- ./modded/server:/data
- ./modded/plugins:/plugins
- ./modded/mods:/mods
mc-router:
container_name: router
image: itzg/mc-router
depends_on:
- vanilla
- mods
environment:
DEBUG: true
API_BINDING: ":25564"
MAPPING : |
mc.riddlemc.duckdns.org=vanilla:25565
modded.riddlemc.duckdns.org=mods:25565
ports:
- 25565:25565
# bind the API port to only loopback, this avoids external exposure
- 127.0.0.1:25564:25564
web:
image: itzg/rcon
environment:
RWA_USERNAME: admin
RWA_PASSWORD: admin
RWA_ADMIN: "TRUE"
# is referring to the hostname of 'mc' compose service below
RWA_RCON_HOST: mods
# needs to match the RCON_PASSWORD configured for the container
RWA_RCON_PASSWORD: "cfg"
ports:
- "4326:4326"
- "4327:4327"version: '3.8'
services:
vanilla:
container_name: vanilla
image: itzg/minecraft-server
environment:
EULA: "TRUE"
INIT_MEMORY: 2G
MAX_MEMORY: 4G
RCON_PASSWORD: "cfg"
ports:
- '50:50'
volumes:
- ./vanilla/server:/data
- ./vanilla/plugins:/plugins
restart: unless-stopped
tty: true
stdin_open: true
mods:
container_name: mods
image: itzg/minecraft-server:java11
tty: true
stdin_open: true
ports:
- '48:48'
environment:
EULA: "TRUE"
TYPE: "FORGE"
VERSION: "1.16.5"
FORGE_VERSION: "36.2.34"
INIT_MEMORY: 4G
MAX_MEMORY: 16G
MTOD: |
RCON_PASSWORD: "cfg"
volumes:
# attach the relative directory 'data' to the container's /data path
- ./modded/server:/data
- ./modded/plugins:/plugins
- ./modded/mods:/mods
mc-router:
container_name: router
image: itzg/mc-router
depends_on:
- vanilla
- mods
environment:
DEBUG: true
API_BINDING: ":25564"
MAPPING : |
mc.example.org=vanilla:25565
modded.example.org=mods:25565
ports:
- 25565:25565
# bind the API port to only loopback, this avoids external exposure
- 127.0.0.1:25564:25564
If my understanding is correct about your solution I should be able to access the servers with the local IP and the port 50 and 48.
Using very low ports like 48 and 50 is very unusual -- in fact in some cases using privileged port range like that is disallowed by the OS.
That aside, your mappings are not correct since the minecraft server is listening on port 25565. Should be
- '50:25565'
and
- '48:25565'
Some related info https://github.com/itzg/docker-minecraft-server/blob/master/notes/container-network-namespaces.drawio.png
Thank you! that graphic helped a ton. Ill rebind to a higher port in the future. as of right now everything works.
Thanks for the help I am definitely a novice at best with networking.
FYI some background on privileged port range (1 - 1024)