Printing from FreeBSD to a Printer on Windows XP

We have a HP DeskJet 970 series printer connected to a Windows XP system. I wanted to print from my FreeBSD laptop to this printer. I decided to try installing Windows Print Services for UNIX, a sort of LPD for Windows, using these instructions. Once done the Windows system was listening on port 515 for print jobs.

If the DeskJet understood Postscript, I should have been able to print directly from FreeBSD using the lpr command. Without Postscript support, I needed to use a filter to accommodate the printer. Inspired by Michael Lucas' recent articles on Apsfilter, I gave it a try. Unfortunately I could not get Apsfilter to work with my printer, so I turned to CUPS.

I installed CUPS using the CUPS port. Through trial and error I figured out I needed to start cups-lpdfrom inetd by adding this line to /etc/inetd.conf:

printer stream tcp nowait lp /usr/local/libexec/cups/daemon/cups-lpd cups-lpd

This means I made sure the native lpd was not running, and inetd was running, by adding this to /etc/rc.conf:

inetd_enable="YES"
lpd_enable="NO"

After starting inetd manually, I started CUPS with a renamed /usr/local/etc/rc.d/cups.sh script. That launched a Web server at http://localhost:631/. I could not reach the Web server via http://orr.taosecurity.com:631 even though sockstat output showed port 631 TCP available on all interfaces:

orr:/home/richard$ sockstat -4
USER COMMAND PID FD PROTO LOCAL ADDRESS FOREIGN ADDRESS
root cupsd 6892 0 tcp4 *:631 *:*
root cupsd 6892 2 udp4 *:631 *:*
root sendmail 429 4 tcp4 127.0.0.1:25 *:*
root sshd 423 3 tcp46 *:22 *:*
root sshd 423 4 tcp4 *:22 *:*
orr:/home/richard$

Once I logged in as user root with root's password, I was able to add my remote printer. I selected "LPD/LPR Host or Printer", with device URI "lpd://192.168.2.8:515/scout". The IP is the machine where the printer is connected, pot 515 is the LPD port, and 'scout' is the name of the queue. I chose "HP" as the "Model/Driver" and the last "HP DeskJet 900 CUPS+Gimp-Print" series entry(of which there were 15 identical items).

Once done I was able to print a test page within the CUPS Web administrative interface. Getting my applications to work was another story. CUPS installs a new 'lpr' binary in /usr/local/bin/lpr. Apparently using this lpr one can print using CUPS. Unfortunately I could not use the stock /usr/bin/lpr to print, so I moved the stock version to /usr/bin/lpr.orig and made this link:

ln -s /usr/local/bin/lpr /usr/bin/lpr

Now I can print from OpenOffice. Under Mozilla I was able to specify /usr/local/bin/lpr. I believe I could have also tried installing Samba on my FreeBSD machine, but I didn't feel the need to do that. I can mount remote Windows shares on the XP box using FreeBSD's mount_smbfs:

mount_smbfs -I 192.168.2.8 //administrator@scout/temp /mnt

That command mounts the remote share 'temp' on host 'scout', IP 192.168.2.8, as user 'administrator', to my local /mnt share.

In other FreeBSD news, I've moved to Fluxbox as my new window manager. I was using FVWM with an Afterstep theme, which I decided was somewhat silly. Fluxbox seems to be working out fine for now. I like the simple syntax in the ~/.fluxbox/menu file:

[begin] (Fluxbox-0.9.8)
[exec] (aterm) {aterm -bg black -fg white -sl 1000}
[exec] (mozilla) {mozilla}
[exec] (sguil) {/usr/local/bin/sguil.sh}
[exec] (ethereal) {aterm -e sudo ethereal}
[exec] (acroread) {acroread}
[exec] (openoffice) {openoffice-1.1}
[exec] (xv) {xv}
[exec] (gv) {gv}
[exec] (gtksee) {gtksee}
[exec] (gtk-gnutella) {gtk-gnutella}
[exec] (xmms) {xmms}
[exec] (gmplayer) {gmplayer}
[exec] (vmware) {vmware}
...and so on...

Popular posts from this blog

Zeek in Action Videos

New Book! The Best of TaoSecurity Blog, Volume 4

MITRE ATT&CK Tactics Are Not Tactics