I recently decided I wanted to replace my aging Asus router which last had an update many years ago. Against a backdrop of the developing new world order, I wanted something that I built and controlled, at least as much as is reasonably possible, so I opted for a Raspberry Pi based router using OpenWrt.
The Pi only has one ethernet port, of course, and rather than go for a USB solution to this problem, I instead bought this:

The shopping list:
You'll also need an SD card or other storage solution, but I already had one.
The case is pretty cool, and very easy to set up. It's just a case of putting the Pi inside along with the extra boards that come with the case. One of these is the additional ethernet port while the other extends the HDMI, power and UART connections to the front and back of the case.

Connect it all up and then you can turn your attention to the software and drivers. It's at this point I logged into the web interface and set up everything LAN related, like the IP address and so on. I won't cover that as it's fairly simple.
One thing I will mention is that you'll need 192.168.1.1 to be unused, as this is the default OpenWrt IP address. If it isn't free, the only option I had at the time was to use VirtualBox on my Windows laptop with USB passthrough, put the OpenWrt SD card into my laptop and edit /etc/config/network
to change the IP.
Next, you have to turn on PCIe. You just need to edit config.txt in the FAT32 boot partition of your OpenWrt SD card, then add the following line.
dtparam=pciex1
So far, so good. If you boot the router and then SSH in, you can run the following:
> opkg update && opkg install pciutils
> lspci
0000:00:00.0 PCI bridge: Broadcom Inc. and subsidiaries BCM2712 PCIe Bridge (rev 21)
0000:01:00.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8111/8168/8211/8411 PCI Express Gigabit Ethernet Controller (rev 15)
0001:00:00.0 PCI bridge: Broadcom Inc. and subsidiaries BCM2712 PCIe Bridge (rev 21)
0001:01:00.0 Ethernet controller: Raspberry Pi Ltd RP1 PCIe 2.0 South Bridge
The second line here tells you that the PCIe ethernet controller has been detected, so next you need to install drivers for it.
> opkg install kmodār8169
That should do it. Rebooting may or may not be necessary at this point, I'm not sure, but the PCIe ethernet port should now work. You can verify by running:
>ip link show eth1
3: eth1: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN qlen 1000
link/ether 2e:8a:e1:fc:5a:bb brd ff:ff:ff:ff:ff:ff
At this stage in my setup process, I hadn't actually connected a cable, so the interface showed as down. In order to configure OpenWrt to use eth1
as the wan
interface, you can run the following:
> uci set network.wan.device='eth1'
> uci set network.wan.proto='dhcp'
> uci commit network
> /etc/init.d/network restart
For me and my ISP, DHCP was the right way to go. If you use PPPoE or something else, you will need to do a little extra work here, although from what I understand it's only a few extra commands to set the PPPoE user/pass values.
If you want to verify the firewall isn't going to let anyone in, you can do this:
> uci show firewall | grep -A6 "@zone.*name='wan'"
firewall.@zone[1].name='wan'
firewall.@zone[1].network='wan' 'wan6'
firewall.@zone[1].input='REJECT'
firewall.@zone[1].output='ACCEPT'
firewall.@zone[1].forward='REJECT'
firewall.@zone[1].masq='1'
firewall.@zone[1].mtu_fix='1'
If you don't see the masq
and mtu_fix
items (as I didn't), you can use the following:
> uci set firewall.@zone[1].masq='1'
> uci set firewall.@zone[1].mtu_fix='1'
And that's it! Connect your internet connection to eth1
and your LAN to eth0
and you've got yourself a router.