Setting up Network Printer Ports

From SambaWiki
Revision as of 20:52, 24 August 2015 by Mmuehlfeld (talk | contribs) (Mmuehlfeld moved page Network Printer Ports to Configure network printer ports: Rename page for better wiki structure)


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.

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.

Setup Printer Ports

  • Write a script (e. g. /usr/local/bin/, that prints the name/IPs of the printers, one per line, to standard output:
echo "DemoPrinter1"
echo "DemoPrinter2"
echo "DemoPrinter3"
Of course you don't have to simply „echo“ these entries. They can be retrieved from other sources and printed, too.
  • Make the script executable
chmod 755 /usr/local/bin/
  • Add the following line to the [global] section of your smb.conf:
enumports command = /usr/local/bin/
  • Reload Samba
# 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).
Printer Ports.png

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!