NOOB looking for a quick explanation of how a RPi can be a router

Hello all,
Pretty new to OpenWRT and most things networking. I have seen a lot of posts saying they use an ODRIOD or Raspberry Pi and a Managed Switch for high speed low latency routing etc.

I am really curious how this works. Does anyone have a summary and maybe a diagram of how this works? Is the Pi somehow able to control the switch?

Thank you! :slight_smile:

1 Like

The code word is VLAN. It basically allows you to carry different virtual streams over the same wire between say the RPi and switch. The managed switch can then route those streams to independent ports again e.g. one where you hooked up your internet connection aka WAN and others being LAN. One limitation is of course that all traffic shares that one cable's bandwidth.


Ahhh, so setup one interface on the switch as a WAN port connected to the ISP, another as a LAN port connected to the Pi and put them both in the same VLAN, correct?

I would assume the rest of the interfaces are then setup a LAN ports and connected to the various computers, etc. and placed on a separate VLAN.

So then how does the Pi communicate with the computers on second VLAN and route?

A managed switch is one option for a "router on a stick" setup but keep in mind that it will cut your maximum throughput in half. I have had great success using a Raspberry Pi with a USB gigabit Ethernet adapter for the WAN connection and the onboard gigabit port to connect to the LAN. The TP-Link UE300 is a popular choice and works well, though any RTL8153-based dongle should work fine. Avoid anything with an Asix chipset.

Note that the stock OpenWRT image doesn't include the necessary kmods to support the USB adapter, so you will need to either use a community build (wulfy23's for example), create your own image using an image builder, or download the packages ahead of time and opkg install them onto the Pi after flashing the image.


This looks like a good walkthrough for the router-on-a-stick configuration. The gist is that you define separate VLANs for WAN and LAN (one port for WAN, however many for LAN) then put the Pi on a trunk.

This is awesome! Thank you. Only about half-way through the article and many of my questionsare answered. :slight_smile:
Thank you!

No, of course separate VLANs for those. Basically, on the RPi you really do get two separate Ethernet interfaces for them, just virtual ones.

Those separate virtual Ethernet interfaces are exactly how one can achieve that.


The router on a stick approach is not advantageous in terms of throughput or latency compared to adding a good USB ethernet card, it's just a method to save cables/ cash (not really, if you have to buy a managed switch first).

Using two ethernet cards (one onboard, one via USB3) will always be better (faster) - and is also easier to set up and operate, especially for beginners. VLANs are anything but trivial to start with.

1 Like

So with a USB Ethernet dongle, you don't need a managed switch? I am assuming one port goes to the ISP connection and the other to the rest of the LAN. The Pi is the router and gateway using OpenWRT and not really anything else to "manage".

Further, If I add a second dongle, I could have a multi-WAN setup and let OpenWRT load balance or bond using MPTCP and a VPS.

Am I getting that about right?

Yes, a USB Ethernet adapter is the way to go. It's important to pick one with the right chipset, specifically the RTL8153, for the best performance. The TP-Link UE300 is probably the best choice for most.

1 Like

So I am having fun playing around. I had a RPi 4 available for repurposing. :slight_smile:

I installed OpenWRT and I am currently setup having the Pi's wireless connected as my WWAN. I ordered a USB ethernet, but want to play now.

Anyway, I am having an issue where I cannot seem to force my RPi wireless client to use 5Ghz. It tries when I restart the radio, but quickly switches to 2.4Ghz. Problem is, I have a great ISP connection and cannot get the RPi to saturate the connection on 2.4Ghz.

My iPhone and computer sitting right here next to the RPi both use the ISP's 5Ghz channels, but I cannot seem to get the Pi to do the same.

Anyone have any thoughts on how I can force the WIFI client in OpenWRT on the RPi to use 5Ghz?


Using the inadequate 1x1 WiFi on the RPi will hardly provide good results (and neither would external USB cards, for similar but slightly different reasons).

Starting with the RPi4, this platform can be a very capable wired router, but its wireless side is better left non-existent and connected externally (via purpose built APs).

1 Like

Hello, I noticed this thread through the summary mail, I have this "router on a stick" thing, with wan+lan on the same port, and am considering on switching to USB adapter. I would like to be able to switch without interrupting the service for more than 5 min. Can I just create the wan interface for the USB adapter in addition to the current wan still on production, and then quickly change the cabling, to make the new wan work immediately?

I initially chose wan+lan on the same port beacuse I thought USB jack might come out, while ethernet cable wont, but then it seems that this setting is responsible for that I have to restart raspi whenever the modem gets restarted. I don´t like it at all. And I´m getting short on ports on the switch, want to free up a port.

In all I kind of regret having used Raspi4 for a router....

You could plug the USB adapter in, reassign the WAN interface to the new device, then move the cable from your switch to the adapter. It shouldn't take 5 minutes, just a few seconds at most.

Thank you for your reply! I haven't plugged the adapter in yet (I have a UE300), but I'm wondering, Deutsche Telekom requires that wan traffic should be tagged vlan7. Right now wan device is eth0.7 for that. I saw elsewhere that the driver for USB adapter is called usb2eth. Should I type usb2eth0.7 in order to get the VLAN7 tag ? It's going to be connected to a pure modem (speedport entry2).

As for the driver, is kmod-usb-net-rtl8152 the right one ?

Yes, that kmod is correct. My UE300 (great choice BTW) came up as eth1, so once you have the kmod installed and plug it in it should be as simple as switching the WAN assignment to eth1.7. :slight_smile:

Thank you! Just done. Yes, mine came out eth1, too. It was very quick:) Only, the UE300 suddenly stopped working, as I changed the port of the switch for LAN (ethernet port): it should be irrelevant to the USB adapter, but I reconnected the cable to it, then the light came up again, and it worked. I hope it stays that way.... perhaps it's not very clean? (I carried it in my pocket for a while)

It would be good if you gave the contacts/pins all around a cleaning with some contact cleaner or something.

OK, I will pull it again and take a look and try to clean as I can...

By the way, I power-cycled the modem to see what happens, the connection recovered automatically :slight_smile: (which was not the case, as I was doing LAN+WAN on the single Ethernet port)

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.