Ubuntu supports printer sharing over networks, so you can print from your Ubuntu machine, your Windows machine, etc, to another Ubuntu or Windows machine that has a printer attached (ie a "Ubuntu print server" or "Windows print server").
Ubuntu uses the Common UNIX Printing System ("CUPS") to handle printing. CUPS uses the Internet Printing Protocol ("IPP") as the basis for managing print jobs and queues. Other protocols are also supported (LPD, SMB, AppSocket a.k.a. JetDirect), some with reduced functionality.
CUPS printer configuration and management is handled by the Printer Admin utility launched from the Gnome menu - System -> Administration -> Printing (If the menu item does not exist you need to add the command system-config-printer to the menu). Also IPP provides web services so after you have configured CUPS appropriately, you can access the printers and jobs via your web browser.
When a locally attached printer is defined, eg using the Printer Admin utility, that printer is automatically published from this "print server" host to the network, depending on the server directives in the CUPS configuration file. A remote Ubuntu "client" host can then be able to see and use the printer attached to the server. The network printer automatically appears in the client's Printer Admin utility. It simply pops up if CUPS is up and configured correctly and disappears if you stop CUPS at either the Print Server or your local machine.
Ubuntu print server
The Print Server is the Ubuntu computer that is directly connected to the printers.
On the server machine (the one the printer is attached to), open System -> Administration -> Printing (If the menu item does not exist you need to add system-config-printer to the menu). . This will open the Printer Configuration window.
Select Server in the menu bar, and then Settings. This will open the Basic Server Settings window.
- Check the second box:
Publish shared printers connected to this server If this computer acts as both a Print Server and a client (it does need access to a printer connected to another computer), select also the first box, "Show printers shared by other systems".
Right click the printer and check the Shared option, if not checked yet
Check that users that you want to be able to use the printer are not excluded. See Properties>Access Control. The default settings may be set to "deny printing for everyone except ..."
But you might want to "allow printing for everyone".
Ubuntu print server compatible with Windows (Samba)
If your Ubuntu print server shall be able to work also with Windows clients, you must first make sure that the SAMBA package is installed (e.g. using Synaptic package manager). Then, do a little configuration change to SAMBA. In brief, you must uncomment the following lines in /etc/samba/smb.conf - open terminal and run:
gksudo gedit /etc/samba/smb.conf
In the [printers] section:
browseable = yes guest ok = yes
When done, restart Samba:
sudo service smbd restart sudo service nmbd restart
There is a dedicated page in the official documentation which gives more details.
Also, one would want to allow the following ports through a firewall (ufw for example) via:
sudo ufw allow 139/tcp sudo ufw allow 445/tcp sudo ufw allow 137/udp sudo ufw allow 138/udp
For more on this, please see here.
Printing from Ubuntu
Now let's configure the client (the Ubuntu computer from where you want to print):
System -> Administration -> Printing
Add - Network printer
Click Find network printer
- Specify the host IP address or name. (It may also work without, try) (IP address worked for me, hostname did not.)
- Printers on the target machine should be found, no matter whether they are connected using CUPS or SAMBA.
- BUT if both protocols are available, e.g. because you have shared your printer on a Linux box both using CUPS and Samba, prefer CUPS (ipp://) over Samba (smb://), because you won't be prompted to install a driver in general.
- You **may** be prompted to select a driver. Select your model in the list.
- (to be done) What to do if driver is not in the list
Printing from Windows
Once your Ubuntu print server is set up using SAMBA as described above, you can add the printer in Windows as follows:
- Devices and Printers
- Add a printer
- Add a network, wireless or Bluetooth printer
Click The printer that I want isn't listed (unless a miracle happens)
Enter the address manually (\\servername\MyPrinter). Be sure to respect uppercase/lowercase.
Note that searching or browsing for printers in Windows is notoriously unreliable, as it heavily depends on the network setup. Therefore, it is recommended to enter the printer address manually as shown.
Windows will then probably complain about a missing driver, and offer you to choose one manually. This is the easiest option, so select your printer manufacturer and model from the dialog box. (Alternatively, the Samba configuration could be improved so that the driver would be automatically downloaded.) If your printer model isn't listed, you may try the "Generic" printer.
Tips: You can avoid intermediate SAMBA buffer using direct connection to CUPS/IPP Ubuntu server from Windows workstation. You should manually specify "http://hostname:631/printers/MyPrinter" IPP URL and select printer driver.
Windows print dialog window (Ctrl-P) can take long time (about 30 seconds) to appear. You can reduce the connection time to CUPS IPP printer by disabling option Automatically detect settings in "Control Panel/Internet Explorer -> Internet Options -> Connections -> LAN settings".
1. Bypassing firewall.
If there is an firewall either on print server or the client side, there might appear a communications problem. Use this command to update the firewall to get through.
iptables -A INPUT -p tcp --dport 631 -j ACCEPT
- This rule is used for IPP only. If you're using other protocol, such as SAMBA, you have to adapt.
You might need to use this rule on both sides (server & client) if the firewall is being used on both of them. To apply this rule after each start/restart of the system, use /etc/rc.local .
2. Networking issues.
Be careful about using different network masks/subnets on your network where you would like to share the printer.
If the subnets differs, e.g. on the print server there would be a /24 (255.255.255.0) netwok mask configured, and e.g. on the clients there would be a /16 (255.255.0.0) network mask - perhaps provided by the DHCP server, this might cause a problem that clients won't be able to detect any shared printer on the server, even if other communications between print server and clients would be possible (e.g. ICMP, ssh) and successful.
If such situation happens, you have to unify the network masks/subnets on all of your stations, e.g. use /24 (255.255.255.
3. IP address
Generally, it is a good idea to assign your print server a static IP address. Instead, using its host name is also possible, but functionality will then depend on proper configuration of your home router, name service, etc.
4. IPv6 Windows (since XP) can print over IPv6 to Ubuntu Linux (tested between Windows XP SP3 and Ubuntu Linux 8.10). Make sure both the Windows and Ubuntu have IPv6 connectivity. You should tick "Allow Printing from the Internet" on the Ubuntu machine. Then use the URL (which resolves to IPv6) of the Ubuntu machine as described above.
5. Mac OS X 10.5.
Will not find your network printer unless you go to the terminal and run cupsctl BrowseRemoteProtocols=cups (see the CUPS 1.4 documentation at http://www.cups.org/documentation.php/doc-1.4/sharing.html). After doing so, you may need to set the network printer as your default printer for it to show up in program "print" menus.