Setting up Network Printer Ports: Difference between revisions
From SambaWiki
Mmuehlfeld (talk | contribs) m (Mmuehlfeld moved page Setting up Network Printer Port to Setting up Network Printer Ports without leaving a redirect) |
Mmuehlfeld (talk | contribs) (Rewrote documentation. Used clearer structure. Added some additional details, used updated image.) |
||
Line 1: | Line 1: | ||
= Introduction = |
= Introduction = |
||
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: |
|||
⚫ | |||
* 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. |
|||
:By adding echo "Samba Printer Port" to the above script, you wont lose the previous settings, just make sure you echo it once. |
|||
* You can write a script that generates the port names from configuration files, databases, or other sources. |
|||
⚫ | |||
⚫ | |||
{{Imbox |
|||
⚫ | |||
| type = important |
|||
⚫ | |||
| text = Every line the script outputs is used as a printer port. Make sure that the script does not output other content. |
|||
}} |
|||
⚫ | |||
⚫ | |||
* The port entries generated by the script are visable and selectable in the printers properties on the print server (e. g. via printmanagement.msc). |
|||
⚫ | |||
= 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! |
|||
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]]. |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
The ports are now usable in the properties when preconfiguring a printer. |
|||
⚫ | |||
For details, see [[Setting_up_Automatic_Printer_Driver_Downloads_for_Windows_Clients#Preconfiguring_a_Printer|Preconfiguring a Printer]]. |
Revision as of 01:10, 21 January 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.
![]() | 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,
/usr/local/bin/samba-ports.sh
that outputs each port in a new line. For details, see 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
[global]
section in yoursmb.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.
For details, see Preconfiguring a Printer.