https://wiki.archlinux.org/index.php/CUPS/Printer_sharing_(简体中文)

 

GNU/Linux系统间共享

在作为打印服务器的GNU/Linux系统(服务器端)上安装好CUPS之后,建议您通过网页操作界面与另一个GNU/Linux系统(客户端)共享打印机;当然您也可以选择手动操作共享。

在启动cupsd之前,您需要保证avahi-daemon处于运行状态。

您的客户端需要支持Avahi主机名解析,否则客户端可能报错称“找不到打印机”("Unable to locate printer")。详情请参考avahi#Hostname resolution。

使用网页操作界面

用浏览器访问CUPS管理页面:http://localhost:631

点击页面上方的Administration按钮, 在Printer下选择“add printer”,将会自动检测已连接的打印机。如果打印机无法被检测,请尝试将打印机重启后重新检测。

打印机设置好之后,将Server下的"Share printers connected to this system"改为选中状态,然后点击下方的change settings保存修改。这时打印服务器将自动重启。

选择"Edit Configuration File"即可直接修改配置文件cups.conf。通过修改文件您可以选择仅将打印机共享到特定用户或IP地址,下文中有详细说明。

手动操作

在打印服务器端(即与打印机直接相连的那端)编辑配置文件 /etc/cups/cupsd.conf,使共享打印机的系统能连接到服务器端。比如添加如下内容:

<Location />
Order allow,deny
Allow localhost
Allow 192.168.0.*
</Location>

其中“Allow”后面为允许与打印服务器相连的系统。"Allow all"将允许局域网内所有系统与打印服务器连接。

此外我们需要保证服务器端正在监听客户端所在的IP地址。在"# Listen <serverip>:631"之后添加如下内容(注意:“Listen”后面为服务器的IP地址,而非客户端IP地址):

Listen 192.168.0.101:631

为了“让打印机在局域网中可见”("Show shared printers on the local network"),请添加如下内容以保证Browsing指令可以使用:

Browsing On

完成修改后重启CUPS。

在客户端的/etc/cups/client.conf文件中(如果文件不存在则新建)新建一行,将服务器的名称或IP地址添加到"ServerName"(服务器名称)后面:

ServerName 192.168.0.101

还有很多其他可行的配置方式,在http://localhost:631/help/network.html 中有详细介绍。

完成修改后重启CUPS。

注意: 在客户端添加打印机时,如果采用的是IPP协议(Internet Printing Protocol), 请采用如下形式的URI: ipp://192.168.0.101:631/printers/<打印机名称>

如果您的客户端CUPS版本为1.6.x而服务器端CUPS版本<= 1.5.x

在CUPS 1.6及其之后的版本中, 客户端默认采用IPP 2.0。如果服务器端的CUPS版本<=1.5/IPP版本<= 1.1,由于客户端不会自动使用较早版本的通信协议,客户端将无法与服务器端交流。一个可行的方法是在/etc/cups/client.conf中添加如下内容(此方法于2013-05-07被指有误, 可以参考错误报告):

ServerName HOSTNAME-OR-IP-ADDRESS[:PORT]/version=1.1
 

Between GNU/Linux and Windows

Linux server - Windows client

Sharing via IPP

The preferred way to connect a Windows client to a Linux print server is using IPP. It is a standard printer protocol based on HTTP, allowing you all ways to profit from port forwarding, tunneling etc. The configuration is very easy and this way is less error-prone than using Samba. IPP is natively supported by Windows since Windows 2000.

To configure the server side proceed as described in the section above to enable browsing.

On the Windows computer, go to the printer control panel and choose to 'Add a New Printer'. Next, choose to give a URL. For the URL, type in the location of the printer:

http://host_ip_address:631/printers/printer_name

(where host_ip_address is the GNU/Linux server's IP address and printer_name is the name of the printer being connected to, you can also use the server's fully qualified domain name, if it has one, but you may need to set ServerAlias my_fully_qualified_domain_name in cupsd.conf for this to work).

Note: The add printer dialog in windows is quite sensitive to the path to the printer, the dialogue box itself suggests:

http://servername:631/printers/printer_name/.printer

which will work in a web-browser but not in the add printer dialogue. (At least, not when using cups as an ipp server). The syntax suggested above:

http://host_ip_address:631/printers/printer_name

will work.

After this, install the native printer drivers for your printer on the Windows computer. If the CUPS server is set up to use its own printer drivers, then you can just select a generic postscript printer for the Windows client(e.g. 'HP Color LaserJet 8500 PS' or 'Xerox DocuTech 135 PS2'). Then test the print setup by printing a test page.

Sharing via Samba

If your client's Windows version is below Windows 2000 or if you experienced troubles with IPP you can also use Samba for sharing. Note of course that with Samba this involves another complex piece of software. This makes this way more difficult to configure and thus sometimes also more error-prone, mostly due to authentication problems.

