Freedom, Community & Sustainability

5 - Configure your router to access your server from the Internet

October 28, 2014 -- William
Last modified on August 2016
Duration: +- 15 minutes

This is a tricky part of this tutorial because it involves a lot of exploration and uncertainty. Every network and every router is different and I can't provide instructions for all of them. This page will give you the general concepts that will help you to find what we are looking for in your particular network.

Why do we need to configure the router?

Until now we were accessing our server inside the local network, the network that your router creates for you in your home. The router receives information from the local network and from the Internet and it routes, or forwards, the information to the appropriate machine. We want to tell the router to send all incoming requests to the server, so that the server can then respond and send the information back to the Internet.

How to configure the router?

1 - Accessing your router configuration

First of all you need to find the IP of your router in order to access it's settings page. Sometimes the router has a default IP and password that are written on it. You can take a look at it and try to find a sticker that states what's the router IP and eventually the username and password.

If there is no information written on the router we will chase this information manually. On the server you can type on a terminal "ifconfig" and note the "inet addr", this is the IP of your server.  Usually, the router will receive the first IP of the network, so if your server address is, your router is probably Try to access your router typing the address on a browser (inside your local network!). You can also try the command "route" and note the "Default Gateway" as this is probably the address of your router.

If the above doesn't work we will try one last thing. We will map the network and get information from all devices connected to the local network. To do this we will install on the server a program called nmap and launch it (replace the address below with the address you found under "inet addr" but replace the last digit with 0/24, this is the same as saying "all addresses on the network"):

apt-get install nmap

You will see a list of all devices found locally, their local IP address and hopefully also a short description. Try to find in this list your router and type the IP address in a browser to access the router configurations.

2 - Check the configuration of your firewall and find open ports

Ideally we want to use the default ports 80 (http), 443 (https), 20-21 (FTP), 22 (SSH, SFTP), 25-57-143-587 (mail). We'll start by checking if these ports are open. If you haven't installed nmap on the previous step, do it now and map the ports of your router (replace [] with the IP of your router):

apt-get install nmap
nmap []

You will see the list of open ports. If the ports above are open, you're good! If not you can either change the configurations of your firewall to open the given ports or use non-standard ports like 8080 for http, 8081 for https... Sometimes ISPs block some of the standard ports and you are forced to use non-standard ports to communicate with your server.

To tell your server to use non standard ports you need to configure Apache and modify the ports Apache will listen to. Then you can access your server through a browser specifying both the IP and the port:

3 - Find and set the port forwarding configuration

You need to find the configuration for "port forwarding" and forward all (external) incoming traffic to the internal IP address of your server. Sometimes this setting is located under some unintuitive menu like "Application and gaming". Then just specify the port that should be forwarded and the internal IP of your server in order to send all traffic from this port to your machine.

As I write this tutorial I know that the instructions are very generic but, really, I can't do much more than giving you the information that I hope will guide you in many different setups. Try to go as far as you can, and if you're stuck, ask for help! There are plenty of resources online that can help with your specific hardware and situation.

Congratulations for getting to the end of the tutorial!!! I hope it has been a fun experience and that you have learned something!!! Even if you didn't get it all right this time, I'm sure you'll get better at doing this with a bit of experience! Please let me know if there are parts that were not clear or accurate and I'll do my best to improve it. Thank you for following this tutorial!

Add new comment