post music: anders enger jensen - a song long ago
Okay, so. I have an old laptop. Like, really, really old. It is a Dell Precision M60, from 2005. Right in the height of Dell batteries pulling a Note 7 before the Note 7 made it scary. Anyway, I keep this machine around because there are some points where I'll need an old system, such as doing synchronisation to and from my WorkPad z50. I don't have the serial cable for it, and ActiveSync doesn't play nicely on newer versions of Windows anyway. Not the point, that's for a different adventure.
When I'm not using crusty old Windows XP or a suspiciously fragile Hackintosh Leopard install, I run Haiku on it. For the uninitiated, Haiku is a binary-compatible, open-source reimplementation of BeOS. It is currently in beta, but it is shockingly stable for a beta, and it still gets reasonably regular releases and new software and the community is great. It is also shockingly snappy on older hardware. Even moreso than Linux. Thus, Haiku is my everyday choice for this particular laptop.
There is one problem with this, though. The WiFi implementation is dogwater. Well, okay, the Broadcom 4306 installed isn't great to begin with. But at least it would work reasonably in Windows and even in the suspiciously fragile Leopard with a kext patch. In Haiku, I've had random connection dropouts, speed kills, and even the entire system crashing with its WiFi implementation. Now, I could use Ethernet exclusively, and the experience is actually good over Ethernet. But I want my wireless connectivity, damnit!
So, why not use a small nugget machine, say, a Raspberry Pi, for pushing WiFi over the Ethernet port? I have a currently unused Raspberry Pi 3 (which, I thought was a B+ for the longest time but it's actually just a B regular, huh.) laying around. Let's put it to use.
Now, admittedly, I have done this before. Back in college I used this machine, Haiku and all, when my everyday had its first board failure and was getting RMA'd. I couldn't deal with the paltry WiFi then, either, and so I used my old Pi Original as the WiFi bridge. I don't have my Pi Original anymore; it kicked the bucket a year or two ago with a blown USB power fuse. Even moreso, I don't have the original configuration for how I did it before, so I gotta do this from scratch.
There are many, many guides online for how to do this. However, my configuration is a bit different than what the guides use, and it comes down to the image. I've been an avid user of DietPi ever since discovering it and now every SBC (and even some VMs) here in the lab use exclusively DietPi, and unless you plan on using your SBC with a GUI you should too. But, that runs into issues because all of the guides that I've found, at least for Raspberry Pi, use Raspbian-- justifiably-- as the base.
Thusly, here is the definitive guide for doing this with DietPi. This assumes that your SBC is already connected to a network and the Internet over WiFi.
net-tools. You can do this either with
aptthe traditional way or perhaps by installing the PiHole package from
dietpi-software. I've not tested the PiHole installation method; it might not install
net-tools. If it doesn't, install it.
iptableswill need to be installed manually. Just do it with
aptit'll be easier.
- Set a static IP on
eth0. You can do this from
dietpi-configor by manually editing the
/etc/network/interfacesfile to something similar to this:
allow-hotplug eth0 iface eth0 inet static address 172.24.20.1 netmask 255.255.255.0 gateway 172.24.20.1
wlan0configuration lives in here as well. Don't touch it. DietPi will require you to reboot after making this configuration change.
- The following commands will set up forwarding to and from the target on
# iptables -F # iptables -t nat -F # iptables -t nat -A POSTROUTING -o wlan0 -j MASQUERADE # iptables -A FORWARD -i wlan0 -o eth0 -m state --state RELATED,ESTABLISHED -j ACCEPT # iptables -A FORWARD -i eth0 -o wlan0 -j ACCEPT
- Uncomment the line in
interface=eth0 listen-address=172.24.20.1 # Make sure this is the same as what you set as the static IP above. bind-interfaces # Forces dnsmasq to bind to eth0 server=188.8.131.52 # You may use whatever DNS server you please. I'm using Quad9 here. domain-needed # prevents non-FQDNs from being forwarded bogus-priv # prevents weird address calls from being forwarded dhcp-range=172.24.20.69,172.24.20.169,12h # This is technically optional; you could totally set a static IP on the other end and it'll work, but it helps to be modular.
# dietpi-services enable dnsmasq && dietpi-services start dnsmasq
- Fire up your target machine and plug in the Ethernet. If it configures itself, then you're good to go. Try pinging your WiFi AP or even an Internet IP just to make sure.
Once it works, you'll need to, at minimum, add the
iptablescommands to a boot script, as those are lost on reboot. The entire internet has decided that the
iptables-persistentpackage is the way to go, but we're not doing that. Instead, we'll create a new service by making new file
/etc/systemd/system/wifi-forwarding.servicewith these contents:
[Unit] Description=DietPi iptables WiFi Forwarding After=network.target [Service] Type=oneshot ExecStart=/bin/sh -c 'iptables-restore < /etc/iptables.rules' [Install] WantedBy=multi-user.target
Then, dump the current table with
# iptables-save > /etc/iptables.rules. To test it, clear the table with
# iptables -Fand then run with
# dietpi-services start wifi-forwarding. Now, if you run
iptables -Land get results, it works! Enable with
# dietpi-services enable wifi-forwardingand you're on your way.
This works shockingly well on my Haiku system, and the speeds are actually good compared to the onboard WiFi, and I don't risk crashing the system just from running a system update. Of course, this isn't just for a computer. It'll work for any Ethernet target. Network printer without WiFi? Done. Dusting off the ol' Dreamcast? It does WiFi now. Plug in a small switch? Boom, WiFi extender. I'll be seeing quite a bit of use with this.