OpenWRT in Raspberry Pi 4B: A Comprehensive Guide

Author

Reads 294

Green Computer Circuit Board
Credit: pexels.com, Green Computer Circuit Board

OpenWRT is a popular Linux distribution that can be installed on the Raspberry Pi 4B, turning it into a powerful network device.

One of the main advantages of OpenWRT on the Raspberry Pi 4B is its ability to handle a wide range of network protocols and provide a high level of customization.

The Raspberry Pi 4B's quad-core CPU and 4GB of RAM make it an ideal platform for running OpenWRT, allowing for fast and efficient network performance.

With OpenWRT, you can configure your Raspberry Pi 4B as a wireless access point, router, or even a network switch, giving you a high level of flexibility and control over your network setup.

Take a look at this: Android Auto Raspberry Pi

Hardware and Setup

To get started with OpenWrt on your Raspberry Pi 4B, you'll need a few pieces of hardware. A Raspberry Pi 4 with 4 GB RAM is a good starting point, just like the one used in this tutorial. You'll also need a good SD card, as the image is tiny and the archive is less than 100 MB.

On a similar theme: Dropbox Raspberry Pi

Credit: youtube.com, How To Build A Custom Raspberry Pi Router // OpenWrt on RPi 4

A keyboard and monitor are required to change the Raspberry Pi's IP address manually, especially if your main network is on the same range. This can be done with a few command lines, and you'll need an Ethernet cable to connect the Raspberry Pi to your network.

Here are the specific hardware requirements:

  • Raspberry Pi: OpenWrt supports the Raspberry Pi 4 with 4 GB RAM
  • A good SD card: the image is tiny, and the archive is less than 100 MB
  • Keyboard: a keyboard is required to change the Raspberry Pi's IP address manually
  • Monitor: a monitor is required to change the Raspberry Pi's IP address manually
  • Micro-HDMI cable: used to connect the Raspberry Pi to a monitor
  • Ethernet cable: used to connect the Raspberry Pi to your network

Hardware Requirements

To start with OpenWrt, you'll need a few pieces of hardware. The Raspberry Pi is the brain of the operation, and it's supported by OpenWrt on almost every board, including the newest Raspberry Pi 5.

You'll also need a good SD card, but don't worry, the image is tiny, and the archive is less than 100 MB! A monitor is necessary for this process, and the author used a Raspberry Pi monitor with a micro-HDMI cable.

A keyboard is also required for manual IP address changes, and the author swears by their Rii keyboard. Finally, an Ethernet cable will come in handy for connecting your Raspberry Pi to your network.

Recommended read: Blue Raspberry Vodka

Credit: youtube.com, What Are The Hardware Requirements For A NAS OS? - The Hardware Hub

Here's a rundown of the specific hardware requirements:

  • Raspberry Pi: OpenWrt supports almost every board, including the newest Raspberry Pi 5.
  • A good SD card: you don’t need anything fancy, the image is tiny, and the archive is less than 100 MB!
  • Monitor: a Raspberry Pi monitor with a micro-HDMI cable will do the trick.
  • Keyboard: a keyboard like the Rii keyboard is recommended.
  • Ethernet cable: for connecting your Raspberry Pi to your network.

Raspberry Pi Setup

To set up your Raspberry Pi, start by installing OpenWrt on it. This will give you a solid foundation for customizing your device.

The first step is to connect the Raspberry Pi to your existing network. You can do this by plugging it into an Ethernet cable from your computer or connecting it to an unmanaged switch.

To access the OpenWrt web interface, click on "choose os" and select "Use Custom". Then, click on "Login" without setting a password initially.

Once you're logged in, you can access the web interface and start configuring your Raspberry Pi.

If you're experiencing issues with the web interface, such as errors when trying to update new packages, check your network settings and connectivity. These errors can be caused by issues like network ranges or permissions.

To resolve these issues, make sure you're using the correct network settings and that you have the necessary permissions to update packages.

For another approach, see: Openwrt Interface

Enable USB Device

Credit: youtube.com, How to setup USB Printer Port)

Enabling your USB device on OpenWRT requires some extra steps. OpenWRT doesn't have the kernel drivers for USB ethernet installed by default.

You'll need to install the kmod-mii, kmod-usb-net, and kmod-usb-net-rtl8152 opkg packages. These packages are available at the OpenWRT repository.

