Warning: preg_match(): Unknown modifier '-' in /home/akl1986/public_html/support/wp-content/plugins/redux-framework/redux-core/inc/extensions/metaboxes/class-redux-extension-metaboxes.php on line 783

Warning: preg_match(): Unknown modifier '-' in /home/akl1986/public_html/support/wp-content/plugins/redux-framework/redux-core/inc/extensions/metaboxes/class-redux-extension-metaboxes.php on line 783

Warning: preg_match(): Unknown modifier '-' in /home/akl1986/public_html/support/wp-content/plugins/redux-framework/redux-core/inc/extensions/metaboxes/class-redux-extension-metaboxes.php on line 783

Warning: preg_match(): Unknown modifier '-' in /home/akl1986/public_html/support/wp-content/plugins/redux-framework/redux-core/inc/extensions/metaboxes/class-redux-extension-metaboxes.php on line 783

Warning: preg_match(): Unknown modifier '-' in /home/akl1986/public_html/support/wp-content/plugins/redux-framework/redux-core/inc/extensions/metaboxes/class-redux-extension-metaboxes.php on line 783

Warning: preg_match(): Unknown modifier '-' in /home/akl1986/public_html/support/wp-content/plugins/redux-framework/redux-core/inc/extensions/metaboxes/class-redux-extension-metaboxes.php on line 783

Warning: preg_match(): Unknown modifier '-' in /home/akl1986/public_html/support/wp-content/plugins/redux-framework/redux-core/inc/extensions/metaboxes/class-redux-extension-metaboxes.php on line 783

Warning: preg_match(): Unknown modifier '-' in /home/akl1986/public_html/support/wp-content/plugins/redux-framework/redux-core/inc/extensions/metaboxes/class-redux-extension-metaboxes.php on line 783

Warning: Cannot modify header information - headers already sent by (output started at /home/akl1986/public_html/support/wp-content/plugins/redux-framework/redux-core/inc/extensions/metaboxes/class-redux-extension-metaboxes.php:783) in /home/akl1986/public_html/support/wp-includes/rest-api/class-wp-rest-server.php on line 1794

Warning: Cannot modify header information - headers already sent by (output started at /home/akl1986/public_html/support/wp-content/plugins/redux-framework/redux-core/inc/extensions/metaboxes/class-redux-extension-metaboxes.php:783) in /home/akl1986/public_html/support/wp-includes/rest-api/class-wp-rest-server.php on line 1794

Warning: Cannot modify header information - headers already sent by (output started at /home/akl1986/public_html/support/wp-content/plugins/redux-framework/redux-core/inc/extensions/metaboxes/class-redux-extension-metaboxes.php:783) in /home/akl1986/public_html/support/wp-includes/rest-api/class-wp-rest-server.php on line 1794

Warning: Cannot modify header information - headers already sent by (output started at /home/akl1986/public_html/support/wp-content/plugins/redux-framework/redux-core/inc/extensions/metaboxes/class-redux-extension-metaboxes.php:783) in /home/akl1986/public_html/support/wp-includes/rest-api/class-wp-rest-server.php on line 1794

Warning: Cannot modify header information - headers already sent by (output started at /home/akl1986/public_html/support/wp-content/plugins/redux-framework/redux-core/inc/extensions/metaboxes/class-redux-extension-metaboxes.php:783) in /home/akl1986/public_html/support/wp-includes/rest-api/class-wp-rest-server.php on line 1794

Warning: Cannot modify header information - headers already sent by (output started at /home/akl1986/public_html/support/wp-content/plugins/redux-framework/redux-core/inc/extensions/metaboxes/class-redux-extension-metaboxes.php:783) in /home/akl1986/public_html/support/wp-includes/rest-api/class-wp-rest-server.php on line 1794

Warning: Cannot modify header information - headers already sent by (output started at /home/akl1986/public_html/support/wp-content/plugins/redux-framework/redux-core/inc/extensions/metaboxes/class-redux-extension-metaboxes.php:783) in /home/akl1986/public_html/support/wp-includes/rest-api/class-wp-rest-server.php on line 1794

