16

It is easy to list the printers you've already installed with this command:

lpstat -a

However, this does not list network printers you have NOT installed.

nmap will scan for all open ports on the LAN, but the list produced won't be limited to network printers:

sudo nmap -sT 192.168.0.1-254

Is there a command that does the following:

  1. Detects the LAN you're currently connected to automatically.
  2. Scans the entire LAN looking for Network Printers specifically.
  3. Produces a list of Network Printers providing both their hostnames and IP addresses.

For example, I logged into the web interface of a Imagistics fx2100 printer today. It had a "Find device" feature that was capable of finding all the network printers on the LAN (see screenshot below). Notice that this Imagistics printer's built-in utility found printers of all brands (NOT just Imagistic ones).

It seems like there would be a command in Linux that could achieve the same list and info (without scripting):

enter image description here

3
  • 2
    The problem here is that the criteria ("Network Printer") is something that only makes sense to humans. Computer programs aren't going to have a clear sense of that idea. You might try doing a network sweep for IP addresses that successfully connect on the JetDirect port (tcp/9100). The list is still likely to be incomplete in the case of non-JetDirect printers such as desktop printers shared over SMB.
    – Bratchley
    Commented Jun 30, 2014 at 18:16
  • 1
    As you mention, a program can scan open ports of each IP on the LAN, and even do a little talking to those ports to gather data. I understand how this could be done. I'm just unaware of any command line utility that already does this (specifically for printers). Commented Jun 30, 2014 at 18:44
  • 1
    You can do sweeps to find a list of valid IP addresses and use nc to verify that it can connect on tcp/9100. You'd have to script something since this is a very specific problem you're trying to solve. So I doubt anyone's written a tool to do this.
    – Bratchley
    Commented Jun 30, 2014 at 19:33

3 Answers 3

18

If avahi-daemon is running then,

avahi-browse -a | grep Printer
2
  • 1
    This avahi-browse -a command seems to list the same printers multiple times and (even with the --all argument) it leaves out pertinent information that's shown in the screen shot above (like the ip address of the printer it is listing). It amazes me that this "Imagistics fx2100 printer" contains firmware that beats every Linux utility I've seen, when it comes to listing all printers of all brands (that are not even installed, but are providing network printing). Commented Oct 4, 2019 at 11:40
  • 1
    @Lonniebiz If you don't grep for 'Printer', then you'll get useful info including the IP address. With sed, you can use avahi-browse -t -d local -c -a --resolve | sed -n '/^=.*Printer/,/txt =/p' to select all blocks of lines that pertain to printers.
    – Jellicle
    Commented Dec 22, 2020 at 0:13
3

There isn’t a program that does this specifically, but with nmap -A (advanced host detection/fingerprinting) may be able to identify most printers. You’re going to have to filter it after.

1
lpstat -l -e

Excerpt from man lpstat:

   -e   Shows all available destinations on the local network.

   -l   Shows a long listing of printers, classes, or jobs.
1
  • I just tried your suggestion. Unlike the Imagistics fx2100 utility, I screenshotted in my question, this command only locates ONE of the many (not installed) network printers on the LAN. Plus, it lacks a lot of other pertinent info shown in the screenshot. It was worth trying though. Thanks. Commented May 30 at 12:37

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .