Quick and dirty Linux dedicated server howto
Zaggy
NullPointerExceptionThe Netherlands Join Date: 2003-12-10 Member: 24214Forum Moderators, NS2 Playtester, Reinforced - Onos, Subnautica Playtester
A quick and dirty Linux dedicated server howto
Legend
Text in italic are commands to be run from the commandline
Initial installation of Ubuntu and Steam
Create a fresh Steam account for this server and note the login credentials.
Download Ubuntu Server x64 12.04.3: from http://www.ubuntu.com/download/server
Install Ubuntu Server x64, select appropriate options, select OpenSSH server if you want to remotely manage it.
Note: I highly recommend configuring your Ubuntu server properly, at LEAST change the default ssh port and disable root login, this guide should work rather well: http://www.thefanclub.co.za/how-to/how-secure-ubuntu-1204-lts-server-part-1-basics
Update, upgrade, install 32-bit libraries and reboot: sudo apt-get update && sudo apt-get upgrade -y && sudo apt-get install ia32-libs -y && sudo reboot
Create seperate folder for ns2 server and steam: mkdir ns2server && cd ns2server
Create seperate folders for ns2 server files, config and log: mkdir ns2 log config
Download and unpack SteamCMD: wget http://media.steampowered.com/client/steamcmd_linux.tar.gz && tar -xvzf steamcmd_linux.tar.gz
Run SteamCMD: ./steamcmd.sh
login steamaccountname
enter password
force_install_dir ns2
app_update 4940 validate
exit
Create server startup script and config files
If you have no GUI it's quite a bit to type out: wget the attachment of this post, extract the files and move them to appropriate folders:
wget -O ns2scripts.tar.gz http://tinyurl.com/pj8qyzn && tar -xvzf ns2scripts.tar.gz && mv *.json config/.
(original URL: https://us.v-cdn.net/5019629/uploads/FileUpload/cc/c1af7e46d444363753f03173ede096.gz)
Edit the config files, config/ServerAdmin.json and start.sh are important!
Make the following changes to start.sh:
Remove the \ in front of
Make sure start.sh is executable: chmod +x start.sh
If all this succeeded, you can attempt to start the server with ./start.sh!
Portforwarding
Remember to forward the appropriate ports or your server will not be visible!
Webport, 27000-27050 TCP/UDP (default server port) and 4380 UDP
As per https://support.steampowered.com/kb_article.php?ref=8571-GLVN-8711
Server startup script and nfig files copied below for reference
start.sh
--cut below--
#!/bin/bash
echo -n "Killing any previous servers: "
killall server_linux32
sleep 2
echo
echo -n "Starting NS2 Server: "
cd /home/<username>/ns2server/ns2
screen -A -m -d -S ns2 ./server_linux32 -name "Server title in browser" -webadmin -webdomain <LANaddresshere> -webuser <webusername> -webpassword <webuserpass> -webport <webport> -map ns2_biodome -ip <LANadresshere> -port 27015 -limit 16 -logdir /home/<username>/ns2server/log -config_path "/home/<username>/ns2server/config"
cd /home/<username>/ns2server
sleep 2
echo
echo "Attaching to server console..."
screen -x ns2
--cut above--
MapCycle.json
--cut below--
{
"maps": [ "ns2_descent", "ns2_docking", "ns2_mineshaft", "ns2_summit", "ns2_tram", "ns2_veil", "ns2_refinery", "ns2_biodome" ],
"time": 30,
"mode": "order",
"mods": [ ]
}
--cut above--
Cycle all official maps at time of writing.
ServerAdmin.json
--cut below--
{
"groups":
{
"admin_group": { "type": "allowed", "commands": [ "sv_changemap", "sv_reset", "sv_say", "sv_cheats"] },
"mod_group": { "type": "disallowed", "commands": [ "sv_ban", "sv_reset" ] },
"clan_group": { "type": "allowed", "commands": [ "sv_kick", "sv_say" ] }
}
"users":
{
"joe": { "id": 1234567, "groups": [ "admin_group" ] },
"bob": { "id": 12345678, "groups": [ "mod_group" ] }
}
}
--cut above--
Change users and their ids to the people you want to be admin or mod
ServerConfig.json
--cut below--
{
"settings": {
"rookie_friendly": false,
"end_round_on_team_unbalance": 0.4,
"auto_kick_afk_time": 300,
"auto_team_balance": {
"enabled_after_seconds": 10,
"enabled_on_unbalance_amount": 2
},
"auto_kick_afk_capacity": 0.5
},
"tags": [ "tag" ]
}
--cut above--
Current afk kick is set to kick after 5m
edit: couple of typos
Will look into the sv_commands and json rights issue, thanks radionaut!
edit2: removed \ from start.sh file, added sleep 2 after server start to give attach a bit more time to succeed, added attachment with corrected start.sh
TODO:
-check permissions issues with ServerAdmin.json
Legend
Text in italic are commands to be run from the commandline
Initial installation of Ubuntu and Steam
Create a fresh Steam account for this server and note the login credentials.
Download Ubuntu Server x64 12.04.3: from http://www.ubuntu.com/download/server
Install Ubuntu Server x64, select appropriate options, select OpenSSH server if you want to remotely manage it.
Note: I highly recommend configuring your Ubuntu server properly, at LEAST change the default ssh port and disable root login, this guide should work rather well: http://www.thefanclub.co.za/how-to/how-secure-ubuntu-1204-lts-server-part-1-basics
Update, upgrade, install 32-bit libraries and reboot: sudo apt-get update && sudo apt-get upgrade -y && sudo apt-get install ia32-libs -y && sudo reboot
Create seperate folder for ns2 server and steam: mkdir ns2server && cd ns2server
Create seperate folders for ns2 server files, config and log: mkdir ns2 log config
Download and unpack SteamCMD: wget http://media.steampowered.com/client/steamcmd_linux.tar.gz && tar -xvzf steamcmd_linux.tar.gz
Run SteamCMD: ./steamcmd.sh
login steamaccountname
enter password
force_install_dir ns2
app_update 4940 validate
exit
Create server startup script and config files
If you have no GUI it's quite a bit to type out: wget the attachment of this post, extract the files and move them to appropriate folders:
wget -O ns2scripts.tar.gz http://tinyurl.com/pj8qyzn && tar -xvzf ns2scripts.tar.gz && mv *.json config/.
(original URL: https://us.v-cdn.net/5019629/uploads/FileUpload/cc/c1af7e46d444363753f03173ede096.gz)
Edit the config files, config/ServerAdmin.json and start.sh are important!
Make the following changes to start.sh:
Remove the \ in front of
"/home/<username>/ns2server/config"add
sleep 2above
echo echo -n "Starting NS2 Server: "And change the hostnames, usernames, password and ports.
Make sure start.sh is executable: chmod +x start.sh
If all this succeeded, you can attempt to start the server with ./start.sh!
Portforwarding
Remember to forward the appropriate ports or your server will not be visible!
Webport, 27000-27050 TCP/UDP (default server port) and 4380 UDP
As per https://support.steampowered.com/kb_article.php?ref=8571-GLVN-8711
Server startup script and nfig files copied below for reference
start.sh
--cut below--
#!/bin/bash
echo -n "Killing any previous servers: "
killall server_linux32
sleep 2
echo
echo -n "Starting NS2 Server: "
cd /home/<username>/ns2server/ns2
screen -A -m -d -S ns2 ./server_linux32 -name "Server title in browser" -webadmin -webdomain <LANaddresshere> -webuser <webusername> -webpassword <webuserpass> -webport <webport> -map ns2_biodome -ip <LANadresshere> -port 27015 -limit 16 -logdir /home/<username>/ns2server/log -config_path "/home/<username>/ns2server/config"
cd /home/<username>/ns2server
sleep 2
echo
echo "Attaching to server console..."
screen -x ns2
--cut above--
MapCycle.json
--cut below--
{
"maps": [ "ns2_descent", "ns2_docking", "ns2_mineshaft", "ns2_summit", "ns2_tram", "ns2_veil", "ns2_refinery", "ns2_biodome" ],
"time": 30,
"mode": "order",
"mods": [ ]
}
--cut above--
Cycle all official maps at time of writing.
ServerAdmin.json
--cut below--
{
"groups":
{
"admin_group": { "type": "allowed", "commands": [ "sv_changemap", "sv_reset", "sv_say", "sv_cheats"] },
"mod_group": { "type": "disallowed", "commands": [ "sv_ban", "sv_reset" ] },
"clan_group": { "type": "allowed", "commands": [ "sv_kick", "sv_say" ] }
}
"users":
{
"joe": { "id": 1234567, "groups": [ "admin_group" ] },
"bob": { "id": 12345678, "groups": [ "mod_group" ] }
}
}
--cut above--
Change users and their ids to the people you want to be admin or mod
ServerConfig.json
--cut below--
{
"settings": {
"rookie_friendly": false,
"end_round_on_team_unbalance": 0.4,
"auto_kick_afk_time": 300,
"auto_team_balance": {
"enabled_after_seconds": 10,
"enabled_on_unbalance_amount": 2
},
"auto_kick_afk_capacity": 0.5
},
"tags": [ "tag" ]
}
--cut above--
Current afk kick is set to kick after 5m
edit: couple of typos
Will look into the sv_commands and json rights issue, thanks radionaut!
edit2: removed \ from start.sh file, added sleep 2 after server start to give attach a bit more time to succeed, added attachment with corrected start.sh
TODO:
-check permissions issues with ServerAdmin.json
Comments
i'm still a linux noob, so naturally hit a few minor snags along the way.
should read: -xvzf ns2scripts.tar.gz
should read: \"/home/<username>/ns2server/config\" (also works fine without quotes/escaped quotes)
also, a user assigned to the admin group claimed to have no privileges to execute sv_* commands.
after 'chmod 664 ServerAdmin.json' and a server restart, the sv_* commands worked (644 being default for that file).
^^ not sure what to make of that, i'll have to look into it further (maybe it was simply a mistype on their part?)
anyway, thanks again for this.
Thank you for the feedback!
Will make corrections to OP.
Edit: after deleting the old attachment I couldn't find a way to attach the new file..