Gentoo Wiki


Please improve it in any way that you see fit, and remove this notice {{Cleanup}} from the article. For tips on cleaning and formatting see Cleanup process

This article is still a Stub. You can help Gentoo-Wiki by expanding it.

This guide will cover installing, and configuring a dedicated Battlefield 2 server on linux. No ebuilds are available (at this time), so we will use the official BF2 linux server archives. We will cover adding bots to a multiplayer game, and adding mods to the server. Unlocking all weapons, and general tweaking, is also covered towards the end of the guide.


Server Requirements

According to EA, these are the minimum requirements for a Linux dedicated server:

Code: Server Requirements

Minimum Specification, based on playing a 16 player game:

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.


The Official BF2 Website has several mirrors for downloading the unranked Linux server files.

First get the installer:


For version 1.41, use this link instead:


Then extract it:


Make the installer executable:

sudo chmod u+x

Optional: Create a new user under which the game server will run. It is highly recommended not to run the server as root!

sudo adduser bf2

Run the installer:

sudo 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."

Warning: Make sure /tmp is NOT mounted noexec. If it is, remount -oexec /tmp for the length of the installation.

If you get error messages about, similar to this one: "error while loading shared libraries: cannot open shared object file: No such file or directory", install libstdc++-v3 using this command:

emerge -av libstdc++-v3


Change into your BF2 installation directory and edit the server config file:

sudo nano -w mods/bf2/settings/serversettings.con

These are the most important settings:

File: 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 iplayers to join the server
sv.internet 0                  // 0 = LAN server, 1 = internet server
sv.serverIP ""      // IP of your server (must be LAN IP if behind NAT firewall)
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 ""   // IP of your server, only needs specified if server has multiple interfaces
sv.allowNATNegotiation 0       // Must be set to 1 if behind NAT firewall

(later BF2 Server (1.41): sv.serverIP "" sv.interfaceIP "")

Edit your maplist to contain the maps you want to have in your map cycle:

sudo nano -w mods/bf2/settings/maplist.con

File: 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 road_to_jalalabad 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
mapList.append wake_island_2007 gpm_cq 32

The following maps are included in the newer server packages, but users need an (not free of charge) addon to play, Highway Tampa being a notable (free) exception. Adding any of these maps will require all your users to have the addon, or they will get kicked once any of these maps load:

mapList.append greatwall gpm_cq 32
mapList.append operationsmokescreen gpm_cq 32
mapList.append taraba_quarry gpm_cq 32
mapList.append highway_tampa gpm_cq 32

Additionally, if you want to enable rcon, you have to create admin/default.cfg:

sudo nano -w admin/default.cfg

File: 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:

./ +help

Starting the server:

./ +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):

screen ./ +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.
1. Save your current firewall rules iptables-save > /etc/iptables.bak
2. Open /etc/iptables.bak in your favorite text editor
3. Add the following rule(s) in appropriate order (according to your existing rules).

Firewall Rule: BF2
-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 -j ACCEPT
-A <ChainName> -m udp -p udp --sport 29910 -s -j ACCEPT

4. Restore all rules to be part of your current configuration iptables-restore /etc/iptables.bak


not yet written


Give example with mercs3 linux mod.

Weapon unlocks

Weapon unlocks haven't been available since the 1.01 patch. Before 1.01 you could edit gameserverdir/python/bf2/stats/

Find the line:

defaultUnlocks = [0, 0, 0, 0, 0, 0, 0]

and edit it to this one:

defaultUnlocks = [1, 1, 1, 1, 1, 1, 1]

then all ccted 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 will not work for mulitplayer anymore you can try to use it for single player but it may damage your game

Tweaking the server

team ratios

server graphic+motd

ticket ratios

etc 32132132

See Also

Retrieved from ""

Last modified: Mon, 08 Sep 2008 06:58:00 +0000 Hits: 33,223