To configure Samba on the Linux server, edit /etc/samba/smb.conf file to allow access to printers. File smb.conf can look something like this:

/etc/samba/smb.conf
[global]
workgroup=Heroes
server string=Arch Linux Print Server
security=user [printers]
comment=All Printers
path=/var/spool/samba
browseable=yes
# to allow user 'guest account' to print.
guest ok=no
writable=no
printable=yes
create mode=0700
write list=@adm root yourusername

That should be enough to share the printer, yet adding an individual printer entry may be desirable:

/etc/samba/smb.conf
[ML1250]
comment=Samsung ML-1250 Laser Printer
printer=ml1250
path=/var/spool/samba
printing=cups
printable=yes
printer admin=@admin root yourusername
user client driver=yes
# to allow user 'guest account' to print.
guest ok=no
writable=no
write list=@adm root yourusername
valid users=@adm root yourusername

Please note that this assumes configuration was made so that users must have a valid account to access the printer. To have a public printer, set guest ok to yes, and remove the valid users line. To add accounts, set up a regular GNU/Linux account and then set up a Samba password on the server. For instance:

# useradd yourusername
# smbpasswd -a yourusername

After this, restart the Samba daemon.

Obviously, there are a lot of tweaks and customizations that can be done with setting up a Samba print server, so it is advised to look at the Samba and CUPS documentation for more help. The smb.conf.example file also has some good samples that might warrant imitating.

Windows server - Linux client

Warning: CUPS cannot handle spaces in printer URIs. If your Windows printer name or user passwords have spaces, CUPS will throw "lpadmin: Bad device-uri" error

Sharing via LPD

Windows 7 has a built-in LPD server - using it will probably be the easiest approach as it does neither require an installation of Samba on the client nor heavy configuration on the server. It can be activated in the Control Panel under Programs -> Activate Windows functions in the section Print services. The printer must have shared activated in its properties. Use a share name without any special characters like spaces, commas, etc.

Then the printer can be added in CUPS, choosing LPD protocol. The printer address will look like this:

# lpd://windowspc/printersharename

Before adding the printer, you will most likely have to install an appropriate printer driver depending on your printer model. Generic PostScript or RAW drivers might also work.

Sharing via IPP

As above, IPP is also the preferred protocol for printer sharing. However this way might be a bit more difficult than the native Samba approach below, since you need a greater effort to set up an IPP-Server on Windows. The commonly chosen server software is Microsoft's Internet Information Services (IIS).

Note: This section is incomplete. Here is a description how to set up ISS in Windows XP and Windows 2000, unfortunately in German [1]

Sharing via Samba

much simpler way is using Window's native printer sharing via Samba. There is almost no configuration needed, and all of it can be done from the CUPS Backend. As above noted, if there are any problems the reason is mostly related to authentication trouble and Windows access restrictions.

On the server side enable sharing for your desired printer and ensure that the user on the client machine has the right to access the printer.

The following section describes how to set up the client, assuming that both daemons (cupsd and smbd) are running.

Configuration using the web interface

The Samba CUPS back-end is enabled by default, if for any reason it is not activate it by entering the following command and restarting CUPS.

# ln -s $(which smbspool) /usr/lib/cups/backend/smb

Next, simply log in on the CUPS web interface and choose to add a new printer. As a device choose "Windows Printer via SAMBA".

For the device location, enter:

smb://username:password@hostname/printer_name

Or without a password:

smb://username@hostname/printer_name

Make sure that the user actually has access to the printer on the Windows computer and select the appropriate drivers. If the computer is located on a domain, make sure the user-name includes the domain:

smb://username:password@domain/hostname/printer_name

If the network contains many printers you might want to set a preferred printer. To do so use the web interface, go into the printer tab, choose the desired printer and select 'Set as default' from the drop-down list.

Manual configuration

For manual configuration stop the CUPS daemon and add your printer to /etc/cups/printers.conf, which might for example look like this

/etc/cups/printers.conf
<DefaultPrinter MyPrinter>
AuthInfoRequired username,password
Info My printer via SAMBA
Location In my Office
MakeModel Samsung ML-1250 - CUPS+Gutenprint v5.2.7 # <= use 'lpinfo -m' to list available models
DeviceURI smb://username:password@hostname/printer_name # <= server URI as described in previous section
State Idle
Type 4
Accepting Yes
Shared No
JobSheets none none
QuotaPeriod 0
PageLimit 0
KLimit 0
AllowUser yourusername # <= do not forget to change this
OpPolicy default
ErrorPolicy stop-printer
</Printer>

Then restart the CUPS daemon an try to print a test page.

To set the preferred printer use the following command

