Author's Picture
Author: Joel Gray Published: 24 November 2023 Read Time: ~13 minutes

How to Set Up a Call of Duty 4 Modern Warfare Server on Linux 2023

Firstly, I’m writing this due to a lot of outdated and sparse information on the internet about how to deploy a Call of Duty 4 Modern Warfare (CoD 4) Multiplayer server in 2023. The information is out there, but here I aim to consolidate it into one concise blog post.

Note: This will require you to downgrade your CoD 4 multiplayer game application, I tried to find a way around this and had no luck, additionally you have access to way more servers when you do this so it’s a win win.

Steps are performed on a Debian system using the apt package manager, but should be easily replicated across distros.

Install dependencies on your Linux system

The following commands should install all the necessary libraries, double check during installation that there are no issues thrown as it will tell you if you are missing dependencies.

This should be run as root or a sudoer as apt requires elevated permissions.

sudo dpkg --add-architecture i386
sudo apt update && sudo apt install -y distro-info file libstdc++-10-dev libsdl2-2.0-0:i386 netcat tmux uuid-runtime curl wget tar bzip2 gzip unzip bsdmainutils python3 util-linux ca-certificates binutils bc jq lib32gcc1 lib32z1 uuid-runtime

Create user account for CoD4 server

1. Create a user, set a password when prompted.

adduser cod4server

2. Log in as user cod4server

su - cod4server

Install server using LinuxGSM

LinuxGSM gives us an easy way to install the CoD4x server and run it with a console.

1. In the home directory of your cod4server user enter the following command.

wget -O linuxgsm.sh https://linuxgsm.sh && chmod +x linuxgsm.sh && bash linuxgsm.sh cod4server

2. Run the cod4server installer

./cod4server install

If you encounter any issues please read the terminal output of the installer, it will let you know which dependencies you have and which you are missing – install any missing ones.

Copy CoD 4 game files to your Linux sever

For some games on LinuxGSM it will automatically download the required game files for you, this is not the case for CoD4.

1. Navigate to your game installation directory:

Windows:

C:\Program Files (x86)\Steam\steamapps\common\Call of Duty 4

Linux:

/home/$USER/.local/share/Steam/steamapps/common/Call of Duty 4

2. Copy the entire folders ‘main’ and ‘zone’ to your Linux server system under the directory:

/home/cod4server/serverfiles/

Note: There may already be directories with the same name, either delete or rename them

If you have FTP set up you can do it that way, or if you have physical access to the machine you can do this via USB. My preferred way to send files is SCP.

How to SCP the files to your Linux system:

From the directory of the main and zone folders, run this command: (It may take a long time)

scp -r main zone user@remote_server:/home/cod4server/serverfiles

Here’s a breakdown of the command:

  • scp: The command used to securely copy files and directories over SSH.
  • -r: This option is used to recursively copy entire directories.
  • main zone: The names of the source directories you want to copy.
  • user@remote_server: Replace this with the actual username and the hostname or IP address of the remote server.
  • /home/cod4server/serverfiles: The destination path on the remote server where the directories will be copied.

When you run this command, you will be prompted to enter the password for the user on the remote_server, unless you have set up SSH keys for passwordless authentication. After authentication, the main and zone directories, along with their contents, will be copied to the specified path on the remote server.

Update the game config file

In the /home/cod4server/serverfiles/main directory create or edit a file called ‘cod4server.cfg’. You can (and I advise you do) use the example cod4server.cfg below.

Some important config settings:

set rcon_password – This is necessary to enable and set an rcon password for the server

“Most source engine games make use of RCON – a protocol that allows server administrators to remotely execute commands on the server.”

https://nodecraft.com/support/games/csgo/setting-changing-the-rcon-password

set g_password – This is the game server password, that users will use to join your game, empty means open to public

set dedicated – For a LAN server this should be 1, for an Internet Dedicated server it should be 2

set sv_authorizemode – This must be set to 0 to show on server listings in game

set sv_mapRotation – This sets the list of maps and game types to be scheduled

set sv_authtoken – This is a token generated by signing into CoD4x using your steam account to allow your server to be listed on their master server list – generate it here: Generate sv_authtoken!

set sv_steamserverlogintoken – This is a token generated by Steam to register your game server with them, I’m unsure if this is necessary as we are using CoD4x servers but I do it anyway: Generate sv_steamserverlogintoken here!

