How to Set Up a Dedicated Battlefield2 Server
From Section6wiki
Contents |
How to Set Up a Dedicated Battlefield2 Server
This guide will cover installing, and configuring a dedicated Battlefield 2 server on GNU/Linux. This is a pretty straight forward task and requires minimal configuration, depending on your preferences..
Server Requirements
According to EA.com's website, these are the minimum requirements for a Linux dedicated server:
CPU: 1 Ghz RAM: 256 Mb
Recommended Specification, based on playing a 64 player game:
CPU: 3 Ghz. For AMD Athlon 64 CPU: 3500+ (2.2 Ghz) RAM: 2 Gb
It is reported that a full 64player server requires 8Mb/s of bandwidth.
Installation
The Official BF2 Website has several mirrors for downloading the unranked Linux server files.
First get the installer:
wget ftp://largedownloads.ea.com/pub/patches/BF2/1.4/bf2-linuxded-1.1.2963-795-installer.sh.gz
Then extract it:
gunzip bf2-linuxded-1.1.2963-795-installer.sh.gz
Make the installer executable:
chmod u+x bf2-linuxded-1.1.2963-795-installer.sh
Optional: Create a new user under which the game server will run. It is highly recommended not to run the server as root!
adduser bf2
Run the installer:
sh bf2-linuxded-1.1.2963-795-installer.sh
You have to accept the BF2 EULA by typing 'accept'. If you want to, you can also install Punkbuster by accepting it's EULA, simply entering 'yes'.
Next, you have to enter where the server should be installed. A folder called 'bf2' will be created below the specified location, so if you use /home/bf2 for your user's home directory you will get /home/bf2/bf2 as the install directory.
After a few seconds, you should get a message "Installation complete."
Make sure /tmp is NOT mounted noexec. If it is, remount -oexec /tmp for the length of the installation.
Configuration
Change into your BF2 installation directory and edit the server config file:
nano -w mods/bf2/settings/serversettings.con
These are the most important settings:
#serversettings.con|
sv.serverName "BF2 Server" // Name of your BF2-Server
sv.welcomeMessage "text line 1 | text line 2 | [...]" // Server welcome message,
// use ' |' for a linebreak.
sv.password "" // Password needed for players to join the server
sv.internet 0 // 0 = LAN server, 1 = internet server
sv.serverIP "192.168.1.1" // IP of your server
sv.serverPort 16567 // Port of your server
sv.punkBuster 1 // 0 = disable Punkbuster, 1 = enable Punkbuster
sv.maxPlayers 32 // Maximum number of allowed players (16, 32, 64)
sv.numPlayersNeededToStart 10 // For ranked servers, this needs to be:
// 6 for maxPlayers 16, 10 for 32, 10 for 64
sv.roundsPerMap 2 // How often each map will be replayed
sv.[*]FriendlyFire 100 // For ranked servers: FF on and at 100% damage
sv.friendlyFireWithMines 1 // same as above
sv.tkPunishEnabled 1 // For ranked servers, you need FF-punish on
sv.interfaceIP "192.168.1.1" // IP of your server
Edit your maplist to contain the maps you want to have in your map cycle:
nano -w mods/bf2/settings/maplist.con}} #maplist.con mapList.append dalian_plant gpm_cq 32 mapList.append daqing_oilfields gpm_cq 32 mapList.append dragon_valley gpm_cq 32 mapList.append fushe_pass gpm_cq 32 mapList.append gulf_of_oman gpm_cq 32 mapList.append kubra_dam gpm_cq 32 mapList.append mashtuur_city gpm_cq 32 mapList.append operation_clean_sweep gpm_cq 32 mapList.append sharqi_peninsula gpm_cq 32 mapList.append songhua_stalemate gpm_cq 32 mapList.append strike_at_karkand gpm_cq 32 mapList.append zatar_wetlands gpm_cq 32
Additionally, if you want to enable rcon, you have to create admin/default.cfg:
nano -w admin/default.cfg}}
#default.cfg port=4711 // rcon port password=pass // rcon password
Running the server
I recommend not starting the server as root. The game does run as any user, you might want to add a special bf2-user. Then change to this users idetity:
su - bf2 cd ./bf2/
To view the different starting parameters:
./start.sh +help}}
Starting the server:
./start.sh +dedicated}}
It is a good idea to start the game using screen, because the server keeps a command line open. To start the game using screen, use the following command line: (+lowPriority can be used to make sure the server runs smooth even if bf2 causes heavy load):
./start.sh +dedicated +lowPriority}}
Use <ctrl-a> then <ctrl-d> to detach from the screen session, leaving it running in the background. You can later re-connect to the command line session with:
screen -r}}
Firewall Rules
EA says not to use a firewall on a server, but we all know that is silly.
From the BF2 Technical Wiki, these rules should allow the server to be listed in the server browser and for VOIP to work.
-A <ChainName> -m udp -p udp -m multiport --dports 29900,29901,29902,29903,29904,16567,55125 -j ACCEPT -A <ChainName> -m tcp -p tcp -m multiport --dports 4711 -j ACCEPT -A <ChainName> -m udp -p udp --sport 29910 -s 207.38.8.27 -j ACCEPT -A <ChainName> -m udp -p udp --sport 29910 -s 207.38.8.28 -j ACCEPT
Weapon unlocks
Weapon unlocks haven't been available since the 1.01 patch. Before 1.01 you could edit Template:Filename.
Find the line:
#unlocks.py defaultUnlocks = [0, 0, 0, 0, 0, 0, 0]
and edit it to this one:
defaultUnlocks = [1, 1, 1, 1, 1, 1, 1]
then all connected players could play with all weapons enabled.
Here is a quick hack for unlocking the weapons on more current versions of the server. This post has cgi code if you'd like to use your own webserver instead.
UPDATE - The hack above worked as of 05/14/2006 with v1.22. Locally created dedicated server and local client connected to it - all unlocks available.
See Also
Fuitad guide.
BF2 Technical Information Wiki
BF2CC - server management daemon and client

