Port Forwarding: Why And How

Discussion in 'Guides' started by Rydian, Jul 19, 2011.

  1. Rydian Floaty Gross

    1. What is "port forwarding", and why do many of us need to do it?
      Show Spoiler
      • Let's say that the following diagram shows your house (with three computers in it), the internet, and a few random computers on the internet.

        [IMG]


      • Now, let's say that your computer wants to connect to a web server to view a web page. First it tries to establish a connection with the web server on the internet. Your PC sends data through the router, out onto the internet and to the target machine.

        [IMG]


      • The connection is established, and now data can flow both ways across the connection. Since your computer initiated the connection, the router knows that the data should be flowing to YOUR computer, not anything else.

        [IMG]


      • What if something out on the internet attempts to connect to you? The connection attempt gets to your router... and your router has no clue which machine to send it to.

        [IMG]


      • Since the connection cannot be established, none of the players can connect to your server!

        [IMG]


      • However if port forwarding is set up properly, then the router can make decisions on data flow depending on the port number. If a player tries to connect to your server on port 7777 (the default terraria port) for example, then your router has been told that incoming connections on port 7777 should be sent to a specific machine.

        [IMG]


      • Since the router forwarded the connection attempt to the right machine, a connection was established, and the random terraria player online can now connect to your server.

        [IMG]


    2. What information do I need in order to port forward?
      Show Spoiler
      You need your router information, the port that will be used, and both of your IP addresses (internal and external).

      • Router Information
        Find your router and look at it to get it's make and model information. The "router" is the little box thing that gives off the wireless signal in your house (if you have wireless), and/or the box thing that a desktop may be hooked into.

        The "make" is the company that made it, such as Linksys, Buffalo, Zyxel, or whatever (this is often the "brand" name), this is often displayed on the top or front or something.

        The model is which specific router of theirs it is. This information is sometimes on the underside, and is often in the form of a few letters followed by a few numbers (such as WRT54G). This is NOT the "serial number" or "S/N".

      • Port Number
        The default port for terraria is currently 7777. If you're using a different port for some reason, be sure to forward that port instead of 7777.

      • Internal IP Address
        This is your computer's IP address according to your router. This is how the router refers to your computers, so when you're telling the router which PC to forward to, you need to make sure to give it this IP address.

        In your start/globe menu, go to the "run" command. If you're on vista/7, you'd use the little white box near the bottom. Type in "CMD" and press ENTER. In the black box that comes up, type "ipconfig" and press enter. It'll list a series of four numbers as your "IP address" or "IPv4 address". Write those down. The numbers should be in the form of 192.168.x.x, or rarely 10.x.x.x or even more rarely 172.16.x.x - 172.32.x.x.

        Look at this example.

        [IMG]

        As you can see my local/internal IP address is 192.168.2.2, meaning if I tell my router to port forward, I need to give it that IP. Do NOT confuse this with "default gateway"!

      • External IP Address
        This is your IP address as the internet sees it (well to be technical it's the IP address of your router). The quickest way to find this is to visit a site such as http://whatismyip.org/ and seeing what IP address it reports.

        For some people this may rarely change, and for other people it may change a lot, so if people can connect one day but not another, go see if your external IP address changed so you can give people the new one.


    3. Now that I have that information, how do I do it?
      Show Spoiler
      1. In your start/globe menu, go to the "run" command. If you're on vista/7, you'd use the little white box near the bottom. Type in "CMD" and press ENTER.

      2. In the black box that comes up, type "ipconfig" and press enter. It'll list a series of four numbers as your "default gateway" (do NOT confuse this with the "IP address").

        [IMG]

        Write those down. Go open any web browser, and enter the four numbers into the address bar, and press enter.

      3. A login box should come up. The username could be "admin" or blank, and the password can be anything from "admin" to "administrator" "pass" to "password" or "password1", or something else if you've set it differently. Ask whoever set up the router what the password to get into it is, or check this page. http://www.phenoelit-us.org/dpl/dpl.html

      4. You'll need to find the port forwarding section of your router's control panel. Different routers have completely different control panels, and there's so many routers out there that it's way beyond my capability to list exact instructions for every single one, so you're going to have to do a little searching yourself to find the port forwarding section. Key words to look for are "port forwarding", "NAT", "firewall", "network address translation" "local network", and stuff like that. If you're lost, you can try googling for a port forwarding guide for your router, that should show you where the right section is.

      5. When you find the port forwarding section, it might offer to automatically set it up for some specific services (such as WWW/HTTP , FTP, POP3, stuff like that). if it does that, there will often be some sort of "custom" or "user-defined" option, you'll need to choose that.

        If it asks you about TCP and UDP, you want TCP (which is the connection type Terraria uses).

        When you go to tell the router to add a new port forwarding rule, you'll need to give the router both the port number to forward (7777 is terraria's default), and the local/internal IP address to forward it to. If it asks for a "start" and "end" port, just set both of them to whatever port you're using.

        It may look something like this.
        [IMG]

      6. Save the changes, give the router a minute or two to update itself, and then start your server and let people connect and play!


    4. The port forwarding appears to break every few days!
      My internal IP changes a lot, how do I stop that?

      Show Spoiler
      This is going to require some explanation because it's important that you understand what you're doing. If you set this up incorrectly it's likely that you'll start kicking other machines in your house off of the internet.

      As you learned earlier in the guide, the router (or "gateway") controls the connections in your house. In order to do this, it automatically assigns internal/private IP addresses to devices as they connect. This setup is called "DHCP". IP addresses given automatically don't last forever though, they're generally on a lease. The lease time is generally 24 hours (this can be changed), so if a machine is disconnected (shut down, moved out of range of the network, etc) when the lease time expires, then the IP it was using is freed. Let's use an example to explain it...


      • Let's say you're hosting Terraria from your laptop at home, with a local/private IP of 192.168.1.5, and you have port 7777 (for Terraria) forwarded to 192.168.1.5. Well, that normally works fine.
        [IMG]

      • Let's say one day you shut down the laptop and take it to school, and while you're at school with it (so it's not connected to your home network) the IP 192.168.1.5 at your home becomes free, it's not being used.
        [IMG]

      • Then your mom comes home before you, with her laptop. If she turns it on and connects to the internet, the router/gateway automatically gives her an IP address... and 192.168.1.5 is free at that time, so she may get it.
        [IMG]

      • If you then come home later and turn your laptop on, you'd likely be given 192.168.1.6, since .5 has already been given!
        [IMG]

        So since your port forwarding points to .5, it's now pointing to your mom's laptop instead of yours, and your server doesn't work anymore because the ports aren't forwarded properly.

      So how do we prevent that? It's actually rather simple. Instead of letting your computer be given any old IP address from your router/gateway, you should have it request a specific address that other machines won't use, so this situation doesn't happen. There's two steps to that.

      1. Find out what the DHCP range of addresses is, and how many are being used normally.
        Remember, you need to be requesting an IP that's not being used by other machines! So you should find out the "DHCP pool", which is the "pool" or "group" of addresses that the router/gateway will give out via DHCP.first, so you know which addresses are actually valid. After that, find which addresses are used so you know which ones to NOT set.

        1. Finding the DHCP Pool.
          Log into your router's settings (like you've done before), and look around the local/LAN section for some sort of DHCP or IP settings. It may look something like this.
          [IMG]
          In this example the IPs start at .2 and there's 32 of them... so 192.168.2.2 though 192.168.2.33 will be given out by the router automatically.

          In other cases the router/gateway will just plainly show you the start and end address.

        2. Finding out how many addresses are used.
          Well now that we know how many can be given out, let's figure out how many are being used often. There's two ways to do this, a technical and a "duh" way. Let's do the technical way first...
          • Technical Way
            In your router/gateway's settings there is likely to be some spot to pull up the "DHCP Client List". This shows you a list of the machines currently connected to your router/gateway that are getting automatic/DHCP addresses, and what those addresses are.
            [IMG]
            In this example we can see two devices, using the .2 and .3 addresses.

          • "Duh" Way
            Simply count how many computers and devices in your home use your wired/wireless internet. :p This is actually often more reliable since you don't always have every single device connected at once.

      2. Choose and set your static IP.
        Well now that you know the range of DHCP addresses, it's time to decide which one to use for your computer that'll be hosting Terraria. While in many cases you can simply choose one that's higher than the DHCP range and it'll work just fine, in some cases that may not be allowed, so you should pick one that's near the upper end of the address "pool" to be safe.

        So for example if 192.168.2.2 though 192.168.2.33 are being given out via DHCP, go ahead and use 192.168.2.32 or 192.168.2.33.

        As for the actual process of setting a static IP on your machine, it varies depending on your OS, but generally it involves changing the settings for your local/internet connection on the computer. Detailed information on setting it for the various OS's out there would take up way too much room, so simply use this link.

        Windows XP/Vista/7: http://www.howtogeek.com/howto/19249/how-to-assign-a-static-ip-address-in-xp-vista-or-windows-7/


    5. My external IP changes a lot, is there anything I can do?
      Show Spoiler
      Outside of paying your ISP for a static IP address, there's nothing you can do to stop it from changing if you happen to have a situation where your ISP changes your IP address often (sometimes daily).

      However there is a way to work around it so that your external IP changing won't cause an issue for hosting terraria! What you'll want to do is set up a DynDNS account, and then install a program to your computer that automatically keeps track of your external IP and updates the record as needed, so you can tell people to join something like "rydian-terraria.dyndns.org", and that name will always translate into your current IP address (you may see some servers already doing something like this).

      Two free services for this are FreeDNS, and No-IP
      http://freedns.afraid.org
      http://www.no-ip.com/

      For both of the services, you can sign up for the site, and add a free subdomain. If you're asked, the type of record is "A".

      Then after setting up the domain, you download a "Dynamic DNS Client", or whatever client the service suggests. Once this program is installed on your computer and you've put in the proper login/address info, it should keep your server's address updated with your current IP address automatically.


    6. F.A.Q.
      Show Spoiler
      • I did all this but it still doesn't work.
        Go to http://canyouseeme.org/ and enter the port number you're using for terraria, see what it says. There may be some firewall on your computer (perhaps built into your antivirus) that's stopping people from connecting, this is very common because the point of a firewall is to deny hosting from the inside so with most firewall software (or anti-virus programs that include a firewall) you will need to disable it or add Terraria to the whitelist before you can host.

      • I've added Terraria to my firewall before, but it stopped working after an update.
        When terraria update, it changes, so on technical terms it's not the exact same program it was before, so you may need to re-add it to your firewall's whitelist after it updates.

      • I don't need to port forward to host, why is that?
        Either you're not using any sort of router or firewall, or the router has already been set up by somebody else to forward all ports to the specific machine you're using. Terraria can also try to automatically port-forward using uPnP (since version 1.2), but seeing as this needs to be supported and turned on by the network interface, OS, router, and not be blocked by firewall software, the success rate isn't very high.

      • I'm stuck on part (x)!
        Post whatever information you have (especially your router make and model) in the help section and see if somebody can help you.

      • I'm on dialup and my hosting sucks, why?
        You're on dialup. No way around it.

      • I'm on satellite and my hosting sucks, why?
        Satellite has two forms. One uses a dialup modem for upload (in which case you're in the same boat as dialup users as far as hosting goes), and the other uses the satellites for upload as well as download... the issue being that satellite has a very high latency associated with it, so any sort of online gaming is subject to terrible lag in either case.

      • I'm on 3G/4G and my hosting sucks, why?
        Cellular internet tends to have worse latency than home broadband, and while not nearly as bad as satellite it's still often enough to ruin online gaming. If you're tethering through your phone, try getting a 3G dongle for your PC from your provider so you don't need to do that anymore, as your phone may be the bottleneck.

      • Hey, you added a section on static IPs even though you were initially against it, why?
        I underestimated the number of people who try to run "dedicated servers" on machines that aren't even physically turned on 24/7. :p

      • What about hamachi?
        You'll find many people are not willing to (or allowed to as it needs admin rights) install hamachi just to play on your server. If you port forward properly then anybody on the internet should be able to play on your server.

      • All of the "port check" websites online report the port as closed even though I opened it!
        You need to have the server running when you check. If there's no program listening on the port at the time of the check, the check will fail.


    7. Changelog
      11/30/2013 - Updated the FAQ a bit to account for uPnP.
      6/13/2012 - Added the info about having the server up during a port test to the FAQ.
      1/25/2012 - Edited the FAQ to add the firewall issue in more detail and make it stand out.
      1/10/2012 - Removed dyndns info as they stopped the service, stuck in some simple placeholders since the two suggestions are sort of varied.
      12/26/2011 - Fixed a typo in the date of the changelog. XD
      12/25/2011 - Added the section on setting a static IP, changed the FAQ to account for it (and changed the wording of another question or two to be less awkward).
      7/31/2011 - Added no-ip as an alternative to the DNS thing.
      7/26/2011 - Fixed typo pointed out by Glaydur.
      7/21/2011 - Added info on using the automatic DynDNS updater, added changelog.
      7/20/2011 - Added info on TCP/UDP.
    jce123, MehPotato, dokydom and 58 others like this.
  2. Tobe Green Slime

    Amazing guide; highly detailed. This will certainly help with a lot of people who are trying out hosting and are often confused/make mistakes on port forwarding. I'll certainly reference this if people happen ask about port forwarding (they often do).
  3. Saber Hell Bat

    I'm on telus, when i go to my firewall section there's a portforward section, once i click on that i see:

    Port Forwarding

    Enter ports or port ranges required to forward Internet applications to a LAN device below.
    1. Set the LAN port and IP information.

    Starting Port:
    Ending Port:
    Protocol: TCP UDP GRE
    LAN IP Address:

    2. Set the remote port and IP information. (Optional)

    Starting Port:
    Ending Port:
    Set Remote IP Address: (0.0.0.0 will use any IP Address)

    3. Click "Apply" to save your settings.

    Im not sure what to do

    EDIT: theres also an application section but i cant find terraria.

    Applications

    Applications forwards ports to the selected LAN device by application name.
    1. Select Device.

    Select Device:
    Manually Enter IP Address 192.168.1.64SaberSaberPCSaber-PCVaio-Laptopkazim-HP Enter IP Address:

    2. Select the application category, then the application to forward.

    Application Category: All GamesGame ConsolesVPNAudio/VideoAppsServersUser Created Rules
    Applications: Alien vs PredatorAsheron's CallDark Rein 2Delta ForceDoomDune 2000DirectX 7~8 GamesEliteForceEverQuestFighter Ace IIHalf LifeHeretic IIHexen IIKaliMotorheadMSN Gaming ZoneMyth: The Fallen LordsNeed for Speed PorcheNeed for Speed 3OutlowsRainbow 6Rogue SpearStarcraftTiberian SunUltimaUnreal TournmentQuake 3 ServerQuake 2 ServerUnreal ServerPS2 PS3 WiiXBoxIPSEC L2TPPPTPDirecTV ReceiverNet2PhoneNetmeetingQuick Time 4 ServerVoiceWingVNCWin2k TerminalPcAnywhereNetbiosRemoteAnythingRadminLapLinkCarbonCopyGnutellaWeb ServerFTP ServerTELNET ServerDNS ServerLDAP ServerNNTP ServerSMTP ServerPOP 2 ServerPOP 3 ServerIMAP ServerIRC ServerLotus ServerRemotely Possible Server

    3. Click "Apply" to save changes.

    Also, when checking Canyouseeme.com the error it gives me is connection refused.
  4. Rydian Floaty Gross

    That should be all the info that's needed.

    I forgot to mention that some routers make a distinction between TCP and UDP connections so I'll add a note that it should be for TCP...
  5. Ethan Green Slime

    This is a really good guide, it explained a lot.
  6. Rydian Floaty Gross

    D'aww, thanks.

    I added a section on using the DynDNS updater so people can have those fancy subdomains to point to instead of an IP. Does anybody else know any free services with an updater like DynDNS? IIRC there's one or two more.
  7. mapledragon89 Green Slime

    well ive done the basic port fowarding..several times now.im sure ive allowed terraria through my firewall. when i use canyouseeme.org it says the problem is conncection timed out -.-
  8. Rydian Floaty Gross

    What router model?
    What's your external IP?
    What's the internal one you set to be forwarded to?
    Screenshot the forwarding section?
    What firewall?
  9. ForeverCopper Cursed Skull

    Very nice guide! Great diagrams.
  10. Dantheman737 Green Slime

    Thank you this is by far the best guide I've seen, actually it's the only good guide I've seen and I've looked at them all on the TO forums- videos are always blurry and make no sense bcuz people don't talk and do it too fast, and the worded guides have no detail what so ever and don't explain enough. Thank you and it worked I <3 you so much right now.:D
  11. Glaydur Fire Imp

    THANK YOU!! I really hope you find more free services like this. :)

    FOUND A TYPO:
    Do NOTE should be DO NOT

  12. Ashleigh Green Slime

    Nice guide indeed!

    My default gateway, if you will, is 192.168.1.1 - and I know for a fact the login information hasn't been changed, so it should be admin/admin. However, whenever I type a password in the dialogue box after entering the gateway into my address bar, it will begin abbreviating whatever I'm writing. For example, I'll write "admin" which has five characters, but while I'm typing it'll show about 8 or so and then suddenly flash to four characters. At first I thought this was just a security measure for password protection, but I can't log into this at all. It won't tell me wrong password or anything of the sort, it simply just refreshes the page. I've tried several browsers and pc's in the house and it still gives me the same problem. As someone who's irritated not being able to create my own servers, I'd really appreciate the insight. Thanks!
  13. Rydian Floaty Gross

    D'awww, thanks guys. Fixed that typo.

    At that point it sounds like somebody did change the login info. If you're comfortable with changing it's settings you can reset it so it'll use the default login info (but you'll need to set up the router from scratch again).
  14. Ashleigh Green Slime

    Weird, I don't see how that's possible.. gotta ask my boyfriend if he tinkered with it. Thank you very much.
  15. Ashleigh Green Slime

    Update: Sorry for double, just kinda desperate.
    I turned off javascript on my browser and the character-thing stopped happening - however no user/pass combinations are working. No one in the house has tinkered with it.. is reset imminent? I'm lazy (since it goes to factory reset, right? Which would mean setting every pc up again..)
  16. Rydian Floaty Gross

    I'm not aware of a way to get the login info, and if it's not accepting what you know then it's been changed.

    Yes, factory-reset (via the reset button). If you make the wireless SSID and key info the same then the other computers won't need to enter new info to connect.
  17. Ashleigh Green Slime

    I should be good then.. thank you very much. I'll stop spamming your thread. :oops:
  18. Rydian Floaty Gross

    No worries, this thread was made to be helpful, I just recommended the help section in the guide since I won't always be here.
    Xes0h123 likes this.
  19. WarDriver Green Slime

    Although it is highly NOT RECOMMENDED for security reasons one can always set a DMZ to the host IP address as a quick and easy way to forward ALL PORTS to that IP address here is a checklist of things that you must do before creating a dmz rule:

    1. you should have a dynamic WAN IP address, why? it helps to stop people from probing your computer for open ports since they may now your external IP address only until you reset your modem or you get a new lease from the dhcp server you are connected on.

    2. you must have a firewall installed in your computer (many internet security anti-viruses offer those e.g:kaspersky) it doesn't keep everything out but it helps, and also don't forget to add terraria to the trusted app list there too since it WILL LAG your server because it keeps scanning the network traffic that terraria is generating.

    keep in mind that this constitutes a security flaw on your network, therefore you should only do it if you understand the risks that it involves, it is still the quickest way to port forwarding IMHO.

    I only use it for limited periods of time, and if you wish to leave it enabled forever and beyond do so at your own risk.
  20. Glaydur Fire Imp

    what is a DMZ?

Share This Page