CUPS&samba+CUPS为Linux安装打印机并共享给Windows
解决的不是太完美,不能共享给Internet,曾经发过疑问贴,也被热心的管理员很好地解答了,但没解决问题。
经过查询,应该是CUPS的一个BUG,不是nat123的原因,因为输入管理页面的地址后在浏览器可以很好地出现400错
这是BUG贴
帖子说在cupsd.conf文件尾部增加“ServerAlias *”就解决了,但经过实际操作并没有什么♀用
另外经过实测不用samba也可以,在CUPS管理页面勾选“Allow printing from the Internet”和“Allow remote administration”
配置文件改成下面这样,我的CUPS版本是1.5.3
代码似乎不能标红,夹在<font color="Red"></ font>中间的是改动的部分
LogLevel warn MaxLogSize 1m # Allow remote access <font color="Red">Port *:631</font> Listen /var/run/cups/cups.sock Browsing On BrowseOrder allow,deny <font color="Red">BrowseAllow All</font> BrowseRemoteProtocols cups ldap slp BrowseAddress *:631 BrowseLocalProtocols cups dnssd ldap slp DefaultAuthType Basic WebInterface Yes <Location /> # Allow remote administration... Order allow,deny <font color="Red">Allow all</font> </Location> <Location /admin> # Allow remote administration... Order allow,deny <font color="Red">Allow all</font> </Location> <Location /admin/conf> AuthType Default Require user @SYSTEM # Allow remote access to the configuration files... Order allow,deny <font color="Red">Allow all</font> </Location> <Policy default> JobPrivateAccess default JobPrivateValues default SubscriptionPrivateAccess default SubscriptionPrivateValues default <Limit Create-Job Print-Job Print-URI Validate-Job> Order deny,allow </Limit> <Limit Send-Document Send-URI Hold-Job Release-Job Restart-Job Purge-Jobs Set-Job-Attributes Create-Job-Subscription Renew-Subscription Cancel-Subscription Get-Notifications Reprocess-Job Cancel-Current-Job Suspend-Current-Job Resume-Job Cancel-My-Jobs Close-Job CUPS-Move-Job CUPS-Get-Document> Require user @OWNER @SYSTEM Order deny,allow </Limit> <Limit CUPS-Add-Modify-Printer CUPS-Delete-Printer CUPS-Add-Modify-Class CUPS-Delete-Class CUPS-Set-Default CUPS-Get-Devices> AuthType Default Require user @SYSTEM Order deny,allow </Limit> <Limit Pause-Printer Resume-Printer Enable-Printer Disable-Printer Pause-Printer-After-Current-Job Hold-New-Jobs Release-Held-New-Jobs Deactivate-Printer Activate-Printer Restart-Printer Shutdown-Printer Startup-Printer Promote-Job Schedule-Job-After Cancel-Jobs CUPS-Accept-Jobs CUPS-Reject-Jobs> AuthType Default Require user @SYSTEM Order deny,allow </Limit> <Limit Cancel-Job CUPS-Authenticate-Job> Require user @OWNER @SYSTEM Order deny,allow </Limit> <Limit All> Order deny,allow </Limit> </Policy> <Policy authenticated> JobPrivateAccess default JobPrivateValues default SubscriptionPrivateAccess default SubscriptionPrivateValues default <Limit Create-Job Print-Job Print-URI Validate-Job> AuthType Default Order deny,allow </Limit> <Limit Send-Document Send-URI Hold-Job Release-Job Restart-Job Purge-Jobs Set-Job-Attributes Create-Job-Subscription Renew-Subscription Cancel-Subscription Get-Notifications Reprocess-Job Cancel-Current-Job Suspend-Current-Job Resume-Job Cancel-My-Jobs Close-Job CUPS-Move-Job CUPS-Get-Document> AuthType Default Require user @OWNER @SYSTEM Order deny,allow </Limit> <Limit CUPS-Add-Modify-Printer CUPS-Delete-Printer CUPS-Add-Modify-Class CUPS-Delete-Class CUPS-Set-Default> AuthType Default Require user @SYSTEM Order deny,allow </Limit> <Limit Pause-Printer Resume-Printer Enable-Printer Disable-Printer Pause-Printer-After-Current-Job Hold-New-Jobs Release-Held-New-Jobs Deactivate-Printer Activate-Printer Restart-Printer Shutdown-Printer Startup-Printer Promote-Job Schedule-Job-After Cancel-Jobs CUPS-Accept-Jobs CUPS-Reject-Jobs> AuthType Default Require user @SYSTEM Order deny,allow </Limit> <Limit Cancel-Job CUPS-Authenticate-Job> AuthType Default Require user @OWNER @SYSTEM Order deny,allow </Limit> <Limit All> Order deny,allow </Limit> </Policy> BrowseWebIF Yes ServerAlias *
添加成功后,在windows添加网络打印机,输入地址"http://ip:631/printers/打印机名"就可以添加了,驱动自己选w
====================================接下来是samba+CUPS的方法====================================
继续学习,这次是在树莓派把联想LJ2400的USB打印机装上,然后就可以共享了,I'm lovein' 共享w
原理是samba共享+CUPS的打印管理,亲测可用!因为联想LJ2400并没有Linux版驱动,所以驱动不正确,但据说他们的产品是仿 Brother的,所以我选择了Brother HL-2140 Foomatic/hl1250的驱动,测试页成功。在Windows端安装LJ2400的驱动就可以了。
下面是过程:
安装配置CUPS
先安装必要的包
sudo apt-get install cups cups-pdf cups-bsd
确认CUPS正在运行
ps -ef | grep cups
给账户pi赋予修改权限
sudo usermod -a -G lpadmin pi
修改配置文件
sudo nano /etc/cups/cupsd.conf
修改
Listen localhost:631
变成
Listen 631
有Location的部分,在最后增加一句
<Location /> allow @LOCAL </Location>
重启服务
service cups restart
增加打印机的阶段
在浏览器输入
https://树莓派IP:631/admin
点击“Add Printer ”,开始添加!选好要共享的那台打印机以后随便填吧,共享默认是勾上的。
驱动方面,可以上Brother和联想官网对比一下联想和Brother的外观和型号序列,基本上是对应的。我选了Brother的“Brother HL-2140 Foomatic/hl1250”
配置好以后可以在“Printers"看到刚才加的打印机了,点开之后,Mantenance下拉可以打印测试页,Administration可以设置打印机和用户。
打印机方面的配置就结束了,接下来是共享。
安装samba
sudo apt-get install samba samba-common
更改samba配置文件:
sudo nano /etc/samba/smb.conf
共享打印机:
[printers] comment = All Printers browseable = no path = /var/spool/samba printable = yes guest ok = yes read only = yes create mask = 0700
可以在网上邻居找到打印机了,格式:
\树莓派IP
双击打印机,手动安装联想驱动。
又解放了一个USB口w
参考文献:
用树莓派做WiFi打印机
Linux和windows之间文件和打印共享方法
评论