Using an old router as a print server

My old Linksys EA4500 has a USB port, and Linksys claims I can use it for printer sharing. Sadly it requires a bitrotted old driver program to be installed on every client machine. Here’s a better way to make it work.

Contents

Install OpenWRT

I installed version 22.03.5.

Configure networking

Networking would be simple if I were actually using this device as my home router. For my use case, however, I’m just connecting a LAN port on the EA4500 to my home LAN. (You could connect it via wifi with a bit more effort.) Before I can actually plug it into my home network, it’s important to turn off the DHCP server and choose an appropriate IP address.

  1. Open the LUCI web UI and choose Network→Interfaces→Edit “lan”.
  2. Change the static IP to a free one on your network (odds are, 192.168.1.1 is taken), or change “Protocol” to “DHCP client”.
  3. Switch to the “DHCP Server” tab and enable “Ignore interface”.
  4. Save & apply. You’ll need to reopen the web UI on the newly selected IP.

Now you can safely plug it into your LAN. Next we need to give OpenWRT internet access so we can download a couple packages.

  1. Open Network→Routing.
  2. Add a route: Interface=lan, Target=0.0.0.0/0, Gateway=<your LAN gateway>
  3. Open Network→DHCP and DNS.
  4. Set “DNS forwardings” to your preferred DNS server.

Install print server

Follow the instructions on this page. In brief:

# opkg update
# opkg install kmod-usb-printer
# opkg install p910nd luci-app-p910nd

Enable the print server, and set the device to /dev/usb/lp0 and the interface to lan.

Set up mDNS

At this point you could follow the client setup instructions on the wiki, but we can make it much easier.

# opkg install umdns
# vim /etc/config/p910nd

The mDNS options are hidden from the web UI, so we have to edit them here. This is what my config looks like:

config p910nd
        option device '/dev/usb/lp0'
        option port '0'
        option bidirectional '1'
        option runas_root '0'
        option mdns '1'
        option mdns_ty 'Brother HL-5240'
        option mdns_mfg 'Brother'
        option mdns_mdl 'HL-5240'
        option mdns_note 'Basement'
        option enabled '1'
        option bind '192.168.1.3'

To get the values for mdns_mfg and mdns_mdl, run the following:

# cat /sys/bus/usb/devices/1-1/manufacturer 
Brother
# cat /sys/bus/usb/devices/1-1/product 
HL-5240

The mdns_ty and mdns_note values can be whatever you want. (note here means “location”, apparently.) And, of course, don’t forget to set mdns to 1.

Now, after a reboot, you should be able to click “add printer” on any Mac and see your print server appear automatically. On Windows you can do the same if you first install Bonjour Print Services.