Local and remote printers

What if we now want to move one of the two printers (say lpt2) from node1 to node2?

We have to change the /etc/printcap file on both nodes. Likewise, we need to change /etc/printcap on any other network nodes we wished to print from:

Make sure you have entries for node1 and node2 in the /etc/hosts file on each node. You also need entries in the /etc/hosts.lpd file on node1 and node2 for each node that you want to be able to use the printers.

If you've set up your remote printing network according to the examples given, you should be able to send a file in /tmp/test on node2 to the printer attached to node1 using a command like this:

lpr -h -Plpt1 /tmp/test

Here's what happens:

  1. You enter the lpr command to print a file remotely.
  2. The lpr utility requests printing service.
  3. The lpd daemon on node2 hears the request, spawns a copy of itself to service the request, and then creates a spooling subdirectory to hold the files to be printed.
  4. The spawned lpd daemon places the print job in the spooler as two files: a data file containing the file to be printed and a header file containing information about the print job (to be printed as an optional front sheet).
  5. The spawned lpd daemon processes the spooled print jobs in the order they were received; it starts sending data packets containing the print job to the remote lpd daemon.
  6. The lpd daemon on node1 receives the packets as a printing request, and after checking that the request is from an approved node, spawns a copy of itself to service the request and also creates a spooling subdirectory to hold the files to be printed. (If the request isn't from an approved source, a refusal message is sent back to the source address.)
  7. The spawned lpd collects the data packets, places the print job into the spooler queue, and then sends the print jobs, in the order they were received, to the printer you specified.