////////////////////////////////////////////////////////////
///                                                      ///
///                                                      ///
///      Call of Duty 4 X Standard Configuration         ///
///                                                      ///
///      Author: Daedalus, Created: 08.01.2017           ///
///      Provides a general starting point for your      ///
///      CoD4X server configuration. Also contains       ///
///      features only available on CoD4X 1.8+ servers   ///
///                                                      ///
///      Updated by Joel, Date: 24.11.2023               ///
///      Contact: [email protected]                       ///
///                                                      ///
////////////////////////////////////////////////////////////


// Meta Information, not required
sets _Admin "Admin Name"
sets _Email "[email protected]"
sets _Website "example.com"
sets _Location ""
sets _Maps ""
sets _Gametype ""
/////////////////////////////////

set sv_authtoken "Place your key here"
set sv_steamserverlogintoken "Place your key here"

// Basics
set sv_hostname "For The Bois - Vanilla"
set g_motd "Welcome to Vanilla CoD4 for the bois" // Message of the day, which getting shown to every player on his 1st spawn
set dedicated "2"       // 0 = Listen, 1 = LAN, 2 = Internet ( you probably want 2 )
set rcon_password ""  // password for remote access, leave empty to deactivate, min 8 characters
set g_password ""     // join password, leave empty to deactivate
set sv_privateClients "2" //Private Clients, number of slots that can only be changed with a password
set sv_privatePassword ""  // the password to join private slots
set sv_authorizemode "0" // cdkey validation
set sv_showasranked 1 // 0 = show modded server as not ranked, 1 = shows server as ranked altough it is modded
set sv_master1 "master.activision.com"

// Log File
set g_logsync "2" // 0=no log, 1=buffered, 2=continuous, 3=append
set logfile "1" // 0 = NO log, 1 = log file enabled
set g_log "games_mp.log" // Name of log file, default is games_mp.log
set sv_log_damage "1"
set sv_statusfile "serverstatus.xml" // writes an xml serverstatus to disc, leave empty to disable

// Networking
// set net_ip "0.0.0.0" // not necessary to be set
// set net_port 28960 // network port
// set sv_maxRate 25000

set sv_minPing "0" // minimal ping [ms] for a player to join the server
set sv_maxPing "350" // maximal ping [ms] for a player to join the server
set sv_timeout 40 // Seconds to keep a client on server without a new clientmessage
set sv_connectTimeout 90 // Seconds to wait for a client which is loading a map without a new clientmessage
set sv_zombieTime 2 // Seconds to keep a disconnected client on server to transmit the last message
set sv_reconnectlimit 5 // Seconds to disallow a prior connected client to reconnect to the server

// Floodprotection is enabled by default!
// sv_floodProtect, sv_maxRate, 


// Variables you should not touch :)
// set sv_fps "20" //Server-FPS (do not change!)
// set sv_punkbuster "0" //Punkbuster, PB is not supported on CoD4x
// set sv_pure "1" //check IWD-data 0 = off, 1 = on
// set g_antilag "1" //0 = off, 1 = on // Anti lag checks for weapon hits
// set ModStats 1 // 1 = use player stats file for mods (normal behaviours), 0 = use player stats file of basegame (DANGEROUS!!! as it can overwrite your stats)



// Variables I have no clue what they are doing :D
set sv_allowAnonymous "0" // Anonymous //0 = off 1 = on


//////////////////////
// Gameplay

// Maps
set sv_mapRotation "gametype dm map mp_backlot gametype dm map mp_bloc gametype war map mp_bog gametype dm map mp_cargoship gametype dm map mp_citystreets gametype dm map mp_convoy gametype dm map mp_countdown gametype dm map mp_crash gametype dm map mp_crossfire gametype dm map mp_farm gametype dm map mp_overgrown gametype dm map mp_pipeline gametype dm map mp_shipment gametype dm map mp_showdown gametype dm map mp_strike gametype dm map mp_vacant" // maps that will be played automatically
set sv_randomMapRotation 1 // 0 = sv_mapRotation is randomized, 1 = sequential order of sv_mapRotation

set g_deadChat "1" // dead can chat // 0 = off, 1 = on
set voice_deadChat "0" // dead can use voicechat //0 = off, 1 = on
set g_gravity "800" //Gravity //Standard 800
set sv_disableClientConsole "0" //deactivate console for clients //0 = no, 1 = yes
set scr_teambalance "1" //auto-teambalance //0 = no, 1 = yes
set scr_team_fftype "0" //friendly-fire //0 = off, 1 = on, //2 = reflect damage, 3 = shared damage
set scr_game_spectatetype "2" // spectator // 0 = off, 1 = only Team/player, 2 = free
set scr_hardcore 0 //Hardcore Mode //0 = off 1 = on
set scr_oldschool "0" //Oldschool Mode //0 = off, 1 = on

