How to run a Garry’s Mod server using port forwarding

Let’s say that you want to play Garry’s Mod (GMod) with your friends across the internet. So you create a map and tell your friends what it is called and they search for you in the list of multiplayer servers and they never find you!

Maybe you google it and find some help that says your friend needs to type in “connect <your IP address>” and they do that but it never connects.

Sad face.

OK, so what gives? Why doesn’t GMod allow you to set up a server and play with your friends like every other game does?

I dunno, can’t help you there. But I can help you allow your friends to connect.

There are two main ways to do it.

1. Set up a Virtual Private Network (VPN) like Hamachi.

This works really well and a lot of people do this. What this means is that you effectively extend your local area network (LAN) across the internet in a private space that your friends can connect in to.

Downsides of this: it is slower, as the network traffic has to navigate through the VPN as well. Also it costs, or in the case of Hamachi you can have 5 or so people* connecting for free – this includes you and anyone else on your local network, as well as your friends across the internet.

* This may have changed since I last checked it.

2. Port forward the GMod ports.

This means that you open up a few ports through your router’s firewall so that anyone on the internet can connect to your computer that is running GMod.

This isn’t as scary as it seems.

The ports are used only by Garry’s Mod, so they don’t allow other programs (eg. viruses) to get in to your computer. And depending on your router you may be able to limit the connections to being only open to specific computers, not open to anyone.

This document details how to set up port forwarding for Garry’s Mod.

Set up Port Forwarding

From your router’s control panel forward a port to the internal IP address of the computer that will be running GMod.

First you will need to get your internal IP address. To get your internal IP address the instructions for Windows are below. If you are running a different platform then sorry I dunno how – Mr Google is your friend!

  • Hold down the Windows key and press the letter R
  • Type in cmd and click OK.
  • In the window that pops up type: ipconfig and press the Enter key.
  • In the information that is displayed search for the line starting with IPv4 Address.
  • Your internal IP address is the string of four number separated by full stops, typically starting with either 192.168… or 10.0….

Now you need to forward port 27015 for both TCP and UDP to that IP address.

Port forwarding is set up on your router. Each router has slightly different ways to set this up, so rather than going into detail here the best way is to follow the instructions here:

Set up the game

Run GMod on the PC. The only setting to alter is how many people to allow into the game.

If you have a lot of add-ons then this might make it difficult for people to join, because they will need to download all of the mods.

Once the map has loaded press the tilde key (~) (usually next to the number 1 key) to open the console and type sv_lan 0 and click on Submit.

Let other people join

Google search: “What is my ip”

Google will tell you what your external IP address is. This might change from one day to the next depending on your ISP.

Other computers on your home network should be able to join as normal.

To enable people across the internet to find your game:

From the main menu in GMod each person should press the tilde (~) key to bring up the console, and then type connect <IP address from your google search above> and click on Submit.

For example, if your Google search told you that your IP address is then they would type in connect and then click on Submit.

Managing unwanted players

Your server will show up in the list if anyone else somewhere in the world clicks on the Join a Multiplayer Game option from the main menu. Because you can only select the number of players as 2, 4, 8, 16, etc, you might have a some spare capacity if you don’t have exact that number of people playing in your group of friends. This means that occasionally you may get a random stranger joining.

To kick them open the console (~), type status and click Submit. This will bring up a list of players. Then type either
kick <name>
kickid <userid>

(The userid includes all of the text in that column starting with “steam:…”.)

Be careful if you are typing in the name and they have included an asterisk (*) in their name, because this works as a wildcard to match all names. For example, if their name is “a*” and you type kick a* then you will kick ALL players whose names start with “a”.

Another way to exclude unwanted players

Another little trick I have used if you only want one other person to joining from the internet, is to limit the port forwarding for just that person’s IP address. For this you will need to get them to find out their external IP address (Google search: “What is my ip”) and enter that into the port forwarding settings on your router’s control panel.