You may have heard of a Router-on-a-Stick before. It’s a network configuration trick to configure routing for two different networks when you only have a single interface on a router. We’ve done it for a number of years for things like voice networks when we’re limited on resources. However, it’s been so long since routers have only come with a single Ethernet interface that stick routing has mostly become a configuration oddity.
However there is one device that is still in wide use that has a single network interface that benefits greatly from this old routing trick. The Raspberry Pi is the most popular small computer for hobbyists as well as for IT pros that need to deploy basic compute to some interesting locations. However, the lack of multiple Ethernet interfaces makes it hard to deploy as a router. Looks like we’ve found a great reason to resurrect the router-on-a-stick for a computer that can easily fit on one!
Louwrentius has an excellent write up on how to configure the Linux OS running on a Raspberry Pi with VLANs and routing protocols to make this a reality for you. Here’s an excellent excerpt from his post:
As you can see, the VLAN packets that arrive as tagged packets, are send (without their tags) to a virtual network interface belonging to that particular network. Those virtual network interfaces all share the same physical interface (enp2s0f0). The virtual network interfaces are just the physical interface name with “.(VLAN ID)” added.
From here on out, you probably understand where this is going: those two virtual network interfaces are basically similar to a setup with two physical network interfaces. So all the routing and NAT that needs to happen, just happens on those two virtual interfaces instead.
Make sure you read the entire article for configuration snippets and theory behind why the Pi makes a great router: Raspberry Pi as a Router Using a Single Network Interface