Windows PC print to Linux printer

From openSUSE

HowTo: Print to a Linux Print Server from a Windows or a Linux Client


Author: [Swerdna]

Tested for Suse Linux 10.0 and 10.1

What question are you asking How do I print from Linux to Linux - stay here & read on How do I print from Windows to Linux - stay here & read on How do I print from Linux to Windows - go to [Companion Wiki Howto] How do I print from Windows to Windows - go to [this page of options]

Note from Swerdna 26 Oct 07: The CUPS configuration files for openSUSE 10.2 and 10.3 differ significantly from those for Suse Linux 10.0 and 10.1. This Tutorial is for 10.0 and 10.1. A tutorial for openSUSE 10.2 and 10.3 can be found on the site [Swerdna•Net]

Scenario: You have a home or small business LAN of mixed windows and Linux hosts/workstations and a printer is installen on a Linux host. You want to print to the linux print server both from windows and from Linux workstations.

Prerequisites: The computers that are/will be print servers must have fixed IP addresses so that the client computers can address the printers. Another must is to have CUPS as the printer engine for Linux and of course a working CUPS printer installed on the Linux print server. [Note added Oct 07: can now use DHCP-addressed server, [see here]]

Firewalls: Maybe firewalls on individual hosts should be off while you are installing & testing. Then put shields up afterwards. Here are some ports for you to consider letting through firewalls on hosts

445/TCP: SMB over TCPIP - Use this if NetBT turned off
515/TCP: LPD - Line PrinterDaemon - LPD windows/Unix printing
515/UDP: LPD - Line PrinterDaemon - LPD windows/Unix printing
631/TCP: IPP - Internet Printing Protocol of CUPS
631/UDP: IPP - Internet Printing Protocol of CUPS

Options covered in this tutorial

There are two ways to do this job. Both use Cups as the print engine. One way is to use the Internet Printing Protocol (IPP) via Cups network printing. The other way is to use Server Message Block (SMB aka CIFS) via Samba for communications to Cups printing. Either option requires Cups to be set up so we'll address that first.

Cups: Setting up the Linux print server.

If you need to set a username and password to access Cups administration, check the [companion printing HowTo]

The printer name (for network purposes) is available in the Cups admin gui at http:localhost:631/printers. In this example I have installed a Hewlett Packard LaserJet 1020 printer named "laserjet1020". Whatever name you choose, don't use spaces. Record laserjet1020 exactly for later use. That name is the queuename.

You can obtain the server's/host's IP address by entering "ifconfig" in a su console. Mine is 192.168.2.2 and I'll use it throughout the HowTo - but you use whatever is appropriate for you.

Cups automatically shares your printer. You can check this in /etc/cups/cupsd.conf, where you should find these two lines:

BrowseAllow @LOCAL BrowseDeny All If these lines are commented out, uncomment them.

Cups: Check Communications with the Linux server

Check Linux client communication by entering "telnet 192.168.2.2 631" in a console. Here's a succesful console session:

grizelda@acer:~> telnet 192.168.2.2 631
Trying 192.168.2.2...
Connected to 192.168.2.2.
Escape character is '^]'.
^]
telnet> quit
Connection closed.
grizelda@acer:~>

and here's an unsuccessful session:

grizelda@acer:~> telnet 192.168.2.3 631
Trying 192.168.2.3...
telnet: connect to address 192.168.2.3: Connection refused
grizelda@acer:~>

You can check windows client the same way, except you'll need the escape sequence "ctrl+]" to proceed from the blank screen you should get after entering "telnet 192.168.2.2 631" at the Dos command prompt.

Cups: Allow LAN printing to the Linux server

You need to check the file /etc/cups/cupsd.conf and ensure that the following block of code exists like so:

<Location /> Order Deny,Allow Deny From All Allow From 127.0.0.1 Allow From 127.0.0.2 Allow From @LOCAL Allow From 192.168.2.* </Location>

What I've done by adding the IP range 192.168.2.* is allow a local LAN to access Cups printing.

Now that the Cups server has been enabled you can choose one or both of two options, IPP or Samba. A Linux client using IPP doesn't require Samba running on the print server. A Linux client using Samba does require Samba running on the print server, of course. A Windows client does require Samba running on the print server.

We'll address these clients separately & in this order below: Linux with IPP, Linux with Samba, Windows with Samba (Samba in a windows context means the inherent suppot Windows has for SMB/CIFS).

