Page 1 of 4 123 ... LastLast
Results 1 to 10 of 40

Thread: [CoD2] Setup CoD2 on your Ubuntu server

  1. #1
    Assadministrator IzNoGoD's Avatar
    Join Date
    Aug 2012
    Posts
    1,718
    Thanks
    17
    Thanked 1,068 Times in 674 Posts

    [CoD2] Setup CoD2 on your Ubuntu server

    First off, I'd like to thank any and all sources I've used over the years to gather all this information. I cannot name them individually, however, if you feel special enough that you think you require a listing, send me a PM and I'll put you in my list of special people.


    So, first off, you'd need a server with ubuntu x64 minimal (this tutorial should work an all versions between 12.04 and 20.04 without any modification). Any other linux installation might also work (debian is closesly related to ubuntu, so the steps listed here will probably work on a debian install as well) (CentOS is not that closely related so most steps will require changing). Aquiring such a server is a thing you have to figure out for yourself. You can buy one of the many VPS's (virtual private servers) or run linux locally (on your own server/inside a VM/on your main pc) and go from there.


    Step 1: Securing your server

    The first steps you should always take when running any internet-facing server is securing the server. The most common attack vector for internet facing servers is ssh root password bruteforcing (clicky), so moving away from both password usage for ssh logon as well as root login is a valid first step. Basically, it involves you following this guide: guide is here (choose your ubuntu version at the top right of that page, defaults to 14.04). If you're really paranoid about security you might want to generate your public/private key file on your local pc instead of on your server, use puttygen.

    The next step in securing your ssh login is putting it on a different port. By default ssh listens on port 22, on ANY ssh installation. This means that portscans/brute force attacks will try port 22 first. Changing your ssh port basically boils down to editting /etc/ssh/sshd_config and changing the Port 22 line to some other port, preferably above 1024, but it must be below 65536 (I'm using a port between 30000 and 40000). Hereafter you have to restart your ssh deamon (ubuntu: service ssh restart) and reconnect your client on the new port.

    After this, you should configure a firewall (example here). Keep in mind that changing your ssh port requires you to actually read the stuff at that link or you might lock yourself out of your server.

    Step 2: Installing CoD2 prerequisites
    CoD2 prerequisites are as easy as doing:
    Code:
    sudo dpkg --add-architecture i386
    sudo apt-get update
    sudo apt-get -y install libstdc++5:i386
    Although I'm not 100% sure that covers ALL the prerequisites. If cod fails to run, try installing the libcod prerequisites (step 4) as well.
    Last edited by IzNoGoD; 2nd March 2017 at 18:56.
    "Does not work" is an error report for a bug between keyboard and chair.

    All hail Artie Effem

  2. The Following 6 Users Say Thank You to IzNoGoD For This Useful Post:

    Lonsofore (3rd March 2017),Mitch (30th November 2015),pollo (12th May 2016),raphael (27th May 2023),thOuMta (28th December 2015),YuriJurek (30th November 2015)

  3. #2
    Assadministrator IzNoGoD's Avatar
    Join Date
    Aug 2012
    Posts
    1,718
    Thanks
    17
    Thanked 1,068 Times in 674 Posts
    Step 3: Installing CoD2
    Installing cod2 is as simple as uploading the lnxded file (see another thread here on killtube for the binary files) to, for example, /home/USERNAME/_bin/cod2/cod2_lnxded_1_3 . This needs at least file permissions 500, (read+execute for the owner, assuming you're gonna run this under your own username) so
    Code:
    chmod 500 cod2_lnxded_1_3
    Then you need to upload the corresponding main directory to your server (note: main directories differ between v1.0/1.2/1.3) to, for example, /home/USERNAME/_stock/cod2_1_3/main/
    These files need to be readable by the useraccount that will start the server

    Step 4 (optional): Installing libcod prerequisites
    As copied from the libcod github:
    Code:
    sudo apt-get -y install gcc-multilib
    sudo apt-get -y install libmysqlclient-dev:i386
    sudo apt-get -y install g++-multilib
    I've tried installing these all in one command, but that failed for some unknown reasons. So just keep these as separate commands.

    Step 5 (optional): compiling libcod from source
    In order to compile libcod, you first need to obtain the source code. There are currently multiple libcod versions out there:
    Kung foo man's original version
    Mitch's version which is a bit more experimental and has a few more features than the original version
    Php's version has a few nice functions but seems to be out-of-date
    voron00's version which seems to be the best maintained version currently

    To obtain the code, either download the source from github and upload, or
    Code:
    sudo apt-get install git
    git clone [github url here]
    You can then easily compile the stuff with
    Code:
    ./doit.sh clean
    ./doit.sh base
    ./doit.sh cod2_1_3
    For different cod versions, change the last line.
    The final product (the actual libcod "executable") is then inside the bin folder as libcod2_1_3.so

    Step 6: Starting your CoD2 server
    Create a .sh file with the following contents:
    Code:
    #!/bin/bash
    
    sv_maxclients="32"
    fs_game="your_mod_folder_here"
    fs_homepath="/home/USER_HERE/YOUR_COD_DIR"
    cod="/full/path/to/cod2_1_3_lnxded"
    com_hunkMegs="256"
    config="configfile.cfg"
    net_port="28960"
    
    
    args=\
    "+set fs_homepath \"$fs_homepath\" "\
    "+set fs_game $fs_game "\
    "+set net_port $net_port "\
    "+set com_hunkMegs $com_hunkMegs "\
    "+set sv_maxclients $sv_maxclients "\
    "+set fs_basepath \"$fs_homepath\" "\
    "+exec $config"
    
    $cod $args +set g_gametype tdm +map mp_toujane
    Adjust where required.

    Then, start your server with:
    Code:
    ./filename.sh
    To keep your server running after you leave the ssh session, use screen:
    Code:
    screen -AmdS somename
    screen -x somename
    ./filename.sh
    Step 7 (optional): Starting your CoD2 server with libcod
    Requires a few small edits to your .sh file:
    Code:
    #!/bin/bash
    
    sv_maxclients="32"
    fs_game="your_mod_folder_here"
    fs_homepath="/home/USER_HERE/YOUR_COD_DIR"
    cod="/full/path/to/cod2_1_3_lnxded"
    com_hunkMegs="256"
    config="configfile.cfg"
    cracked="1"
    net_port="28960"
    
    
    args=\
    "+set fs_homepath \"$fs_homepath\" "\
    "+set sv_cracked $cracked "\
    "+set fs_game $fs_game "\
    "+set net_port $net_port "\
    "+set com_hunkMegs $com_hunkMegs "\
    "+set sv_maxclients $sv_maxclients "\
    "+set fs_basepath \"$fs_homepath\" "\
    "+exec $config"
    
    LD_PRELOAD="relative/path/to/libcod2_1_3.so" $cod $args +set g_gametype tdm +map mp_toujane
    Step 8: Creating your first mod
    work in progress

    Step 9: Protecting your server
    Update: Since a few months a patch has been added to both Mitch's github repo as wel as voron00's. The next passage is not applicable to any who use an updated libcod version from the aforementioned sources.

    To prevent your server from being used as a ddos amplifier (http://blog.alejandronolla.com/2013/...sis-2-slash-2/), you have to apply some iptables rules. As you should have iptables installed from the previous steps already, you can skip right to the protection part. Create a file called anti_ddos in /etc/init.d with the following contents:
    Code:
    #!/bin/bash
    
    # Carry out specific functions when asked to by the system
    case "$1" in
      start)
    		iptables -N QUERY-BLOCK
    		iptables -A QUERY-BLOCK -m recent --set --name blocked-hosts -j DROP
    		iptables -N QUERY-CHECK
    		iptables -A QUERY-CHECK -p udp -m string ! --string "getstatus" --algo bm --from 32 --to 41 -j RETURN
    		iptables -A QUERY-CHECK -p udp --sport 0:1025 -j DROP
    		iptables -A QUERY-CHECK -p udp --sport 3074 -j DROP
    		iptables -A QUERY-CHECK -p udp --sport 7777 -j DROP
    		iptables -A QUERY-CHECK -p udp --sport 8002 -j DROP
    		iptables -A QUERY-CHECK -p udp --sport 27015:27100 -j DROP
    		iptables -A QUERY-CHECK -p udp --sport 25200 -j DROP
    		iptables -A QUERY-CHECK -p udp --sport 25565 -j DROP
    		iptables -A QUERY-CHECK -m recent --update --name blocked-hosts --seconds 30 --hitcount 1 -j DROP
    		iptables -A QUERY-CHECK -m hashlimit --hashlimit-mode srcip --hashlimit-name getstatus --hashlimit-above 5/second -j QUERY-BLOCK
    		iptables -A INPUT -p udp --dport 28960 -j QUERY-CHECK
        ;;
    	stop)
    		exit 0
    		;;
      *)
        echo "Usage: /etc/init.d/anti_ddos {start|stop}"
        exit 1
        ;;
    esac
    
    exit 0
    To protect more than just the default port, edit this line:
    Code:
    iptables -A INPUT -p udp --dport 28960 -j QUERY-CHECK
    into something like:
    Code:
    iptables -A INPUT -p udp --dport 28960:28970 -j QUERY-CHECK
    This will limit the amount of queries to 5/second per client which should be plenty for normal queries and should temper or block all ddos amplifications.

    Save this file, chmod 500 it, and add it to bootup with
    Code:
    sudo update-rc.d anti_ddos defaults
    Check if it works by doing:
    Code:
    service anti_ddos start
    twice. If you see "chain already exists" you did everything right.

    Step 10: Go make something awesome
    work in progress
    Last edited by IzNoGoD; 8th September 2016 at 14:44.
    "Does not work" is an error report for a bug between keyboard and chair.

    All hail Artie Effem

  4. The Following 8 Users Say Thank You to IzNoGoD For This Useful Post:

    agribilos (25th May 2020),Invictus (9th June 2016),Lonsofore (3rd March 2017),pollo (12th May 2016),RobsoN (11th December 2016),thOuMta (28th December 2015),voron00 (3rd January 2016),YuriJurek (28th February 2016)

  5. #3
    Assadministrator IzNoGoD's Avatar
    Join Date
    Aug 2012
    Posts
    1,718
    Thanks
    17
    Thanked 1,068 Times in 674 Posts
    (reserved)
    "Does not work" is an error report for a bug between keyboard and chair.

    All hail Artie Effem

  6. #4
    Brigadier General
    Join Date
    Dec 2012
    Posts
    1,012
    Thanks
    440
    Thanked 171 Times in 132 Posts
    Really looking forward to all info

  7. #5
    Assadministrator IzNoGoD's Avatar
    Join Date
    Aug 2012
    Posts
    1,718
    Thanks
    17
    Thanked 1,068 Times in 674 Posts
    Updated, only step 10 missing now
    "Does not work" is an error report for a bug between keyboard and chair.

    All hail Artie Effem

  8. The Following 2 Users Say Thank You to IzNoGoD For This Useful Post:

    Ni3ls (28th February 2016),thOuMta (28th February 2016)

  9. #6
    Private
    Join Date
    Mar 2018
    Posts
    36
    Thanks
    8
    Thanked 6 Times in 6 Posts
    Maybe Im dumb, or I dont know.

    I've uploaded main files, ive downloaded cod2_lnxded_1_3_cracked.zip
    My folder looks like this
    home/cod2server/cod2_lnxded_1_3
    home/cod2server/main/dedicated.cfg
    home/cod2server/main/(here al iw files as normal)

    I have paste and verify this command in putty:

    iptables -I INPUT -p UDP --sport 20700 -s cod2master.activision.com -j REJECT

    of course i've installed all packages by this command:

    sudo apt-get install mailutils postfix curl wget file bzip2 gzip unzip bsdmainutils python util-linux ca-certificates binutils bc tmux libstdc++6

    and after all this I wanted to finally start cod server by this command:

    ./cod2_lnxded_1_3_cracked +set +exec dedicated.cfg

    and nothing happens - my server is not working :/

    here is my cfg:
    sets _ADMIN "rogales"
    sets _EMAIL "rogaldinho@gmail.com"
    sets _IRC ""
    sets _WEBSITE ""
    sets _LOCATION "Poland"
    set sv_hostname "Zjednoczone Chlejtuny Jebane"
    set scr_motd "Witaj na serwerze. Wymagamy napierdalania i przeklinania!"
    set net_ip "194.182.71.250"
    set net_port "28960"
    set dedicated "2"
    set rconpassword "huj"
    set sv_pure "1"
    set sv_maxplayers "20"
    set sv_minping "0"
    set sv_maxping "0"
    set sv_maxrate "0"
    set sv_voice "0"
    set g_password ""
    set sv_drawfriend "0"
    set scr_friendlyfire "0"
    set scr_forcerespawn "1"
    set scr_killcam "1"
    set g_allowvote "1"
    set scr_teambalance "1"
    set scr_spectateenemy "0"
    set scr_spectatefree "0"
    set scr_allow_bar "1"
    set scr_allow_bren "1"
    set scr_allow_enfield "1"
    set scr_allow_enfieldsniper "1"
    set scr_allow_g43 "1"
    set scr_allow_greasegun "1"
    set scr_allow_kar98k "1"
    set scr_allow_kar98ksniper "1"
    set scr_allow_m1carbine "1"
    set scr_allow_m1garand "1"
    set scr_allow_mp40 "1"
    set scr_allow_mp44 "1"
    set scr_allow_nagant "1"
    set scr_allow_nagantsniper "1"
    set scr_allow_pps42 "1"
    set scr_allow_ppsh "1"
    set scr_allow_shotgun "1"
    set scr_allow_springfield "1"
    set scr_allow_sten "1"
    set scr_allow_svt40 "1"
    set scr_allow_thompson "1"
    set scr_allow_fraggrenades "1"
    set scr_allow_smokegrenades "1"
    set scr_ctf_scorelimit "5"
    set scr_ctf_timelimit "30"
    set scr_dm_scorelimit "50"
    set scr_dm_timelimit "30"
    set scr_sd_bombtimer "60"
    set scr_sd_graceperiod "15"
    set scr_sd_roundlength "4"
    set scr_sd_roundlimit "0"
    set scr_sd_scorelimit "50"
    set scr_sd_timelimit "30"
    set scr_tdm_scorelimit "100"
    set scr_tdm_timelimit "30"
    set scr_hq_scorelimit "450"
    set scr_hq_timelimit "30"
    set sv_mapRotationCurrent ""
    sv_maprotation "gametype dm map mp_breakout gametype dm map mp_brecourt gametype dm map mp_burgundy gametype dm map mp_carentan gametype dm map mp_dawnville gametype dm map mp_decoy gametype dm map mp_downtown gametype dm map mp_farmhouse gametype dm map mp_leningrad gametype dm map mp_matmata gametype dm map mp_railyard gametype dm map mp_toujane gametype dm map mp_trainstation gametype tdm map mp_breakout gametype tdm map mp_brecourt gametype tdm map mp_burgundy gametype tdm map mp_carentan gametype tdm map mp_dawnville gametype tdm map mp_decoy gametype tdm map mp_downtown gametype tdm map mp_farmhouse gametype tdm map mp_leningrad gametype tdm map mp_matmata gametype tdm map mp_railyard gametype tdm map mp_toujane gametype tdm map mp_trainstation gametype sd map mp_breakout gametype sd map mp_brecourt gametype sd map mp_burgundy gametype sd map mp_carentan gametype sd map mp_dawnville gametype sd map mp_decoy gametype sd map mp_downtown gametype sd map mp_farmhouse gametype sd map mp_leningrad gametype sd map mp_matmata gametype sd map mp_railyard gametype sd map mp_toujane gametype sd map mp_trainstation gametype ctf map mp_breakout gametype ctf map mp_brecourt gametype ctf map mp_burgundy gametype ctf map mp_carentan gametype ctf map mp_dawnville gametype ctf map mp_decoy gametype ctf map mp_downtown gametype ctf map mp_farmhouse gametype ctf map mp_leningrad gametype ctf map mp_matmata gametype ctf map mp_railyard gametype ctf map mp_toujane gametype ctf map mp_trainstation gametype hq map mp_breakout gametype hq map mp_brecourt gametype hq map mp_burgundy gametype hq map mp_carentan gametype hq map mp_dawnville gametype hq map mp_decoy gametype hq map mp_downtown gametype hq map mp_farmhouse gametype hq map mp_leningrad gametype hq map mp_matmata gametype hq map mp_railyard gametype hq map mp_toujane gametype hq map mp_trainstation"
    map_rotate

  10. The Following User Says Thank You to rgl12 For This Useful Post:

    kubislav23 (7th March 2018)

  11. #7
    Assadministrator kung foo man's Avatar
    Join Date
    Jun 2012
    Location
    trailerpark
    Posts
    2,010
    Thanks
    2,102
    Thanked 1,083 Times in 753 Posts
    What do you see in Putty? Just select everything with mouse to copy the text automatically and post it here in [code]-tag
    timescale 0.01

  12. The Following User Says Thank You to kung foo man For This Useful Post:

    kubislav23 (7th March 2018)

  13. #8
    Private
    Join Date
    Mar 2018
    Posts
    36
    Thanks
    8
    Thanked 6 Times in 6 Posts
    Quote Originally Posted by kung foo man View Post
    What do you see in Putty? Just select everything with mouse to copy the text automatically and post it here in [code]-tag
    this:
    Code:
    https://i.imgur.com/x4pvdH6.png
    and this:

    Code:
    https://i.imgur.com/lnoWJWw.png
    Last edited by rgl12; 7th March 2018 at 21:12.

  14. #9
    Assadministrator kung foo man's Avatar
    Join Date
    Jun 2012
    Location
    trailerpark
    Posts
    2,010
    Thanks
    2,102
    Thanked 1,083 Times in 753 Posts
    Do step 3

    Code:
    chmod 500 ./cod2_lnxded_1_3_cracked
    or just

    Code:
    chmod +x ./cod2_lnxded_1_3_cracked
    timescale 0.01

  15. #10
    Private
    Join Date
    Mar 2018
    Posts
    36
    Thanks
    8
    Thanked 6 Times in 6 Posts
    Ok.
    Now I got this.

    Code:
    root@rgl:/home# cd cod2server
    root@rgl:/home/cod2server# chmod 500 ./cod2_lnxded_1_3_cracked
    root@rgl:/home/cod2server# chmod +x ./cod2_lnxded_1_3_cracked
    root@rgl:/home/cod2server# ./cod2_lnxded_1_3_cracked +set +exec dedicated.cfg
    ./cod2_lnxded_1_3_cracked: line 1: !DOCTYPE: No such file or directory
    ./cod2_lnxded_1_3_cracked: line 2: html: No such file or directory
    ./cod2_lnxded_1_3_cracked: line 3: head: No such file or directory
    ./cod2_lnxded_1_3_cracked: line 4: title: No such file or directory
    ./cod2_lnxded_1_3_cracked: line 5: meta: No such file or directory
    ./cod2_lnxded_1_3_cracked: line 6: meta: No such file or directory
    ./cod2_lnxded_1_3_cracked: line 7: meta: No such file or directory
    ./cod2_lnxded_1_3_cracked: line 8: meta: No such file or directory
    ./cod2_lnxded_1_3_cracked: line 9: meta: No such file or directory
    ./cod2_lnxded_1_3_cracked: line 10: meta: No such file or directory
    ./cod2_lnxded_1_3_cracked: line 11: meta: No such file or directory
    ./cod2_lnxded_1_3_cracked: line 12: meta: No such file or directory
    ./cod2_lnxded_1_3_cracked: line 13: meta: No such file or directory
    ./cod2_lnxded_1_3_cracked: line 14: meta: No such file or directory
    ./cod2_lnxded_1_3_cracked: line 15: meta: No such file or directory
    ./cod2_lnxded_1_3_cracked: line 16: meta: No such file or directory
    ./cod2_lnxded_1_3_cracked: line 17: link: No such file or directory
    ./cod2_lnxded_1_3_cracked: line 18: $'\r': command not found
    ./cod2_lnxded_1_3_cracked: line 19: syntax error near unexpected token `<'
    ./cod2_lnxded_1_3_cracked: line 19: `            <link rel='stylesheet' href='/w                                                                                                 ro/viewjs-e44544f03b22fab45334dcdb8a6b3b0931e845ad.css' /><script src='/wro/view                                                                                                 js-b5af86fa1522edfe99ee6c9472e53cc88f2dc9a5.js' type='text/javascript'></script>                                                                                                 'script type="text/javascript">
    root@rgl:/home/cod2server#

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •