Linux · Router · Networking

Configure Your Own Internet Router

Expose your Raspberry Pi to the internet — port forwarding, DDNS, SSL with Let's Encrypt, and security best practices.

📅 January 2, 2024 ⏱ 40 min 📊 Advanced 🔄 Updated April 2026

Hook Up Your Raspberry Pi

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.

  1. Connect your HDMI cable to your Raspberry Pi and your monitor.
  2. Connect your USB devices.
  3. If you're using an Ethernet cable to connect to your router, go ahead and connect that as well.
  4. Finally, once everything is connected, go ahead and plug in your power adapter. The Raspberry Pi does not have a power switch, so once you connect the power adapter, it'll turn on all by itself.

Connect to Your Wi-Fi Network

Connecting to your Wi-Fi network works the same in Raspbian as it does in any modern operating system.

  1. Click the network icon (it's the one with two computers) in the top right corner.
  2. Select your Wi-Fi network name, and enter your password.

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.

★ 2026 Update

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:

sudo raspi-config
# Or add manually:
sudo nano /etc/wpa_supplicant/wpa_supplicant.conf

Getting Online

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.

Raspberry Pi network diagram

You have several devices connected to your WiFi router — how can you tell the outside world where to find your Raspberry Pi?

Terminal
# Update and upgrade first
sudo apt update && sudo apt upgrade -y
# Install LAMP stack
sudo apt install apache2 mariadb-server php php-gd -y

Reserve an IP Address

You will need to login to your router's configuration tool. Most home networks use one of these common IP addresses for their gateway:

★ Finding Your Router IP

Run this command on your Pi to find your gateway:

ip route | grep default
default via 192.168.1.1 dev wlan0 proto dhcp src 192.168.1.102

The router IP is the address after via (e.g., 192.168.1.1).

Network diagram

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.

Port Forwarding

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.

⚠️ Security Warning

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.

★ 2024 Recommendation — Zero-Config Alternatives

Instead of port forwarding (which exposes your Pi directly to the internet), consider:

Get Yourself A Domain Name

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.

Terminal
# Option 1: noip2 (classic, requires manual config)
sudo apt install noip2
sudo noip2 -C
# Option 2: ddclient (modern, supports many providers)
sudo apt install ddclient
# Configure at /etc/ddclient.conf
sudo systemctl enable ddclient && sudo systemctl start ddclient

Secure Socket Layer (SSL/TLS)

★ Let's Encrypt for Free SSL

https://letsencrypt.org/

Let's Encrypt our connection with the Raspberry Pi.

Install Certbot

Terminal
# Rather than apt-get certbot, download the latest version directly
sudo git clone https://github.com/certbot/certbot /etc/letsencrypt

Easy SSL through Automation

Terminal
sudo /etc/letsencrypt/certbot-auto

Your domain name for your project should now be secure.

★ 2024 Update

Modern certbot is available directly via apt:

sudo apt install certbot python3-certbot-apache
sudo certbot --apache -d yourdomain.com

Certbot will automatically configure Apache for SSL and set up automatic renewal.

← Back to Guides

Did this guide help?

Your answers shape what we write next.

Join the conversation.

Questions, experiences, or ideas — we're listening.