Site icon AranaCorp

Configuring port forwarding

When you want to connect to a device outside your Wifi network, you need to set up port forwarding. Once your Raspberry Pi or ESP is connected to your Internet router, you can access it from anywhere by configuring port forwarding.

N.B: For cybersecurity reasons, it can be very dangerous to set up a port forwarding without taking care. For this reason, you should only set up a redirection if you’re sure of what you’re doing, and you should put in place the necessary safeguards (password, etc.).

Principle

On the same network, devices will communicate with their local addresses (e.g. 192.168.x.xxx). Only the router has a public address. When we configure port forwarding, we ask the router to open a public port and link it to a local address.

Ex:

So if we redirect port 600 to the device’s IP address, we’ll be able to access the device by typing 82.95.256.144:600.

This procedure can be very useful for developing advanced home automation or IoT functions requiring remote access on Raspberry Pi, ESP8266, EP32 or any other device with an Internet connection.

Find your router’s IP address

ip route
ipconfig

These commands give, among other things, the local IP address of your router (here 192.168.1.254).

You can use the netstat -a command to get a list of connections to the device and the ports used.

Configure port forwarding

In your browser, you can enter the IP address to access the router’s home page. You will be asked for your login details.

N.B: The port forwarding procedure differs from one box to another. If you search for “box-name Port Forwarding” on the Internet, you should come across the procedure to follow.

Luego busca la opción “Redirección de Puertos” o NAT/PAT. En un bbox, Servicios de la Box > Redirección de Puerto> Configuración.

Click on “Add a rule” and enter the redirection information

From the previous example:

N.B: The external port can take a value between 0 and 65535. Port numbers below 1024 or above 49150 are reserved for the system.

Applications

Sources

Exit mobile version