Configure Your Own Internet Router
Expose your Raspberry Pi to the internet — port forwarding, DDNS, SSL with Let's Encrypt, and security best practices.
Expose your Raspberry Pi to the internet — port forwarding, DDNS, SSL with Let's Encrypt, and security best practices.
Connecting all your devices to the Raspberry Pi is very easy, but you want to do it in a specific order so it can recognize all your devices when it boots up.
Connecting to your Wi-Fi network works the same in Raspbian as it does in any modern operating system.
That's it, you're now connected to Wi-Fi. This will work in both the command line and in the graphical interface, so you only need to set it once.
If you have an older Pi and you're using a Wi-Fi adapter like the Edimax EW-7811Un, the process is the same. Modern Raspberry Pi models (3B+, 4B, 5) have built-in Wi-Fi that works out of the box.
Wi-Fi Setup on Raspberry Pi OS: Use raspi-config or edit /etc/wpa_supplicant/wpa_supplicant.conf:
The following section assumes you have an updated and upgraded Raspberry Pi 3 or equivalent, and installed L.A.M.P. (Linux, Apache, MySQL, PHP). Excellent article for getting started and RaspberryPi.org's installing LAMP.
You have several devices connected to your WiFi router — how can you tell the outside world where to find your Raspberry Pi?
You will need to login to your router's configuration tool. Most home networks use one of these common IP addresses for their gateway:
Run this command on your Pi to find your gateway:
The router IP is the address after via (e.g., 192.168.1.1).
First, reserve an IP address for your Pi in your router's DHCP settings.
Typically, the router will have a DHCP (Dynamic Host Configuration Protocol) Settings section. The Raspberry Pi and all other devices on your LAN should be listed. Your router should have a somewhat intuitive interface that will make sense as to how to assign an IP address to a device by MAC address. If all else fails, consult your manufacturer's instructions.
The default port for web requests is 80. You can leave the default unless your Internet Service Provider doesn't allow port 80.
The default port for SSL is port 443. Next step in your router's configuration is to have the router forward all incoming requests on port 443 to the Raspberry Pi.
Motion Web-Cam Streaming: The default port for motion is port 8081. Next step in your router's configuration is to have the router forward all incoming requests on port 8081 to the Raspberry Pi.
You could allow Telnet, FTP, SSH, VNC, etc., but I do not recommend these unless you are familiar with the security risks associated with such services.
Instead of port forwarding (which exposes your Pi directly to the internet), consider:
Check for the DDNS (Dynamic Domain Name Service) Setting in your Router's advanced configuration settings. Most routers will support one or more of the following:
The service will offer the ability to register a domain name to associate with the Dynamic IP address that is assigned to you by your Internet Service Provider. Typically, your router or a software plugin will update the Dynamic DNS service's database when your assigned IP address changes.
Let's Encrypt our connection with the Raspberry Pi.
Your domain name for your project should now be secure.
Modern certbot is available directly via apt:
Certbot will automatically configure Apache for SSL and set up automatic renewal.
Your answers shape what we write next.
Questions, experiences, or ideas — we're listening.