# lpoptions -d desired_default_printer_name
 

Troubleshooting

 

CUPS/Printer sharing的更多相关文章

  1. Linaro/Yocto/Openwrt

    http://en.wikipedia.org/wiki/Linaro Linaro From Wikipedia, the free encyclopedia     This article ap ...

  2. gentoo use-flag 全局标识 大全 (官方搬运) 英文 适用funtoo

    连接 https://www.gentoo.org/support/use-flags/ 提示 ctrl+F 可在页面查找 搬运 Global USE flags FlagDescription 3d ...

  3. ASP.NET Core 中文文档 第二章 指南(5) 在 Nano Server 上运行ASP.NET Core

    原文 ASP.NET Core on Nano Server 作者 Sourabh Shirhatti 翻译 娄宇(Lyrics) 校对 刘怡(AlexLEWIS).许登洋(Seay).谢炀(kile ...

  4. Samba Server 配置

    1.Issue:Server requested plaintext password but 'client plaintext auth' is disabled   session setup ...

  5. windows防火墙命令详解

    Old command 针对win7以下版本<包含win7> Example 1: 启用一个程序 Old command New command netsh firewall add al ...

  6. wmi详解,RPC和防火墙

    135端口:Microsoft在这个端口运行DCE RPC end-point mapper为它的DCOM服务.这与UNIX 111端口的功能很相似.使用DCOM和RPC的服务利用计算机上的end-p ...

  7. 自动化测试UI Test, Performance Test, Load Test 总结整理

    MSDN: 测试应用程序,Test apps early and often ,Improve Code Quality 推荐书: <Visual Studio 2015高级编程> < ...

  8. Nginx+Tomcat+Memcached负载均衡集群服务搭建

    操作系统:CentOS6.5  本文档主要讲解,如何在CentOS6.5下搭建Nginx+Tomcat+Memcached负载均衡集群服务器,Nginx负责负载均衡,Tomcat负责实际服务,Memc ...

  9. How to enable $Admin Shares in Windows 7

    Quote from: http://www.wintips.org/how-to-enable-admin-shares-windows-7/ As “Administrative shares” ...

随机推荐

  1. 嗜血法医第八季/全集Dexter 8迅雷下载

    嗜血法医 第八季 Dexter Season 8 (2013) 本季看点:来自Showtime电视网的连环杀人犯<嗜血法医>Dexter作为今夏最重磅的剧集之一,已经于当地时间6月30日回 ...

  2. libcurl下载文件

    一.初始化 CURL *pHandler = curl_easy_init();   二.设置请求参数: 调用curl_easy_setopt方法,设置选项 curl_easy_setopt(pHan ...

  3. PHP获取指定函数定义在哪个文件中及行号

    当调试开源的代码时,希望查看某个函数的定义,那么就需要定位其位置.特别是有的项目中,函数会有多个地方都有定义,那么如果我想知道当前调用的这个函数是在哪里定义的,可以用下面这个方法. function ...

  4. [转]Sqoop-1.4.4工具import和export使用详解

    FROM :http://shiyanjun.cn/archives/624.html Sqoop可以在HDFS/Hive和关系型数据库之间进行数据的导入导出,其中主要使用了import和export ...

  5. 【ContestHunter】【弱省胡策】【Round0】(A)&【Round1】(B)

    DP+容斥原理or补集转化?/KD-Tree 唔……突然发现最早打的两场(打的最烂的两场)没有写记录……(太烂所以不忍记录了吗... 还是把搞出来了的两道题记录一下吧= =勉强算弥补一下缺憾…… Ro ...

  6. 用SLF4j/Logback打印日志-2

    本篇主要介绍logback的输出源配置,logback默认提供了很多输出源,但是用的最多的是这几种: OutputStreamAppender 日志输出到一个二进制流,可以通过 <encoder ...

  7. maven与jdk版本不一致报:Unsupported major.minor version 51.0

    I recently uninstalled Java 8, to use Java 6 as I want my code/creations to be usable by more people ...

  8. Go语言之进阶篇爬捧腹网

    1.爬捧腹网 网页规律: https://www.pengfu.com/xiaohua_1.html   下一页 +1 https://www.pengfu.com/xiaohua_2.html 主页 ...

  9. 深挖android low memory killer

    对于PC来说,内存是至关重要.如果某个程序发生了内存泄漏,那么一般情况下系统就会将其进程Kill掉.Linux中使用一种名称为OOM(Out Of Memory,内存不足)的机制来完成这个任务,该机制 ...

  10. 在TensorFlow中基于lstm构建分词系统笔记

    在TensorFlow中基于lstm构建分词系统笔记(一) https://www.jianshu.com/p/ccb805b9f014 前言 我打算基于lstm构建一个分词系统,通过这个例子来学习下 ...