IPP Option: Setting up a Linux client for IPP using the CUPS Admin GUI

  • Note the printer on the server has been called laserjet1020. You don't have to call the printer on the client the same name. Here we're choosing IPPlaserjet1020.
  • Open http:localhost:631 and enter a printer name, say IPPlaserjet1020, no spaces, and optionally a location and description.
  • In Device for IPPlaserjet1020, select from the drop-down list: Internet Printing Protocol (http).
  • In Device URI, enter http:192.168.2.2:631/printers/laserjet1020
  • Select the printer manufacturer from list in cups database
  • Select the printer model from list in cups database
  • Click printers, click Configure Printer to set formatting settings
  • On the Printers page, click Print Test Page to check connectivity

You should now be printing Linux_to_Linux using IPP/Cups

That's all for the IPP/Cups network client on Linux folks. It's really very easy but ONLY if you know how first.

Samba Option: Additional setup on the server to enable Samba sharing

Sambas configuration is generally preset by the manufacturer appropriately for each Linux distribution. Check that /etc/smb.conf has been set up for Cups and for printer sharing. The [global] entry should contain these lines; if not already present then add them:

printcap name = cups
cups options = raw
passdb backend = tdbsam    # you can use alternatives to tdbsam
encrypt passwords = Yes
wins support = Yes         # can use alternative name resolution
use client driver = Yes    # without this, gives error in windows
load printers = Yes        
printcap cache time = 750

Also, the [printers] section should contain these lines:

comment = All Printers
path = /var/tmp #just use the default
writable = No
printable = Yes
create mask = 0700
guest ok = Yes
browseable = No

At this stage with Cups set up and now Samba set up, you can print from either a Linux client or a Windows client to the print server using Samba to communicate with the Cups engine.

Samba Option: Setting up a Samba/Cups Linux client

All you need to do is activate the Cups admin GUI and install a printer (not a physical printer), bearing in mind that you're printing to IP address 192.168.2.2 where the queuename there is laserjet1020 (It's a HP Laserjet 1020). The steps are, screen by screen, as follows:

  • Note the printer on the server has been called laserjet1020. You don't have to call the printer on the client the same name. Here we're choosing SMBlaserjet1020.
  • pen http:localhost:631 and enter a printer name, say SMBlaserjet1020, no spaces, and optionally a location and description.
  • In Device for SMBlaserjet1020, select from the drop-down list: Windows printer via Samba.
  • In Device URI, enter smb:workgroup/username:password@192.168.2.2/laserjet1020
  • Select the printer manufacturer from list in cups database
  • Select the printer model from list in cups database
  • Click printers, click Configure Printer to set formatting settings
  • On the Printers page, click Print Test Page to check connectivity

You should now be printing Linux_to_Linux using Samba

That's all for the Samba/Cups network client on Linux folks. It's really very easy but ONLY if you know how first.

Setting up a Windows client printing to a Linux Samba print server

These settings need to be applied in Windows.

  • The file c:/windows/system32/drivers/etc/hosts will contain the line 127.0.0.1 localhost. Edit the file and add a line giving the IP address and hostname of the printer server (e.g. 192.168.2.2 suse101). If the hosts file isn't there, create it with those two lines in it.
  • Search for Server IP address (192.168.2.2): e.g. in Windows XP Professional do this: GoTo Start --> Search --> Search Computers/People --> Computer on Network --> enter your server IPaddress (192.168.2.2) as the search term. The search will return an icon displaying the server's hostname and IPaddress like so: suse101(192.168.2.2)
  • Open/click the icon and you should see the shares on the print server, including the laserjet1020. R-click the laserejt1020 and select connect.
  • Wizard presents you with stupid/unhelpful dialogue about drivers. --> go on to the list of installed Windows drivers.
  • Select Manufacturer (e.g. HP) and model (e.g. HP LaserJet 1020) from Printers list. If your printer isn't here you need to use the HaveDisk button at this stage, or othewrwise install the drivers.
  • Proceed and do a test print

You should now be printing Windows_to_Linux using SMB/Samba.

That's all for the Windows network client folks, and that's all for this tutorial

Credits: This tutorial was stimulated by advice given by broch, Jop, winxp_escapee and others on the Suse Linux Support Forum

Also published in [Swerdna's Linux Tutorials]