LPRng-HOWTO: Client To Server Connection Information

Next Previous Contents

## 7. Client To Server Connection Information

The LPRng software is a true set of client/server applications. The LPRng clients, `lpr, lprm, lpq,` and `lpc` connect to a `lpd` server using a TCP/IP connection. This means that you must have TCP/IP networking enabled on your workstation to use LPRng.

However, you do not need to have an external network connection to the Internet. For most single system users, the `lpd` server is running on the same workstation as the client program, and the clients will simply talk to the `localhost`.

## 7.1 Printer Name and Server IP Address

Options used:

- `PRINTER` Environment variable
- `force_localhost` force clients to send requests to localhost
- `default_printer_when_unknown` used by LPD when printer name not in printcap

When an LPRng client such as `lpr`, `lpq`, `lprm`, or `lprc` needs to communicate with a print server, the only information they normally need is:

1. The spool queue or remote printer to be used in requests to the `lpd` print server. This is sometimes referred to as the printer or print queue name.
2. The IP address or hostname of the print server or remote server. This is sometimes called the remote host or simply server.
3. Options that control how jobs or commands are transferred to the server host. These options might include encryption and client side job filtering. We will discuss these capabilities later.

LPRng has several ways to specify the printer queue and server information.

### Command Line -Pprinter@host

The `-P printer@host` option specifies both the print queue and server.

> `

>     lpr -Plaser@10.0.0.1
>     lpq -Plp@myserver

> `

When used as a command line option, the printcap database will not be consulted for other options or information. This allows LPRng clients to function without a printcap database, and without a `lpd` print server running on their local host. However, options set in the `/etc/lpd.conf/` and the compile time defaults will still be used.

### Command Line -Pprinter

This form will cause the LPRng clients to look in the `/etc/printcap` for a printcap entry with the name or alias `printer` and use the information in that printcap entry. We will discuss the format of the printcap entry in a moment. Example:

> `

>     lpr -Plp

> `

### PRINTER Environment Variable

If no command line option is specified, the LPRng clients will check for a `PRINTER` environment variable value and will use it as though specified as a `-P$PRINTER` command line option.

If the $PRINTER value has the form `printer@host` the print queue will be `printer` on server `host` and not consult the printcap database. If the $PRINTER value has the form `printer` then the printcap will be searched for a `printer` printcap entry. For example:

> `

>     export PRINTER=laser@10.0.0.1; lpr
>     export PRINTER=pr; lpr

> `

### Default Printer From Printcap

If you do not specify a printer on the command line or in the `PRINTER` environment variable, then LPRng will search the printcap and use the first valid printcap entry as the printer.

### Default Printer When No Printcap

If you do not have a `/etc/printcap` file, then LPRng will use the `default_printer` and `default_remote_host` fallback values set in the `/etc/lpd.conf` file or by the compile time defaults.

Using the fallback values is usually not a desirable event and may indicate that you have a misconfigured host, so the fallback values are usually set by administrators to `missingprinter@localhost` to provoke an annoying message for users.

### LPD Default Printer

For completeness, there is even a `default_printer_when_unknown` configuration entry for use by LPD when it is given a printer name not in its printcap database. By default, it will look up this name in the database and treat the job as though it was sent to this printer.

## 7.2 LPD Server Runnning on Localhost

Workstations for personal use or in extremely simple configurations will always run an `lpd` server on the localhost. This is the most common situation for the majority of new users, and the default LPRng installation sets the default value of the `force_localhost` configuration parameter to TRUE or to 1. The `lpr` `lpq` `lprm` and `lpc` will connect to `localhost` (usually IP address 127.0.0.1) unless explicitly overridden by the command line `-Pprinter@host` argument.

Larger sites or organizations which want to use a central print server to handle multiple printers or printer sharing may want the clients to connect directly to the server. In this case the system administrator should set `force_localhost@` in the `/etc/lpd.conf` or modify the compile time default. See Simple Client Printcap Entry for ways to change this.

Next Previous Contents