set g_friendlyPlayerCanBlock 1 // 1 = player collision between friendly players, 0 = collision between friendly players is disabled
set g_FFAPlayerCanBlock 1 // same for FFA (non team based) gamemode

// Less interesting Gameplay stuff
set scr_drawfriend "1" //show team mates //0 = off, 1 = on
set scr_enable_scoretext "1" //hit-message //0 = no, 1 = yes
set scr_game_allowkillcam "1" //Killcam //0 = no, 1 = yes // Allow to play killcam after you got killed
set scr_game_deathpointloss "0" //points-distraction when hit //0 = no, 1 = yes
set scr_game_suicidepointloss "0" //points-distraction suicide //0 = no, 1 = yes
set scr_game_matchstarttime "10" //time until match starts
set scr_game_playerwaittime "10" //respawn-delay
set scr_player_forcerespawn "-1" //force respawn //0 = no, 1 = yes // forgot what -1 did but i believe it was different xD
set scr_player_healthregentime "5" //health regeneration (in seconds)
set scr_player_maxhealth "100" //Max health
set scr_player_sprinttime "4" //Sprint-time
set scr_game_onlyheadshots "0" //headshots only //0 = no, 1 = yes
set scr_teamKillPunishCount "3" //Teamkiller kick after x Teamkills
set scr_team_teamkillspawndelay "20" //teamkill spawn delay (in seconds)
set scr_team_teamkillpointloss "1" //pointloss after Teamkill //0 = no, 1 = yes
set scr_enable_hiticon "1" //Hit-Symbol //0 = off, 1 = on

//Game-Modes
//Death Match (dm)
set scr_dm_scorelimit "1000"
set scr_dm_timelimit "10"
set scr_dm_roundlimit "1"
set scr_dm_numlives "0"
set scr_dm_playerrespawndelay "0"
set scr_dm_waverespawndelay "0"

//Team Death Match (war)
set scr_war_scorelimit "2000"
set scr_war_timelimit "10"
set scr_war_roundlimit "1"
set scr_war_numlives "0"
set scr_war_playerrespawndelay "3"
set scr_war_waverespawndelay "0"

//Domination (dom)
set scr_dom_scorelimit "250"
set scr_dom_timelimit "0"
set scr_dom_numlives "0"
set scr_dom_playerrespawndelay "3"
set scr_dom_roundlimit "1"
set scr_dom_waverespawndelay "0"

//HQ (koth)
set scr_koth_scorelimit "250"
set scr_koth_timelimit "15"
set koth_kothmode "0" //Classic HQ-Mode 0 = off, 1 = on
set koth_capturetime "20"
set koth_spawntime "3" //0 = immediately, x = time in seconds
set scr_koth_numlives "0"
set scr_koth_playerrespawndelay "3"
set scr_koth_roundlimit "1"
set scr_koth_roundswitch "1"
set scr_koth_waverespawndelay "0"
set koth_autodestroytime "60"
set koth_delayPlayer "3"
set koth_destroytime "10"
set koth_spawnDelay "3"

//Sabotage (sab)
set scr_sab_scorelimit "2"
set scr_sab_timelimit "10"
set scr_sab_roundswitch "1"
set scr_sab_bombtimer "30"
set scr_sab_planttime "2.5"
set scr_sab_defusetime "5"
set scr_sab_hotpotato "0"
set scr_sab_numlives "0"
set scr_sab_playerrespawndelay "5"
set scr_sab_roundlimit "0"
set scr_sab_waverespawndelay "0"

//Search and destroy (sd)
set scr_sd_scorelimit "9"
set scr_sd_timelimit "2.5"
set scr_sd_roundswitch "4"
set scr_sd_bombtimer "45"
set scr_sd_planttime "5"
set scr_sd_defusetime "7"
set scr_sd_multibomb "0"
set scr_sd_numlives "1"
set scr_sd_playerrespawndelay "0"
set scr_sd_roundlimit "0"
set scr_sd_waverespawndelay "0"

set g_gametype "dm" // gamemode, one of [war, dm, sd, sab, koth]

