lloesche / valheim-server-docker

Valheim dedicated gameserver with automatic update, World backup, BepInEx and ValheimPlus mod support
https://hub.docker.com/r/lloesche/valheim-server
Apache License 2.0
1.92k stars 269 forks source link

Can't connect over WAN, but can connect LAN #552

Closed 46620 closed 6 months ago

46620 commented 1 year ago

I've been attempting to set up a server and every time I start the container I can connect using the local IP of the server, but I can't connect using my public IP.

Running the command sudo netstat -anpe | grep "2456" | grep "LISTEN" brings up nothing, but removing the LISTEN grep I get

udp        0      0 0.0.0.0:2456            0.0.0.0:*                           0          49466      3497/docker-proxy   
udp6       0      0 :::2456                 :::*                                0          19645      3516/docker-proxy

Some info about the setup:

docker-compose.yaml

version: "3"

services: 
  valheim: 
    image: ghcr.io/lloesche/valheim-server
    cap_add:
      - sys_nice
    volumes: 
      - /opt/games/valheim-server/config:/config
      - /opt/games/valheim-server/data:/opt/valheim
    ports: 
      - "2456-2457:2456-2457/udp"
      - "9001:9001/tcp"
    environment:
      - SERVER_NAME="[server_name]"
      - WORLD_NAME=[world_name]
      - SERVER_PASS=[password]
      - PUID=1000
      - PGID=1000
      - TZ=America/New_York
    restart: always
    stop_grace_period: 2m
TheHades commented 1 year ago

Try capturing WAN traffic via tcpdump on the host(!) system, not inside the docker container itself.

tcpdump -i eno1 port '(2456 or 2457)' (Replace eno1 with your actually ethernet interface)

You should see something like the following:

21:14:47.935272 IP 123.123.123.123.39749 > 192.168.178.95.2456: UDP, length 1
21:14:47.936338 IP 123.123.123.123.39749 > 192.168.178.95.2456: UDP, length 1
21:14:50.277664 IP 123.123.123.123.56243 > 192.168.178.95.2457: UDP, length 1
21:14:50.277664 IP 123.123.123.123.56243 > 192.168.178.95.2457: UDP, length 1

If that is not the case, then your router is not properly forwarding the specified ports.

46620 commented 1 year ago

tcpdump doesn't show anything. The default docker container that comes with the dedicated server files from steam works for hosting the game so I don't think it's the router not forwarding the ports, as people can join when I run that.

46620 commented 6 months ago

Tried this again recently and it seems to just work now. Seems to have just been an issue on my system that is no longer an issue.