20) Connecting your Raspberry Pi to a Router and a Domain

<-- Previous    Next –>

At the moment when you enter http://hostname into your browser, you should see your default Apache web page. This page is only accessible from within your local network. We now want to access the web site from outside the home network in the same way as any other web site.

You will need access to your router and the procedure will vary depending on the router so you may have to find its documentation.

One method is to set up port forwarding on your router. To do this, you must change the configuration of your router to forward all inbound traffic from the internet on a specific port to the local IP address of your Raspberry Pi. Most routers have this feature available. However, every router is different so you will need to consult your router’s user manual for instructions.

The settings can be tricky if your Pi is behind a firewall or if there is more than one router. One disadvantage of port forwarding is that it exposes a network port on your private LAN to the public internet. This is a known security vulnerability and must be managed carefully by using firewall on the Raspberry Pi and other security measures such as installing fail2ban.

(1) Log into your router and find the area on Firewall / Port Forwarding section.

(2) Add port forwarding on inbound and outbound traffic for port 80 and port 443 to the list. You will need the Raspberry Pi local IP address which you have probably set to static.

(3) Find your current IP address by browsing on the internet and searching for a web site that is able to display your IP address. This might be for example,

(4) Once set up, browse on the internet to display your Raspberry Pi web server home page. Make sure that you have installed a firewall on your Pi.

<-- Previous    Next –>