Tuesday, February 10, 2015

Using a Netgear WNDR3400 as an OpenWRT Wireless Print Server (Part 3)

This is part of a series of blog posts.
Continued from Part 2

Note: Always `opkg update` before you `opkg install.`
Note: This works perfectly for my printer and my Mac. Your results may vary.

First, you want to install mDNSResponder. OpenWRT has a package for both `howl-mdnsresponder` and `mdnsresponder` available. The howl variant has been around for years and they recently decided that it will no longer be supported instead focusing on the real version. I decided to go with the good old reliable version. You can probably get the real responder to work exactly the same but I made my choice. You'll need to install it.
opkg install howl-mdnsresponder
Second, you'll need to configure it. It's super simple. Just edit your mDNSResponder config file with `vi mDNSResponder.conf` and add the following line. You can remove anything that was there if you want. Replace the text in `product=(*)` with your actual printer name. My Mac was smart enough to figure out exactly what driver it needs.
"OpenWRT Printer"  _pdl-datastream._tcp  local.  9100  "txtvers=1"  "note=Office"  "product=(Lexmark E232)"
Third, you'll want to setup automatic restarts of mDNS service. The mDNS service starts real quick, but unfortunately it takes a couple seconds for the WiFi service to connect. You want to restart the service after the WiFi is live so all the other computers around can be friendly.

You could manually restart the service after every reboot but that could get tedious constantly typing `/etc/init.d/mDNSResponder restart` if it isn't on an UPS. Fortunately, OpenWRT has a great little service they call hotplug. Just put some shell scripts in the right folder and they are run networks are activated or buttons are pressed. So just start up an editor for a new file.
vi /etc/hotplug.d/iface/80-mDNSResponder
The name `80-mDNSResponder` is completely arbitrary it is suggested that you name the file with a number in the front so you can tell what order they run in and I wanted it to run pretty late. Now just put the text below in the new file.
if [ "$ACTION" = ifup ] && [ "$DEVICE" = wlan1 ]; then
  /etc/init.d/mDNSResponder restart
That says if the wlan interface is brought up restart the mDNSResponder service. Pretty straight forward.

Fourth, restart your router again. Find the System Preference for adding a new printer and it should show up there as a Bonjour available device.

You are done. Go celebrate.

Part 4 exists, but don't go there.

No comments:

Post a Comment