One way to get them installed is to manually download the needed packages to your laptop, then upload them via LuCI to the router. You'll have to install each package one at a time and click "Dismiss" on the install popup.

Alternatively, you could plug a WAN cable into one of the working ethernet ports and use the keyboard and screen to install the packages.

Installation and Configuration

To install OpenWrt on your Raspberry Pi 4B, you need to access the RPi-Imager and select the OpenWrt image. You can do this by clicking on "Choose OS" and then selecting "Use Custom" to load the OpenWrt image.

The installation process is straightforward, and you'll be prompted to confirm and start writing the image to the SD card.

Credit: youtube.com, How to build a Router with a Raspberry Pi and managed Switch VLANs with OpenWrt

Initially, no password is set in OpenWrt, so simply click on "Login" to access the web interface.

To access the OpenWrt web interface, you'll need to find the IP address under the "br-lan" section, which is usually highlighted in red. For example, my IP address is 192.168.0.33.

You can then open a web browser and enter the IP address into the navigation bar to access the OpenWrt web interface.

Here are the steps to follow:

  • Click on "Choose OS"
  • Select "Use Custom"
  • Load the OpenWrt image
  • Confirm and start writing the image to the SD card

Networking and Connectivity

To avoid network conflicts, it's essential to change the IP address of your Raspberry Pi, especially if your current router is using the default IP address of 192.168.1.1. You can use a small network switch to isolate your Raspberry Pi and manually set your computer to use any IP starting with 192.168.1.X.

When connecting your Raspberry Pi to your existing network, you'll need to change your password to something secure and enter specific commands to allow for automatic DHCP assignment of an IP to your Raspberry Pi.

Readers also liked: Nextcloud Pi

Credit: youtube.com, OPENWRT ON RASPBERRY PI 4B...

To configure your WAN, you'll need to add an interface for eth1, call it WAN, and then put it in the WAN zone in LuCI. You can also configure your USB ethernet device by installing the kmod-mii, kmod-usb-net, and kmod-usb-net-rtl8152 opkg packages, or by creating a custom OpenWRT image with the necessary drivers.

To enable your wireless interface, you can quickly configure it and use it once you get access to the web interface. You can also configure the DNS server by setting it to receive its DNS from your primary router or by changing the protocol to DHCP client.

A unique perspective: Openwrt Dyndns

Configuring the WAN

Configuring the WAN is a crucial step in setting up your OpenWrt network. This involves creating an ethernet device for the WAN and configuring it in LuCI.

To create an ethernet device for the WAN, go to Network / Interfaces in LuCI and add an interface for eth1. Call it WAN.

You'll also need to put the WAN interface in the WAN zone in the firewall settings. This is a simple step that can be easily overlooked, but it's essential for getting your network up and running.

Rebooting your device can help ensure that everything is working correctly.

A different take: Openwrt Luci

Connect Raspberry Pi to Your Network

Credit: youtube.com, Access ANY Network (remotely)

Connecting your Raspberry Pi to your network can be a bit tricky, but don't worry, I've got you covered.

First, you'll need to decide how to connect your Raspberry Pi to your network. You can either connect it directly to your computer using an Ethernet cable or connect it to your existing network using a switch.

To connect to your existing network, you'll need to plug the Raspberry Pi into an unmanaged switch, as I did in my setup. This will allow your computer to connect to the Raspberry Pi over SSH.

Once you've connected your Raspberry Pi to your network, you'll need to change your password to something secure. Then, enter the following commands to allow for automatic DHCP assignment of an IP to your Raspberry Pi.

You can also manually set the IP address of your Raspberry Pi to a different range, such as 192.168.1.X, to avoid conflicts with your existing router.

Consider reading: Openwrt Switch

Credit: youtube.com, How Do I Connect Raspberry Pi To My Home Network? - LearnToDIY360.com

Here are the steps to manually set the IP address:

* Use the following commands: `uci set network.lan.ipaddr=YOUR_IP>` `uci commit` `etc/init.d/network restart`

Remember to replace `YOUR_IP` with the IP address you want to use.

If you're using a Raspberry Pi 4, you may need to enable the wireless interface. This can be done by clicking on "Scan" to see a list of the wireless networks detected, then clicking on the one you want to connect to and filling out the form with your password.

