How to run an EA Battlefield 2 server on FreeBSD

1395

Author: Mikael Vingaard

Many players of Electronic Arts‘ multiplayer online game Battlefield 2 run Battlefield 2 game servers, either at home or as a hosted solution. Most use Windows or Linux as their server operating system. Few people know that you can use FreeBSD as well. Here’s how you can set up a Battlefield 2 server on FreeBSD 6.0 RC-1.

In Battlefield 2 you play a soldier from either the United States Marines, Middle East Coalition, or China. This is not another shoot’em up game — the focus is on team play and coordination between the players on the team. One nice feature in the game is that the size of the maps over which you battle is dynamic, adjusted according to how many players are logged on to the server.

Why would you want to set up your own server? Sometimes Battlefield players may wish to have administrator capacities on a server in order to practice or to play clan fights against other clans. To get admin privileges you can rent a dedicated public server at EA Games for $8 per slot per month or you can host your own server.

Why choose FreeBSD instead of Linux? If your BSD skills are stronger than your Linux skills, it may be more convenient. You won’t pay a performance penalty — I haven’t been able to detect any differences in system response times in FreeBSD compatibility mode vs. native Linux style.

According to EA Games, the minimum server requirements for 16 players is a 1GHz processor and 256MB RAM. For up to 64 players EA Games recommends a 3.4GHz Pentium 4 with 1GB RAM at a minimum. Those are minimums — you should use the best server hardware you can afford to get the best gaming experience. Your Internet connection must be 2.5Mbps or better in order to avoid long response times, a.k.a. lags, on the server.

Setting up FreeBSD

If you are not already running FreeBSD, you’ll need to install it. If you’ve installed Linux in the past, the FreeBSD installer will not be that difficult, and there’s a good handbook online to guide you through the process.

The installer asks if you’d like to install Linux compatibility. Be sure to say “yes” to this question. If you already have FreeBSD installed, but Linux compatibility is not enabled, you can enable it by loading the Linux Kernel Loadable Object (KLD) by running kldload linux as root. See the FreeBSD handbook section for more on enabling Linux binary compatibility.

Install the Battlefield 2 Linux server

Once you’ve enabled Linux binary compatibility, it’s time to install the game server. Download the Linux Battlefield 2 server and unzip the file with the command unzip bf2-linuxded-1.1.2551.0-installer.zip. This will give you an unpacked shell file, bf2-linuxded-1.1.2551.0-installer.sh. To run it, change its permissions with the command chmod 755 bf2-linuxded-1.1.2551.0-installer.sh and run it from a regular account –not root — to install the server.

You must review and accept two license agreements. One is from the developers of the Linux server, and the other from Gamespy. After accepting the licenses, you’ll be prompted for the path to install the Battlefield 2 server to. Specify something like /home/user/battlefield2/, and that’s all there is to it.

Tweak the settings for maximum performance

Once the installation is finished, you can edit the server configuration file, atmods/bf2/settings/serversettings.con, to improve its performance. The Battlefield 2 server has a number of configuration options, but we’ll touch on just a few of the important ones.

The first is sv.serverName, which is the default server name. You’ll want to change this to your preferred server name. For example, if your server name is “battlefield.mydomain.com,” you would use:

sv.serverName "battlefield.mydomain.com"

You will also need to set the IP address for the server using the sv.serverIP parameter. If you want to password-protect your server, put your chosen password between the empty quotation marks in sv.password "". The next step is to allow Internet players to join games. If sv.internet is set to 0 (the default), the server will allow players only from your local network to join. Change the parameter to 1 to open the server to Internet players. You will need several ports open in your firewall if you want the server to be reachable from the Internet.

One tweak we can make to
improve performance is to limit the number of players allowed. As an example we
will take the “kubra_dam.” In the configuration file, you’ll find several lines with the name of the map; they are identical except for the numbers, which specify the maximum the number of allowed players on the server.

MapList.append kubra_dam gpm_cq 16
MapList.append kubra_dam gpm_cq 32
MapList.append kubra_dam gpm_cq 64

Change all three settings to the number of desired players. For example, if your maximum server capacity is 16 players at one time, change them to MapList.append kubra_dam gpm_cq 16. This can be particularly useful if you’re running a server that only meets the minimum hardware requirements. Some server admins have posted to the online forums to say that deleting the MapList lines have ruined the overall configuration, so just adjust the number of players rather than deleting the other lines.

Another way to ensure a good gaming session is to use the sv.bandwidthChoke setting. This setting states how much bandwidth, in Kbps, the server can actually use, so the server does not have to do any bandwidth polling. This will also save non-gaming LAN users some bandwidth to check email and browse the Web. Setting it to 0 means that bandwidth is not throttled at all.

If your server is very busy, one last hint to gain better performance is to install the Voice over IP (VoIP) teamspeak function on another server. Change sv.voipServerRemote 0 to sv.voipServerRemote 1 and enter the IP address of the external server in the sv.voipServerRemoteIP setting.

Now you’re ready to start playing. Start the server with the command /home/user/battlefield2/start.sh and enjoy the freedom of hosting your own server.

Category:

  • Games