Printer Sharing: openSUSE 10 and 11 Samba Print Server for Linux & Windows Clients

Simply put: it's about printing to a Linux computer from either a Linux computer or a Windows computer using Samba's SMB/CIFS Protocol.

Versions: Suse / openSUSE 10.0, 10.1, 10.2, 10,3, 11.0, 11.1

In this tutorial you share a printer on a Linux host as a print server for both Windows and Linux clients using Samba networking. An alternative protocol, Internet Printing Protocol (IPP) is covered in a separate Tutorial: Linux IPP Printer Sharing. I think that sharing a printer by IPP is easier than sharing by Samba. The reverse scenario where you share a printer on a Windows host as a print server for Linux clients is covered in a third Tutorial: Windows Printer Sharing. This HowTo assumes CUPS is used for printing. Samba of course is installed and running.

Fixed IP address or DHCP Addressing? Your print server can have either a fixed or a dynamic (DHCP) IP address. Dynamic addresses are the Suse do-nothing default. Fixed addressing is the Administrator's choice for Linux servers because it's easier to administer. Tip: there's a reason why fixed IP addressing is widely recommended for servers. Here's a tutorial on configuring addressing both ways: HowTo Configure a NIC in Suse/openSUSE.

Firewall and Ports: You have your network card in the "external" zone of SuSEfirewall2 (note that if it's in the "internal" zone, you're wide open). SuSEfirewall2 blocks the printing port by default, port 631. You can open Port 631 in Yast --> Firewall --> Allowed Services --> Services to Allow --> Cups. Similarly Samba's ports, 135, 137, 138 and 139 are shut unless you open them in Yast (at danger to your Samba setup) or follow the SuSEfirewall2 Tutorial. Tip: turn the firewall off while you get print sharing going, then cope with the firewall.

Starting CUPS: Make sure CUPS is set to always start on booting: GoTo Yast --> System ---> System Services (Runlevels) --> Expert Mode --> cups = yes + runlevels 2, 3 and 5 --> Finish. Also, when you make changes to the CUPS configuration file you need to restart cups with this root shell command: rccups restart.

Check Communications with the Linux server: I ping the IP address of the server from the client as the first test, that's a must. Then I create a shared folder on the server, just to see whether I can see it from the client. Suppose my server's netbios name is suseserver and IP is 192.168.2.2. The real test is to enter these addresses in the client's network browser: smb://192.168.2.2 and smb://suseserver. I expect to see the shared folder using both addresses if my network is up to scratch. If these don't work then your SMB/CIFS name resolution needs tweaking. You can work only with IP addresses if you have a server with a fixed IP.

Authority to change CUPS: When you attempt to make changes in the CUPS admin GUI (which is at http://localhost:631 -- click to see) you'll need a username/password pair. For openSUSE 11.0 & 11.1 supply the credentials for the Linux root user. In Suse Linux 10.x and openSUSE 10.x, the process changed over time from this command in a console: sudo lppasswd -a username to this command in a console: sudo lppasswd -g sys -a root.

Setup the CUPS configuration file on the Server: The cups configuration file is the text file "cupsd.conf", located at /etc/cups/cupsd.conf. You can open a root-owned text file like cupsd.conf with either of these commands in a terminal window:

  • for KDE use kdesu kwrite /etc/cups/cupsd.conf
  • for Gnome use gnomesu gedit /etc/cups/cupsd.conf

File cupsd.conf is grouped into segments. Locate the segment for two of these segments as indicated below and edit it until it is in the required modified form displayed below:

1: Advertise printers on local network

# Show shared printers on the local network.
Browsing On
BrowseOrder allow,deny
BrowseAllow @LOCAL

2: Allow LAN printing to the Linux server

# Restrict access to the server...
<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>

Notice how the local LAN is allowed as 192.168.2.*. If you want to allow all subnets, then uncomment the line #Allow From @LOCAL.

I have attached copies of the adjusted files cupsd.conf that I used to create working servers on Suse 10.0 & 10.1 and openSUSE 10.2 & 10.3 & 11.0 & 11.1 which you can compare against yours.

Set up the Samba configuration file on the server

Samba's 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:

[global]
printing = cups
printcap name = cups
printcap cache time = 750
cups options = raw
load printers = yes
use client driver = yes

The [global] paragraph will contain other statement lines that facilitate network communications. Provided that you can pass the tests I mentioned above in para titled "Check Communications", you have the correct extra lines in [global]. For those who really need to know, I have attached a copy of my file smb.conf for you to peruse. It's for a no-firewall situation and zero other security.

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

[printers]
comment = All Printers
path = /var/tmp
printable = Yes
create mask = 0700
browseable = No
guest ok = Yes

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.

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

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:

  • Open http://localhost:631 --> Administration --> Add Printer: enter a printer name, say hpviasamba, no spaces, and optionally a location and description.
  • In Device for hpviasamba, select from the drop-down list Windows printer via Samba.
  • In Device URI, enter smb://workgroup/192.168.2.2/laserjet1020.
    If you have restricted access to the server, you must add the username and password in the URI; e.g. smb://workgroup/username:password@192.168.2.2/laserjet1020.
    You can use the NetBIOS name instead of the IP address in the device URI but you need to have passed the browsing test that I gave above for good Name Resolution.
  • 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. Tip: Install the win drivers for the printer first.

  • If you passed the "Check Communications" segment above, you won't need this first list item at all. But if you are having difficulty seeing Linux shares from Windows network browser, you have poor Samba NBT communications. This tweak might help but if and only if you are using fixed IP addressing on the Linux Print Server: 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 suseserver). If the hosts file isn't there, create it with those two lines in it.
  • Search either for the Server netBIOS name (suseserver) or 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 name (suseserver) or your server IP address (192.168.2.2) as the search term. The search will return an icon displaying the server's name and workgroup.
  • Open/click the icon and you should see the shares on the print server, including the laserjet1020. R-click the laserjet1020 and select connect.
  • Wizard presents you with 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 Have Disk button at this stage, or otherwise 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 oldcpu on the Suse Linux Support Forum.

I Hope this Tutorial makes life a bit easier for you.

Swerdna: 08 January 2007; last revised 27 September 09