个人工具

如何在Ubuntu上使用网络打印

来自Ubuntu中文

跳转至: 导航, 搜索

如何在Ubuntu上使用网络打印

原文出处:官方Wiki

原文作者:

授权许可:

翻译人员:lightyears

校正人员:

贡献人员:

适用版本: 文章状态:等待校正



Overview(概览)

Ubuntu 5.10 (Breezy Badger)支持网络打印,所以你可以从你的Ubuntu或Windows之类的电脑到另一台带有打印机的Ubuntu电脑(例如一台“打印服务器”)上打印。本页仅包括这些特定情形。

本页不包括从Ubuntu到带有打印机的Windows电脑上打印,例如一台Windows打印服务器。WindowsXP打印机页请访问这里

Background(背景)

Ubuntu使用通用UNIX打印系统(缩写“CUPS”)处理打印事务。CUPS使用Internet打印协议(缩写“IPP”)作为管理打印作业和队列的基础。通过简化的功能也支持行式打印机服务、服务器消息块和AppSocket(a.k.a. JetDirect)协议。本页用CUPS和IPP描述网络打印。

CUPS打印机的配置和管理可以通过Gnome菜单系统 -> 管理 -> 打印下的打印机管理工具进行处理。另外,CUPS还提供了类似老的伯克利和SystemV的lpq、lpstat等打印命令的命令行指令。

当定义了一个本地打印机(例如使用打印管理工具),按照服务器上CUPS配置文件的指示,这个“打印服务器”主机自动向网络发布该打印机。远程Ubuntu“客户端”主机就可以看到和使用安装在该服务器上的打印机。网络打印机自动出现在客户端的打印管理工具上。如果CUPS启动并配置正确它就会出现,如果你在打印服务器或本地计算机上停止CUPS它就会消失。


  • ..从一个Ubuntu桌面(“客户端”)计算机打印到另一台连接有打印机的Ubuntu(“打印服务器”)计算机。

目前,在Ubuntu 5.10 (Breezy Badger)上你需要使用编辑器修改CUPS配置文件 /etc/cups/cupsd.conf 来实现网络打印。以下是让服务器和客户端计算机工作的完整实例。

Ubuntu Print Server(Ubuntu 打印服务器)

  • 这是你希望将打印作业送达的,装有打印机的计算机。
  • 使用打印管理工具(Gnome菜单 系统 -> 管理 -> 打印),添加一个本地打印机的定义。
  • 重新配置CUPS
    • CUPS服务器:/etc/cups/cupsd.conf 这个文件是基于Ubuntu 5.10的。注释行已经被删除。将它复制到你的系统里。
# /etc/cups/cupsd.conf
# Simple CUPS configuration file for a print server
# which serves printers within a private local area network.
# - There is no need for additional security within the print server, ie only authorises people can access the machine.

# This setup also allows access to the CUPS "Administrative tasks" system
# via your web browser to http://localhost:631
# File based on Ubuntu 5.10 (Breezy Badger) (Linux version 2.6.12-10-386)
# Server Directives are explained in http://localhost:631/sam.html

# 25/04/2006
# [email protected]

ConfigFilePerm 0600
LogLevel info
Printcap /var/run/cups/printcap
RunAsUser Yes
Port 631
Include cupsd-browsing.conf
BrowseAddress @LOCAL
BrowseAddress 10.0.0.0/8
BrowseAddress 172.16.0.0/12
BrowseAddress 192.168.0.0/16

<Location />
AuthType None
Order Deny,Allow
Deny From All
Allow From @LOCAL
Allow From 10.0.0.0/8
Allow From 172.16.0.0/12
Allow From 192.168.0.0/16
</Location>

<Location /jobs>
AuthType None
Order Deny,Allow
Deny From All
Allow From @LOCAL
Allow From 10.0.0.0/8
Allow From 172.16.0.0/12
Allow From 192.168.0.0/16
</Location>

<Location /printers>
AuthType None
Order Deny,Allow
Deny From All
Allow From @LOCAL
Allow From 10.0.0.0/8
Allow From 172.16.0.0/12
Allow From 192.168.0.0/16
</Location>

