Difference between revisions of "Setting up Network Printer Ports"

From SambaWiki
m (Mmuehlfeld moved page Network Printer Ports to Configure network printer ports: Rename page for better wiki structure)
m (Updated category name)
 
(5 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
= Introduction =
 
= Introduction =
   
The concept of a "port" is fairly foreign to UNIX hosts. Under Windows print servers, a port is associated with a port monitor and generally takes the form of a local port (i.e. LPT1:, COM1:, FILE:) or a remote port (i.e. LPD Port Monitor, etc...). By default, Samba has only one port defined "Samba Printer Port". Under Windows, all printers must have a valid port name.
+
In Windows, printers must have a port assigned. This can be a local port, such as <code>LPT1</code>, or for example for a remote port, <code>LPD Port Monitor</code>. Per default, Samba auto-generates the <code>Samba Printer Port</code> for all shared printers. However, in certain scenarios, you require to use unique port names.
   
Usually you don't have to change this behaviour. But in some situations, it might be necessary, like when Windows drivers try to send SNMP requests or automatic driver configuration requests towards to the printer.
 
   
If you wish to have a list of ports displayed (smbd does not use a port name for anything) other than the default "Samba Printer Port", you can define enumports command to point to a program/script which should generate a list of ports, one per line, to standard output. This listing will then be used in response to the level 1 and 2 EnumPorts() RPC.
 
   
   
   
  +
= How Samba Provides Custom Ports to the Windows Hosts =
   
  +
Samba enables you to use a script that outputs only the port names:
   
  +
* The script can only output the port names by using <code>echo</code> commands. For example:
= Setup Printer Ports =
 
   
* Write a script (e. g. /usr/local/bin/show-ports.sh), that prints the name/IPs of the printers, one per line, to standard output:
 
 
#!/bin/bash
 
#!/bin/bash
 
echo "DemoPrinter1"
 
echo "DemoPrinter1"
 
echo "DemoPrinter2"
 
echo "DemoPrinter2"
 
echo "DemoPrinter3"
 
echo "DemoPrinter3"
:Of course you don't have to simply „echo“ these entries. They can be retrieved from other sources and printed, too.
 
   
  +
* You can write a script that generates the port names from configuration files, databases, or other sources.
* Make the script executable
 
chmod 755 /usr/local/bin/show-ports.sh
 
   
  +
{{Imbox
* Add the following line to the [global] section of your smb.conf:
 
  +
| type = important
enumports command = /usr/local/bin/show-ports.sh
 
  +
| text = Every line the script outputs is used as a printer port. Make sure that the script does not output other content.
  +
}}
  +
  +
  +
  +
  +
 
= Setting up Printer Ports =
  +
  +
To enable Samba to display individual printer ports:
  +
  +
* Create a shell script. For example, <code>/usr/local/bin/samba-ports.sh</code> that outputs each port in a new line. For details, see [[#How_Samba_Provides_Custom_Ports_to_the_Windows_Hosts|How Samba Provides Custom Ports to the Windows Hosts]].
  +
 
* Make the script executable:
  +
 
# chmod 755 /usr/local/bin/samba-ports.sh
  +
 
* Add the following parameter to the <code>[global]</code> section in your <code>smb.conf</code> file:
  +
 
enumports command = /usr/local/bin/samba-ports.sh
  +
 
* Reload Samba:
   
* Reload Samba
 
 
# smbcontrol all reload-config
 
# smbcontrol all reload-config
   
* The port entries generated by the script are visable and selectable in the printers properties on the print server (e. g. via printmanagement.msc).
+
The ports are now usable in the properties when preconfiguring a printer.
:[[Image:Printer_Ports.png]]
 
   
 
[[Image:Printer_Ports.png]]
   
  +
For details, see [[Setting_up_Automatic_Printer_Driver_Downloads_for_Windows_Clients#Preconfiguring_a_Printer|Preconfiguring a Printer]].
   
   
   
= Additional Notes =
 
   
* Changes done afterwards in the script doesn't require reloading Samba.
 
   
  +
----
* If a port, associated with a printer, changes afterwards in the scripts output, will cause loosing this association!
 
  +
[[Category:Active Directory]]
  +
[[Category:Domain Members]]
  +
[[Category:NT4 Domains]]
  +
[[Category:Printing]]
  +
[[Category:Standalone Server]]

Latest revision as of 21:14, 26 February 2017

Introduction

In Windows, printers must have a port assigned. This can be a local port, such as LPT1, or for example for a remote port, LPD Port Monitor. Per default, Samba auto-generates the Samba Printer Port for all shared printers. However, in certain scenarios, you require to use unique port names.



How Samba Provides Custom Ports to the Windows Hosts

Samba enables you to use a script that outputs only the port names:

  • The script can only output the port names by using echo commands. For example:
#!/bin/bash
echo "DemoPrinter1"
echo "DemoPrinter2"
echo "DemoPrinter3"
  • You can write a script that generates the port names from configuration files, databases, or other sources.



Setting up Printer Ports

To enable Samba to display individual printer ports:

  • Make the script executable:
# chmod 755 /usr/local/bin/samba-ports.sh
  • Add the following parameter to the [global] section in your smb.conf file:
enumports command = /usr/local/bin/samba-ports.sh
  • Reload Samba:
# smbcontrol all reload-config

The ports are now usable in the properties when preconfiguring a printer.

Printer Ports.png

For details, see Preconfiguring a Printer.