// Amazing Stuff
//set sv_autodemorecord 1 // Records demos of players on the serverside, demos are stored in "demos" folder
//set sv_demoCompletedCmd "" // program to execute when a demo has been saved
//set sv_screenshotArrivedCmd "" // program to execute when a screenshot was taken
//set sv_legacyguidmode 0 // 1 = old 32 character guids are used, 0 = new cod4x guid format is used ( like steamids )

///////////////////////////
// Setup for custom maps when running a mod
// seta sv_wwwDownload "1" // enable download redirection
// seta sv_wwwBaseURL "http://someserver/cod4dl/" // defines url to download from
// seta sv_wwwDlDisconnected "0" // disconnect clients while downloading
///////////////////////////


set sv_nosteamnames 1 // 1 = Use names from steam if steam is available

map_rotate // required to load the first map of the rotation, alternatively use "map mp_killhouse" or pass "+set map mp_killhouse" as commandline argument

Expose Ports

We need to expose the necessary ports on our router (if server is running from your house) and your firewall (if you’re using one). If you’re running this on a VPS you might need to do this in your providers security or firewall settings, via their admin page or a tool like Plesk.

CoD 4 servers run using the following ports:

	UDP	28960-28970
UDP 20800
UDP 20810
Expose Ports on your Router
  1. Access Router Settings:
    • Open a web browser and enter your router’s IP address (commonly 192.168.0.1 or 192.168.1.1 occasionally it will be 192.168.0.254 or 192.168.1.254)
    • Log in with your username and password.
  2. Navigate to Port Forwarding Section:
    • Look for a section named “Port Forwarding”, “Port Mapping”, “Gaming”, “Virtual Servers”, or something similar.
    • This section can usually be found under the advanced settings.
  3. Set Up Port Forwarding Rules:
    • Create new port forwarding rules for each of the UDP ports mentioned (28960-28970, 20800, 20810).
    • You will need to specify:
      • The external port range (e.g., 28960-28970).
      • The internal IP address of the machine running the server (find this on your computer or server).
      • The internal port range (usually the same as the external).
      • The protocol (in this case, UDP).
    • Save or apply changes after setting up each rule.

Note: Your server should have a static local if you’re exposing ports on you home router, too stop the internal IP changing.

Disclaimer: Exposing ports opens your network to the outside world. Make sure your server is secured and regularly updated.

Expose Ports on your UFW firewall
  1. Open Terminal:
    • On your Linux server, open a terminal.
  2. Check UFW Status:
    • Before making changes, check the status of UFW by running sudo ufw status.
  3. Add Rules for Each Port:
    • Run the following commands to allow traffic on the specified ports:
      • sudo ufw allow 28960:28970/udp
      • sudo ufw allow 20800/udp
      • sudo ufw allow 20810/udp
  4. Enable UFW:
    • If UFW is not already enabled, enable it with sudo ufw enable.
  5. Verify Rules:
    • Check if the rules are added correctly with sudo ufw status.

Replace your iw3mp.exe file with custom version

You need to downgrade your COD4 Multiplayer app (iw3mp.exe) to version 1.7 to be compatible with the CoD4x servers. This will give you access to many more servers also.

1. Navigate to your CoD 4 Modern Warfare installation location:

2. Find the iw3mp.exe – rename it to iw3mpOld.exe.

3. Download the CoD4x version of the iw3mp.exe file and place it that the same directory as the original.

4. Start your game normally and accept any popups from CoD4x

5. Your game may restart, this is normal

Download the iw3mp.exe file here. Or alternatively from this mirror.

Start and Join your server

1. Start the cod4server application by doing the following:

cd /home/cod4server/serverfiles
./cod4server start

You can view the full list of server commands by doing:

./cod4server

You can find more details about server commands here.

2. Join the server from your game

  • Start CoD 4 Multiplayer
  • Go to ‘Join Game’
  • Change the search option to ‘Internet ATVI’
  • Find your server in the list and connect. (Enter password if set)

If your server doesn’t appear in the list then you can use direct connect to see if it’s up:

Replace $PublicIP with your Public Ip and $YourPassword with your g_password value.

  • Click the ` key under the Esc key to access the console and type:
  • /connect $PublicIP; password $YourPassword

If you haven’t set a g_password then:

  • Click the ` key under the Esc key to access the console and type:
  • /connect $PublicIP;

Congratulations you should now have a working CoD 4 dedicated server up and running!

Support

If you need any extra support feel to contact me through my contact form or emailing [email protected].

Additionally you can find support for LinuxGSM here and support for CoD4x here.