<Location /admin>
AuthType None
Order Deny,Allow
Deny From All
Allow From @LOCAL
Allow From 10.0.0.0/8
Allow From 172.16.0.0/12
Allow From 192.168.0.0/16
</Location>
  • This config file should be altered if security within your local network is an issue for you.
  • 如果对你来说本地网络的安全是个问题的话,这个配置文件就应该进行调整。
  • Change the network addresses if you are part of a different network, eg on the real internet, and remove unnecessary ones.
  • 如果你是另一个网络的一部分(例如在Internet上)那么就要改变网络地址,并删除不必要的那个。
  • This config allows you to use a web browser to manage CUPS, eg set up printers, manage jobs, via "http://PRINTSERVERNAME:631/".
  • 这个配置允许你通过"http://PRINTSERVERNAME:631/"的形式使用WEB浏览器管理CUPS,例如启动打印机,管理打印作业。
  • Restart CUPS
  • 重启CUPS
    • After changing this file, restart CUPS by running ...
    • . 在改变这个配置文件后,通过运行以下命令或使用Gnome菜单的系统->管理里面的服务工具重启CUPS。
sudo /etc/init.d/cupsys restart

or use the Services tool under Gnome menu System -> Administration. After CUPS is restarted the printers will immediately be found automatically by machines that are set up as per the next sections.

    • 在CUPS重新启动后,其打印机将立即自动被每一台按照下面说明进行设置的计算机发现。

Ubuntu Client Machine(Ubuntu 客户端计算机)

  • 这是指你在上面工作并希望从这里发送打印作业的计算机。
  • 重新配置CUPS
    • CUPS客户端:/etc/cups/cupsd.conf 使用如下文件。它的特点是包含注释。
# /etc/cups/cupsd.conf
# Simple CUPS configuration file for a pure client machine:
# which has:
# - no printers of its own, (or any local printers will not be shared?)
# - no need for security within the machine, ie a personal workstation
# - a network connection to a local network, where it will find CUPS-controlled printer servers

# This setup also allows access to the "Administrative tasks" system at
# http://localhost:631
# File based on Ubuntu 5.10 (Breezy Badger) (Linux version 2.6.12-10-386)
# Server Directives are explained in http://localhost:631/sam.html

# 25/04/2006
# [email protected]

ConfigFilePerm 0600
LogLevel info
Printcap /var/run/cups/printcap
RunAsUser Yes
### Listen fails. Use Port
#Listen 127.0.0.1:631
#Listen 10.0.0.0/8:631
#Listen 128.0.0.0/16:631
#Listen 192.168.0.0/24:631
Port 631

### Which print servers to use
Include cupsd-browsing.conf
BrowseOrder deny,allow
BrowseDeny from All
BrowseAllow from @LOCAL
BrowseAllow from 10.0.0.0/8
BrowseAllow from 172.16.0.0/12
BrowseAllow from 192.168.0.0/16

<Location />
AuthType None
Order Deny,Allow
Deny From All
Allow From @LOCAL
</Location>

<Location /jobs>
AuthType None
Order Deny,Allow
Deny From All
Allow From @LOCAL
</Location>

<Location /printers>
AuthType None
Order Deny,Allow
Deny From All
Allow From @LOCAL
</Location>

<Location /admin>
AuthType None
Order Deny,Allow
Deny From All
Allow From @LOCAL
</Location>
  • 重启CUPS
    • 在对文件进行你需要的改造后,通过运行以下命令或使用Gnome菜单的系统->管理里面的服务工具重启CUPS。
sudo /etc/init.d/cupsys restart

CUPS重新启动后,文件服务器上的(按照上面打印服务器一节进行配置的)打印机将被你的计算机自动发现。他们将出现在你的“打印机”屏幕上。虽然这可能要花费30秒的时间。

如果你希望你的计算机能打印到另一台装有打印机的Ubuntu主机(也是其他计算机的打印服务器),你需要创建将上述两个cupsd.conf 结合在一起的文件。

Windows Client Machine(Windows 客户端计算机)

  • 通过使用Windows“添加打印机”向导将打印机添加到Windows客户端。在打印机URL中输入如下内容:
    http://PRINTSERVERNAME:631/printers/PRINTERNAME
  • PRINTSERVERNAME是打印服务器的名称或IP地址,
  • PRINTERNAME是打印服务器上分配给打印机的名称。

Common Problems(常见问题)

  • 打印作业停留在客户端计算机上并且没有被打印。 运行命令
lpstat -p -d

If it reports something like ... 如果它出现象下面这样的报告

printer HP-OfficeJet-D155 is idle.  enabled since Jan 01 00:00
Network host 'alice' is busy; will retry in 30 seconds...

or it reports something like ... 或它的报告象下面这样

printer [email protected] is idle.  enabled since Jan 01 00:00
Unable to get printer status (client-error-forbidden)!
system default destination: [email protected]
  • 你的客户端计算机不能获得服务器上的打印机信息。在每个问题中都试着使用如上所述的"/etc/cups/cupsd.conf" 文件并重启CUPS.

  • 本信息目前支持Ubuntu 5.10 (Breezy Badger)