Site icon JnPnote

How to Setup Port Forward for local Raspberry Pi Server

I have Raspberry Pi 2 from my friend, and set it up already. I haven’t write post for setting up the RPi, but there are tons of tutorials. You can refer to them to setup the RPi.

My friend helped me setup all the port forward configurations before. Recently, I changed my internet service, and all the IP address and the port forward needs to be reconfigured. So, I am writing this post for myself to remember for the future.

For all the detail explanations, you can find them from reference site below.

Reference: How Do I Set a Static IP Address on Raspberry Pi?

1. Prerequisites

2. Configure Router Port Forward

To configure your router, you need mac address of rpi and ip address for rpi.

For the mac address of rpi, you can check with ifconfig command on your rpi. It is ether

For the ip address for rpi, you can choose whatever you want other than the ip addresses already in use. starting with 192.168 and 0 or 1 depends on your router and from 0 or whatever your router start ip address setup to End. In my case, the router setup as 192.168.1.1 and start and end IP address is 33 and 254. And from 34 to 45 were used mostly, so I choose 50 for my rpi.

Now, you need to work on port forwarding.

3. Configure your RPi DHCP

Let’s see what’s your current setting. Run the below command.

sudo nano /etc/resolv.conf

As you can see above, mine was setup with 192.168.0.1, but my router is setup as 192.168.1.1. So, I need to change that. and the below two lines are the DNS of my desktop. (Honestly, I don’t know why, and some of tutorials did not have them.) I will just leave them as it is. Just in case, you can find your mac address of your Windows computer, Settings -> Network & Internet -> Ethernet -> click the connection (Ethernet in my case) -> scroll down to the properties -> IPv6 DNS servers.

4. Setup Static IP Address

Now, you need to setup or change your IP Address setting on your RPi. Run the command below to open up the ip address setting.

sudo nano /etc/dhcpcd.conf

Scroll down to the bottom in case it has a lot of descriptions with comments. You will be able to see like below screenshot.

As you can see, it is also setup with 0 and the static ip address is setup as 0.5.

So, I need to change that as below. 1.1 and 1.50 as I setup above.

5. Reboot RPi and Test

Reboot your RPi with sudo reboot command.

When it is rebooted, you can check the rpi ip address with hostname -I or ifconfig.

Or you can enter the RPi ip address on your local computer browser.

Exit mobile version