Warning: Cannot modify header information - headers already sent by (output started at /home/akl1986/public_html/support/wp-content/plugins/redux-framework/redux-core/inc/extensions/metaboxes/class-redux-extension-metaboxes.php:783) in /home/akl1986/public_html/support/wp-includes/rest-api/class-wp-rest-server.php on line 1794
{"id":2298,"date":"2019-11-26T07:45:46","date_gmt":"2019-11-26T07:45:46","guid":{"rendered":"https:\/\/support.aklwebhost.com\/?post_type=manual_kb&p=2298"},"modified":"2019-12-06T23:55:42","modified_gmt":"2019-12-06T23:55:42","slug":"setting-up-a-garrys-mod-server","status":"publish","type":"manual_kb","link":"https:\/\/support.aklwebhost.com\/knowledgebase\/setting-up-a-garrys-mod-server\/","title":{"rendered":"Setting Up a Garry’s Mod Server"},"content":{"rendered":"

The instructions are designed for\u00a0Ubuntu 14.04 32 bit<\/strong>, but should work on all versions of Ubuntu. This tutorial will teach you how to make a Garry’s Mod game server.<\/p>\n

Log in via the terminal as root.<\/strong><\/p>\n

Firstly, we need to make sure the firewall is secure to reduce the chances of a security issue. Assuming this server will be dedicated to Garry\u2019s Mod, it\u2019s safe to block absolutely all incoming ports (including ICMP) besides the ones required for Garry’s Mod. ICMP is not required for the operation of the server, and blocking it completely will not have any negative effects on Garry’s Mod, however, it will help reduce the attack vectors of a DDoS attack.<\/p>\n

To block all non-required ports, the following commands are required:<\/strong><\/p>\n

iptables -A INPUT -p icmp --icmp-type echo-request -j DROP\r\niptables -A OUTPUT -p icmp --icmp-type echo-reply -j DROP\r\n<\/code><\/pre>\n

This basically tells the firewall to ignore every ICMP packet it receives, and take absolutely no action on it. This also means if someone tries to ping your server, they will get no response. The second line tells the firewall to block all outgoing ICMP packets, this is much less important, but just double ensures there won\u2019t be any ICMP communication happening.<\/p>\n

Next, we need to specifically allow all the ports required for Garry\u2019s Mod (27005 – 27015 inclusive) with these commands:<\/strong><\/p>\n

iptables -I INPUT -p tcp --dport 27005:27015 -j ACCEPT\r\niptables -I INPUT -p udp --dport 27005:27015 -j ACCEPT\r\n<\/code><\/pre>\n

This says anything on the ports between 27005 and 27015 is allowed. The first command is for TCP, and the second is for UDP. The second command (UDP) is the most important here as almost all communication between the server and the players is done with UDP. Some people have reported problems with TCP blocked, so for that reason we should allow it.<\/p>\n

Now we want to tell the firewall to allow connections which we\u2019ve opened ourself (or the software on the server has). This means if we contact a server, we\u2019ll be able to see a response. Type this command to allow it:<\/p>\n

iptables -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT\r\n<\/code><\/pre>\n

If you will be using SSH to control your server (rather than using the console in your account), this command is required to allow SSH to work on the standard port. If you aren\u2019t using SSH, don\u2019t run this:<\/p>\n

iptables -I INPUT -p tcp --dport 22 -j ACCEPT\r\n<\/code><\/pre>\n

And finally, the last command for setting up the firewall. This command will block all incoming connections besides the ones we\u2019ve allowed:<\/p>\n

iptables -A INPUT -j REJECT\r\n<\/code><\/pre>\n

These settings are only applied until we restart our server, which means we\u2019d have to manually reconfigure it every time the computer reboots. This isn\u2019t acceptable, so there\u2019s a package to install which saves the firewall rules to a file, and then loads it every time the server starts up. To install this package, type the following:<\/p>\n

apt-get install iptables-persistent\r\n<\/code><\/pre>\n

Follow the instructions on screen. When asked if you would like to save the current firewall rules, press yes.<\/p>\n

Now our firewall is set up, and no more configuration should ever be required in regards to the firewall.<\/p>\n

If you are using SSH, there\u2019s a package which you should install which will automatically block people\u2019s connection to the server if they keep trying the wrong SSH password. This is very useful to prevent your SSH password being brute forced\u201d. To install the package, use the following command:<\/p>\n

apt-get install fail2ban\r\n<\/code><\/pre>\n

Fail2ban is already configured to block people\u2019s access after just a few failed password attempts, so we don\u2019t need to configure it. Now your server is significantly more secure than it was when we started.<\/p>\n

Next, we need to install “screen”. This basically allows you to run commands continuously, even if you logout from the server. This is vital to keep your Garry\u2019s Mod server running continuously for long periods of time especially when you are controlling the server with SSH. To install “screen”, type the following:<\/p>\n

apt-get install screen\r\n<\/code><\/pre>\n

After the install is complete, run this command:<\/p>\n

screen\r\n<\/code><\/pre>\n

A disclaimer will show on screen, just press enter to continue. Typing\u00a0screen<\/code>\u00a0into console starts screen and allows you to work inside of a virtual console, if you disconnect from SSH, or logout, this virtual console will continue to run with your command in side of it (Garry\u2019s Mod server runs as a Linux command, so this is where we need to use screen).<\/p>\n

Now, before installing Steam, Garry\u2019s Mod, and the required files, we need an account dedicated to it. I suggest calling it\u00a0steam<\/code>. To make a new account, type the following:<\/p>\n

adduser steam\r\n<\/code><\/pre>\n

You need to use a different password than your root password to keep everything secure. You will very rarely use this password. You will be asked some questions about the account, such as it\u2019s full name, phone number, etc. Leave all of these blank.<\/p>\n

Now we want to be logged into the “steam” account while we download all of the required files. This means that “steam” gets all of the ownership to these files, and the Linux permissions are set correctly without any configuration. It is much more difficult to get the permissions right if you install Steam as root, then attempt to change those permissions. To log in as steam, type the following:<\/p>\n

su steam\r\n<\/code><\/pre>\n

We need a directory (folder) to save the Steam software. To make the directory, use this command:<\/p>\n

mkdir ~\/Steam\r\n<\/code><\/pre>\n

Now, we want to be inside of that directory. To make it your current working directory, type the following:<\/p>\n

cd ~\/Steam\r\n<\/code><\/pre>\n

We now need to download the Steam software by typing:<\/p>\n

wget http:\/\/media.steampowered.com\/client\/steamcmd_linux.tar.gz\r\n<\/code><\/pre>\n

Now we need to decompress and install it, with the following:<\/p>\n

tar -xvzf steamcmd_linux.tar.gz\r\n<\/code><\/pre>\n

If you’re using a 64-bit OS, you’ll need to install 32-bit libraries to run Steam.<\/p>\n

apt-get install lib32stdc++6\r\napt-get install lib32gcc1\r\n<\/code><\/pre>\n

Run the following command to open Steam, tell it to log in as “anonymous” (a Steam account that anyone can use to download free software from their servers), and tell it to install the Garry\u2019s Mod server into the gmodds folder (stored in the Steam account\u2019s home directory).<\/p>\n

.\/steamcmd.sh +login anonymous +force_install_dir ..\/gmodds +app_update 4020 validate +quit\r\n<\/code><\/pre>\n

We can expect that command to last a long time, but we get to watch the progress of it. It is possible for this command to fail, the Steam servers quite often have minor difficulties which cause a download to fail (or not start at all). If this happens, simply start it again.<\/p>\n

Once this command is complete, we will have a working copy of the Garry\u2019s Mod server, however, most Garry\u2019s Mod content requires CounterStrike: Source (CS:S for short) to be installed. To install CS:S, run the following command:<\/p>\n

.\/steamcmd.sh +login anonymous +force_install_dir ..\/cssds +app_update 232330 validate +quit\r\n<\/code><\/pre>\n

This command will also take a while.<\/p>\n

Once Garry\u2019s Mod and CounterStrike are installed, they need to be linked together using a configuration file. To do so, we need to edit the following file with this command:<\/p>\n

nano \/home\/steam\/gmodds\/garrysmod\/cfg\/mount.cfg\r\n<\/code><\/pre>\n

On the line containing “cstrike” we need to remove the two slashes (\/\/) at the start of the line, then replace the entire path part of the line (starts with\u00a0C:\/<\/code>). That part of the line needs to be replaced with:<\/p>\n

\/home\/steam\/cssds\/cstrike\r\n<\/code><\/pre>\n

The entire line should now look like this:<\/p>\n

\"cstrike\"       \"\/home\/steam\/cssds\/cstrike\"\r\n<\/code><\/pre>\n

There should be a tab space at the start before the word cstrike and the line should not contain a double slash (\/\/) anywhere. Once done, you can save this file with Ctrl+X and then Y. This tells Garry\u2019s Mod where to find CounterStrike so it can be used.<\/p>\n

Now we have a basic Garry’s Mod server installed. To run it, ensure we are in the correct directory with this command:<\/p>\n

cd \/home\/steam\/gmodds\/\r\n<\/code><\/pre>\n

Then run the following command:<\/p>\n

.\/srcds_run -game garrysmod +gamemode terrortown +maxplayers 16 +map cs_office\r\n<\/code><\/pre>\n

Once it has started up, you should be able to join by typing the following into the Garry\u2019s Mod Console (NOT the server terminal):<\/p>\n

connect IP_ADDRESS\r\n<\/code><\/pre>\n

Replace\u00a0IP_ADDRESS<\/code>\u00a0with the IP address of the server. If you don\u2019t know your IP address, typing the following into the server terminal will tell you what it is:<\/p>\n

url -s checkip.dyndns.org|sed -e 's\/.*Current IP Address: \/\/' -e 's\/<.*$\/\/'\r\n<\/code><\/pre>\n

If you want to change the number of players allowed on your server, stop the server by doing Ctrl+C and do the start command again, but replace\u00a0maxplayers 16<\/code>with\u00a0maxplayers x<\/code>\u00a0(change\u00a0x<\/code>\u00a0to the number of players you want). To change the default map (the first map that is played), replace\u00a0cs_office<\/code>\u00a0with the name of the map you want. And finally, to change the gamemode, replace\u00a0terrortown<\/code>\u00a0with the gamemode you want. Garry\u2019s Mod only comes with\u00a0terrortown<\/code>\u00a0(Short for Trouble in Terrorist Town) and Sandbox by default.<\/p>\n

To further configure the server, there is a configuration file which can be edited. Each line in this file is called a configuration variable (cVar). Run this command to edit the file:<\/p>\n

nano \/home\/steam\/gmodds\/garrysmod\/cfg\/server.cfg\r\n<\/code><\/pre>\n

The following values can be changed, I’ll explain what each one does shortly:<\/p>\n

hostname \"server name\"\r\nsv_downloadurl \"http:\/\/example.com\/files\/\"\r\nsv_allowupload 1\r\nsv_password \"secret password\"\r\nsv_timeout 60\r\n<\/code><\/pre>\n

Changing the hostname value allows you to change the name of your server. It will be called “Garry’s Mod” unless you change it. For example, this will call your server “My cool server”:<\/p>\n

hostname \"My cool server\"\r\n<\/code><\/pre>\n

You may add as many variables to the file as you like, each new variable needs a new line.<\/p>\n

The\u00a0sv_downloadurl<\/code>\u00a0variable allows you to choose where custom server content is downloaded from. Custom content includes Garry’s mod maps, sounds, addons, and textures. By default, Garry’s Mod will only allow data to be downloaded from your server at an extremely slow rate, which is why we need to provide a URL where the data can be downloaded from at full speed. The URL you provide needs to be a clone of your “garrysmod” folder so all of the files will be available.<\/p>\n

sv_allowupload<\/code>\u00a0can has two choices, 0 or 1, this specifies if you want to allow people to upload content to the server. This is only used for sprays (graphics that the players can spray onto walls) and may cause a security problem. Sprays are often requested, so using “1” will make the players happy, but “0” will keep your server more secure.<\/p>\n

sv password<\/code>\u00a0allows you to choose a password for your server. Whenever someone joins, they will be asked for this password and they can’t join if they don’t have it.<\/p>\n

sv_timeout<\/code>\u00a0is the amount of time in seconds you want the server to wait before kicking someone who has lost their connection. The server will automatically wait for them to get their connection back, but while this is happening the player will appear to be stood still. It’s best to have this at 60 or less seconds. Once you’ve changed these settings, a server restart is required.<\/p>\n

Addons can also be installed to give additional features to the game. Some addons need to be installed in a specific way, so you should always read the instructions on their site, but this is how you would download and install the majority of addons:<\/p>\n

cd \/home\/steam\/gmodds\/garrysmod\/addons\/\r\nwget http:\/\/example.com\/addon.zip\r\nunzip addon.zip\r\n<\/code><\/pre>\n

Replace\u00a0http:\/\/example.com\/addon.zip<\/code>\u00a0with the URL of where the addon is located. You will also need to change\u00a0addon.zip<\/code>\u00a0to the name of the addon’s zip file. Now the addon has been downloaded and unzipped, you may delete the zip file to save space, like so:<\/p>\n

rm addon.zip\r\n<\/code><\/pre>\n

Again, replace\u00a0addon.zip<\/code>\u00a0with the actual name of the zip file.<\/p>\n

If the server is currently running, you need to restart it with Ctrl+C and reissue the start command. You can press the up arrow on your keyboard to automatically insert the last command you ran.<\/p>\n

If you lose your SSH connection, when you reconnect you will need to issue the\u00a0screen -r command<\/code>, which lets you resume from where you last were (the game console).<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"open","ping_status":"closed","template":"","format":"standard","manualknowledgebasecat":[105,242],"manual_kb_tag":[204],"_links":{"self":[{"href":"https:\/\/support.aklwebhost.com\/wp-json\/wp\/v2\/manual_kb\/2298"}],"collection":[{"href":"https:\/\/support.aklwebhost.com\/wp-json\/wp\/v2\/manual_kb"}],"about":[{"href":"https:\/\/support.aklwebhost.com\/wp-json\/wp\/v2\/types\/manual_kb"}],"author":[{"embeddable":true,"href":"https:\/\/support.aklwebhost.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/support.aklwebhost.com\/wp-json\/wp\/v2\/comments?post=2298"}],"version-history":[{"count":1,"href":"https:\/\/support.aklwebhost.com\/wp-json\/wp\/v2\/manual_kb\/2298\/revisions"}],"predecessor-version":[{"id":2299,"href":"https:\/\/support.aklwebhost.com\/wp-json\/wp\/v2\/manual_kb\/2298\/revisions\/2299"}],"wp:attachment":[{"href":"https:\/\/support.aklwebhost.com\/wp-json\/wp\/v2\/media?parent=2298"}],"wp:term":[{"taxonomy":"manualknowledgebasecat","embeddable":true,"href":"https:\/\/support.aklwebhost.com\/wp-json\/wp\/v2\/manualknowledgebasecat?post=2298"},{"taxonomy":"manual_kb_tag","embeddable":true,"href":"https:\/\/support.aklwebhost.com\/wp-json\/wp\/v2\/manual_kb_tag?post=2298"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}