Once you've connected to your network, you can log in to your Raspberry Pi using SSH with the following command: `ssh root@IP`

Discover more: Openwrt Uci

Set up DNS server

Setting up a DNS server is crucial for internet access.

You can configure OpenWrt to use your primary router's DNS server.

This is a simple solution that can get you up and running quickly.

To do this, you'll need to make OpenWrt receive its DNS from your primary router.

There are two possible solutions to this problem.

One solution is to use your primary router's DNS server.

This is a great option if you're already set up with a reliable DNS server.

Recommended read: Openwrt Travel Router

Image and Firmware

Credit: youtube.com, How to build an OpenWrt image // Compile and Install for Raspberry Pi 4B

To get started with OpenWrt on your Raspberry Pi 4B, you'll need to download the latest image available from the official website. Find the column corresponding to your Raspberry Pi model and click on the link in the “Firmware Openwrt Install” column to download the .gz image file.

The image size is relatively small, typically around 14 MB, so the download process should be quick. Once you've downloaded the image, you can proceed with flashing it onto your SD card.

To flash the image, you can use a tool like Raspberry Pi Imager, which is free and can be downloaded from the official website. Alternatively, you can use Balena Etcher, which should also work fine.

Here are the steps to flash the image using Raspberry Pi Imager:

  • Start Raspberry Pi Imager and insert your SD card into your computer using an SD Card reader.
  • Click Choose OS > Use custom and point to the file you downloaded above.
  • Click Choose Storage and select your SD card.
  • Click Next, and when asked to apply settings, hit No.

After confirming, the write process will begin, and you can see the progress on the screen. If everything goes smoothly, you can move on to the next step and access the web interface directly.

Note that OpenWrt will set the Ethernet adapter to 192.168.1.1 by default, so make sure you have this information handy if you need to access the web interface.

Broaden your view: Openwrt Access Point

Tips and Recommendations

Credit: youtube.com, How To: Raspberry Pi Router and Firewall with OpenWrt

To get the most out of OpenWrt on your Raspberry Pi 4B, consider these tips and recommendations:

Change the default DNS provider after installation to improve security. This is a crucial step to protect your network.

Restrict LuCi and SSH access to the LAN interface after completing configuration to prevent unauthorized access.

Update the software lists and manually update each package one at a time to avoid breaking the LuCI install. This was a painful lesson learned by the author.

Some quality of life packages to install include less, bash, curl, nano, and mg. These will make your life easier when working with the command line.

Here are some additional packages to consider:

  • luci-app-statistics: provides useful statistics and monitoring tools
  • luci-app-sqm: enables traffic shaping and Quality of Service (QoS) management
  • mwan3: provides failover and load balancing capabilities

By following these tips and recommendations, you'll be well on your way to setting up a robust and secure OpenWrt system on your Raspberry Pi 4B.

Access and Management

To access the openWRT configuration interface, simply open a browser on the machine connected to the Raspberry Pi and type http://192.168.1.1.

You'll be asked for a password, which is "pi" - yes, just "pi".

Once inside, you can use the graphical interface to make settings faster.

Accessing via Browser

Source Code
Credit: pexels.com, Source Code

Accessing the openWRT interface is surprisingly straightforward. You can do it using a browser on the machine connected to your Raspberry Pi.

Type http://192.168.1.1 into the browser's address bar. This is the default address for the openWRT web interface.

You'll be prompted for a password. In this case, the password is simply "pi".

Once you're logged in, you'll be inside the openWRT configuration interface.

Update System Time

If you've just installed OpenWrt, you might notice the system time is off. This can cause issues with package updates later on.

Go to System > System and click on the General Settings tab. From there, you can sync your system time with either the browser or an NTP server - it's worth trying both for good measure.

Wait 5-10 seconds for the system to sync, and it will update your time to UTC. This is a good default to have.

Click Save & Apply at the bottom to save the changes. Now your Local Time should be correct, and it's in UTC.

Lee Mohr

Writer

Lee Mohr is a skilled writer with a passion for technology and innovation. With a keen eye for detail and a knack for explaining complex concepts, Lee has established himself as a trusted voice in the industry. Their writing often focuses on Azure Virtual Machine Management, helping readers navigate the intricacies of cloud computing and virtualization.

Love What You Read? Stay Updated!

Join our community for insights, tips, and more.