Valheim Servidor dedicado on Linux
Valheim es un popular Viking-themed survival game que soporta servidor dedicado hosting on Linux. Running your own servidor dedicado te da control completo over game settings, world configuration, and administrative features. Esta guía cubre el proceso completo de configuración de a production-ready Valheim servidor dedicado on Linux with proper systemd management, automated copia de seguridads, and optimization techniques.
Tabla de contenidos
- System Requirements
- Instalaing SteamCMD
- Instalaing Valheim Server
- Server Configuration
- Port Configuration and Firewall
- Running with Systemd
- World Management
- Mod Instalaation with BepInEx
- [Backup and Recovery](#copia de seguridad-and-recuperación)
- Performance Optimization
- Monitoring and Maintenance
- Conclusion
Requisitos del sistema
Antes de instalar Valheim server, asegúrate de que tu sistema cumpla con estos requisitos:
- Ubuntu 20.04 LTS or CentOS 7+ (or compatible Linux distribution)
- 4GB RAM minimum (8GB recommended)
- 20GB free disk space
- Stable internet connection
- Root or sudo access
Valheim server requires 64-bit Linux. The server es sin interfaz gráfica, meaning it doesn't require X11 or a graphical display.
Instalaing SteamCMD
SteamCMD is Valve's línea de comandos Steam client used to download and manage servidores de juegos.
sudo apt-get update
sudo apt-get install -y curl wget file bzip2 gzip unzip python3 util-linux ca-certificates binutils bc jq tmux netcat
Crea un usuario dedicado Steam user for seguridad:
sudo useradd -m -s /bin/bash steam
sudo -u steam mkdir -p /home/steam/steamcmd
Descarga and extract SteamCMD:
cd /home/steam/steamcmd
sudo -u steam curl -sqL "https://steamcdn-a.akamaihd.net/client/installer/steamcmd_linux.tar.gz" | sudo -u steam tar zxvf -
Verifica la instalación by running SteamCMD:
sudo -u steam /home/steam/steamcmd/steamcmd.sh +quit
Instalaing Valheim Server
Instala el Valheim server using SteamCMD. The app ID for Valheim servidor dedicado is 896660.
sudo -u steam /home/steam/steamcmd/steamcmd.sh +force_install_dir /home/steam/valheim +login anonymous +app_update 896660 validate +quit
Verifica la instalación by checking for key executable files:
ls -la /home/steam/valheim/
file /home/steam/valheim/valheim_server.x86_64
Create necessary directories for server data:
sudo -u steam mkdir -p /home/steam/valheim-data/worlds
sudo -u steam mkdir -p /home/steam/valheim-data/logs
sudo -u steam chmod 755 /home/steam/valheim-data
Server Configuration
Crea el main server startup script. This script will handle server arguments and registro:
sudo tee /home/steam/valheim/start_server.sh > /dev/null <<'EOF'
#!/bin/bash
VALHEIM_DIR="/home/steam/valheim"
DATA_DIR="/home/steam/valheim-data"
SERVER_NAME="${SERVER_NAME:-ValheimServer}"
SERVER_PORT="${SERVER_PORT:-2456}"
SERVER_PASSWORD="${SERVER_PASSWORD:-changeme}"
WORLD_NAME="${WORLD_NAME:-Dedicated}"
BACKUP_DIR="${BACKUP_DIR:-$DATA_DIR/backups}"
cd "$VALHEIM_DIR"
mkdir -p "$DATA_DIR/worlds"
mkdir -p "$BACKUP_DIR"
exec "$VALHEIM_DIR/valheim_server.x86_64" \
-nographics \
-batchmode \
-server \
-serverport "$SERVER_PORT" \
-name "$SERVER_NAME" \
-world "$WORLD_NAME" \
-password "$SERVER_PASSWORD" \
-savedir "$DATA_DIR/worlds" \
-logFile "$DATA_DIR/logs/valheim.log" \
2>&1
EOF
Make the script executable:
sudo chmod +x /home/steam/valheim/start_server.sh
sudo chown steam:steam /home/steam/valheim/start_server.sh
Test the server startup:
sudo -u steam bash -c 'SERVER_NAME="TestServer" SERVER_PORT=2456 SERVER_PASSWORD="test123" WORLD_NAME="TestWorld" timeout 10 /home/steam/valheim/start_server.sh || true'
tail -f /home/steam/valheim-data/logs/valheim.log
Configuración de puertos and Firewall
Valheim uses UDP ports for server communication. The default configuration uses three consecutive ports:
- Primary port (default 2456): Game server UDP
- Secondary port (+1): Server discovery/sync UDP
- Tertiary port (+2): Server query UDP
Configura UFW firewall:
sudo ufw allow 2456:2458/udp
sudo ufw allow 2456:2458/tcp
sudo ufw status numbered
For iptables-based systems:
sudo iptables -A INPUT -p udp --dport 2456:2458 -j ACCEPT
sudo iptables -A INPUT -p tcp --dport 2456:2458 -j ACCEPT
sudo iptables-save | sudo tee /etc/iptables/rules.v4
Verifica port listening:
sudo netstat -ulnp | grep valheim_server
ss -ulnp | grep 2456
Ejecución con Systemd
Crea un servicio systemd file for automatic startup and management:
sudo tee /etc/systemd/system/valheim.service > /dev/null <<'EOF'
[Unit]
Description=Valheim Dedicated Server
After=network.target
Wants=network-online.target
[Service]
Type=simple
User=steam
Group=steam
WorkingDirectory=/home/steam/valheim
EnvironmentFile=/home/steam/valheim/server.env
ExecStart=/home/steam/valheim/start_server.sh
Restart=on-failure
RestartSec=10
StandardOutput=journal
StandardError=journal
# Resource limits
LimitNOFILE=65536
LimitNPROC=32768
# Security
NoNewPrivileges=true
PrivateTmp=true
ProtectSystem=strict
ProtectHome=yes
ReadWritePaths=/home/steam/valheim-data
[Install]
WantedBy=multi-user.target
EOF
Create environment configuration file:
sudo tee /home/steam/valheim/server.env > /dev/null <<'EOF'
SERVER_NAME=ValheimServer
SERVER_PORT=2456
SERVER_PASSWORD=ChangeMeToSecurePassword
WORLD_NAME=Dedicated
EOF
Fix permissions:
sudo chown steam:steam /home/steam/valheim/server.env
sudo chmod 600 /home/steam/valheim/server.env
sudo chown steam:steam /home/steam/valheim-data
sudo chmod 755 /home/steam/valheim-data
Enable and start the servicio:
sudo systemctl daemon-reload
sudo systemctl enable valheim.service
sudo systemctl start valheim.service
sudo systemctl status valheim.service
Monitor servicio logs in real-time:
sudo journalctl -u valheim.service -f
sudo journalctl -u valheim.service -n 100
Administración del mundo
Valheim stores world data in the save directory. Each world consists of multiple files containing terrain, structure, and player data.
List available worlds:
ls -lah /home/steam/valheim-data/worlds/
file /home/steam/valheim-data/worlds/*
World files include:
.fwl: World metadata.db: Player and structure database.fwl.meta: Additional metadata
Crea un copia de seguridad of a specific world:
WORLD_NAME="Dedicated"
BACKUP_DIR="/home/steam/valheim-data/backups"
TIMESTAMP=$(date +%Y%m%d_%H%M%S)
sudo -u steam bash -c "cp -r /home/steam/valheim-data/worlds/$WORLD_NAME.* $BACKUP_DIR/world_${WORLD_NAME}_${TIMESTAMP}/"
Reset or delete a world:
sudo systemctl stop valheim.service
sudo -u steam rm -f /home/steam/valheim-data/worlds/Dedicated.*
sudo systemctl start valheim.service
Generate a new world with custom seed:
# Set WORLD_NAME and restart service
sudo systemctl stop valheim.service
sudo -u steam /home/steam/valheim/start_server.sh 2>&1 | head -20
sleep 5
sudo systemctl kill valheim.service
sudo systemctl start valheim.service
Instalación de mods con BepInEx
BepInEx is a mod loader for Valheim que permite plugin functionality. This is optional but recommended for enhanced server management.
Descarga BepInEx:
cd /home/steam/valheim
BEPINEX_VERSION="5.4.21"
sudo -u steam wget https://github.com/BepInEx/BepInEx/releases/download/v${BEPINEX_VERSION}/BepInEx_x64_${BEPINEX_VERSION}.zip
Extrae BepInEx:
sudo -u steam unzip -o BepInEx_x64_${BEPINEX_VERSION}.zip
sudo -u steam chmod +x valheim_server.x86_64
Instala mod dependencies (optional but recommended):
# Example: Install useful server management plugins
cd /home/steam/valheim/BepInEx/plugins
sudo -u steam wget https://github.com/nxPublic/BepInEx-Tools/releases/download/BepInEx-Tools_v2.2/BepInEx-Tools_v2.2.zip
sudo -u steam unzip -o BepInEx-Tools_v2.2.zip
Verifica BepInEx initialization by checking logs:
tail -50 /home/steam/valheim-data/logs/valheim.log | grep -i bepinex
Copia de seguridad y recuperación
Implement automated daily copia de seguridads with retention policy:
sudo tee /home/steam/backup_valheim.sh > /dev/null <<'EOF'
#!/bin/bash
DATA_DIR="/home/steam/valheim-data"
BACKUP_DIR="$DATA_DIR/backups"
RETENTION_DAYS=30
TIMESTAMP=$(date +%Y%m%d_%H%M%S)
# Create backup
mkdir -p "$BACKUP_DIR"
tar -czf "$BACKUP_DIR/valheim_backup_${TIMESTAMP}.tar.gz" \
-C "$DATA_DIR" worlds/ \
2>/dev/null
if [ $? -eq 0 ]; then
echo "[$(date)] Backup created: valheim_backup_${TIMESTAMP}.tar.gz"
else
echo "[$(date)] Backup failed!" >&2
exit 1
fi
# Remove old backups
find "$BACKUP_DIR" -name "valheim_backup_*.tar.gz" -mtime +${RETENTION_DAYS} -delete
echo "[$(date)] Old backups cleaned (retention: ${RETENTION_DAYS} days)"
EOF
sudo chmod +x /home/steam/backup_valheim.sh
sudo chown steam:steam /home/steam/backup_valheim.sh
Add daily copia de seguridad to crontab:
sudo tee -a /var/spool/cron/crontabs/steam > /dev/null <<'EOF'
0 3 * * * /home/steam/backup_valheim.sh >> /home/steam/valheim-data/logs/backup.log 2>&1
EOF
sudo systemctl restart cron
Restore from copia de seguridad:
# List available backups
ls -lh /home/steam/valheim-data/backups/
# Restore specific backup
sudo systemctl stop valheim.service
BACKUP_FILE="/home/steam/valheim-data/backups/valheim_backup_20240101_030000.tar.gz"
sudo -u steam tar -xzf "$BACKUP_FILE" -C /home/steam/valheim-data/
sudo systemctl start valheim.service
Optimización del rendimiento
Optimize system settings for game server rendimiento:
# Increase file descriptors
sudo sysctl -w fs.file-max=2097152
echo "fs.file-max=2097152" | sudo tee -a /etc/sysctl.conf
# Network optimizations
sudo sysctl -w net.ipv4.ip_local_port_range="1024 65535"
sudo sysctl -w net.ipv4.tcp_fin_timeout=30
sudo sysctl -w net.core.somaxconn=1024
sudo sysctl -w net.ipv4.tcp_max_syn_backlog=2048
Monitor resource usage:
# Real-time monitoring
watch -n 1 'ps aux | grep valheim_server'
htop -p $(pgrep -f valheim_server)
# Memory usage
ps -o pid,vsz,rss,comm $(pgrep -f valheim_server)
# Network statistics
netstat -s | grep -i "udp"
ss -s
Set CPU affinity for better rendimiento (optional):
# Get PID
PID=$(pgrep -f valheim_server)
# Set to use cores 0-3 (adjust based on your server)
taskset -p -c 0-3 $PID
# Verify
taskset -p $PID
Supervisión y mantenimiento
Crea un monitoreo script to check server health:
sudo tee /home/steam/check_valheim.sh > /dev/null <<'EOF'
#!/bin/bash
PROCESS_NAME="valheim_server"
LOG_FILE="/home/steam/valheim-data/logs/valheim.log"
PORT=2456
# Check if process is running
if pgrep -f "$PROCESS_NAME" > /dev/null; then
echo "✓ Server process is running"
else
echo "✗ Server process is NOT running"
exit 1
fi
# Check port
if netstat -ulnp 2>/dev/null | grep -q $PORT; then
echo "✓ Server listening on port $PORT"
else
echo "✗ Server NOT listening on port $PORT"
fi
# Check log for errors
RECENT_ERRORS=$(tail -50 "$LOG_FILE" | grep -i "error\|exception\|fatal" | wc -l)
echo "Recent errors in log: $RECENT_ERRORS"
# Check disk space
DISK_USAGE=$(df -h /home/steam/valheim-data | awk 'NR==2 {print $5}')
echo "Disk usage: $DISK_USAGE"
# Memory usage
MEM_USAGE=$(ps aux | grep $PROCESS_NAME | grep -v grep | awk '{print $6}')
echo "Memory usage: ${MEM_USAGE}KB"
EOF
sudo chmod +x /home/steam/check_valheim.sh
Update server to latest version:
sudo systemctl stop valheim.service
sudo -u steam /home/steam/steamcmd/steamcmd.sh \
+force_install_dir /home/steam/valheim \
+login anonymous \
+app_update 896660 validate \
+quit
sudo systemctl start valheim.service
Conclusión
You now have a fully functional Valheim servidor dedicado running on Linux with systemd management, automated copia de seguridads, and proper reding configuration. This setup provides a reliable foundation for running a multiplayer Valheim server with complete administrative control.
Key points to remember:
- Change the server password to a secure value immediately
- Implement regular copia de seguridads using the provided scripts
- Monitor logs regularly for issues
- Keep the server updated with the latest SteamCMD updates
- Use BepInEx mods carefully to maintain server stability
- Plan for scaling if player count increases
Regular maintenance, monitoreo, and copia de seguridads are essential for long-term server stability and data protection.


