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.
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.
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.
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.
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.
So I am having fun playing around. I had a RPi 4 available for repurposing.
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?
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....
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 ?
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)