1. Overview

In the world of Linux, navigating through the intricacies of networking is a common task for users and administrators alike. When it comes to network printers, one essential piece of information is the IP address, which is crucial for seamless communication between the Linux machine and the printer.

In this tutorial, we’ll explore the methods to get the IP address of a network printer in a Linux environment.

2. Why Identify the IP Address of the Network Printer?

Before we begin the journey of locating the IP address of the network printer, let’s briefly understand why it’s so crucial. The IP address is like the digital address of networked devices. Our Linux machine must know the address to connect seamlessly with the printer. It’s akin to knowing the phone number of the person we want to call.

The identification of IP addresses is fundamental for tasks ranging from sending print jobs to troubleshooting connectivity issues. In essence, obtaining the IP address is the key to unlocking a harmonious connection, making the printing experience on Linux efficient and frustration-free.

3. Identifying the IP Address of the Network Printer

First, we must ensure that the printer is turned on and connected to the same network as our Linux machine. This is fundamental for the two devices to communicate. If the printer is a part of our home or office network, we’re good to go for finding the IP address of the network printer.

3.1. Using nmap

nmap (Network Mapper), is a powerful, open-source tool for network exploration and security auditing. It allows us to discover devices and services on a computer network, identify open ports, and gather information for assessing potential vulnerabilities.

To find the network printer’s IP address, let’s perform an nmap scan over a network range with -sV for service version detection on open ports, and add –open to show only open ports, excluding information on filtered or closed ones:

$ nmap -sV 192.168.1.0/24 --open 
Starting Nmap 7.93 ( https://nmap.org ) at 2023-11-01 15:36 +0545
WARNING: Service 192.168.1.254:443 had already soft-matched rtsp, but now soft-matched sip; ignoring second value
Nmap scan report for 192.168.1.65
Host is up (0.024s latency).
Not shown: 889 closed tcp ports (conn-refused), 105 filtered tcp ports (no-response)
Some closed ports may be reported as filtered due to --defeat-rst-ratelimit
PORT    STATE SERVICE  VERSION
21/tcp  open  ftp      Brother/HP printer ftpd 1.13
23/tcp  open  telnet   Brother/HP printer telnetd
80/tcp  open  http     Debut embedded httpd 1.30 (Brother/HP printer http admin)
443/tcp open  ssl/http Debut embedded httpd 1.30 (Brother/HP printer http admin)
515/tcp open  printer
631/tcp open  http     Debut embedded httpd 1.30 (Brother/HP printer http admin)
Service Info: Device: printer
Nmap scan report for 192.168.1.78
Host is up (0.021s latency).
Not shown: 996 closed tcp ports (conn-refused), 2 filtered tcp ports (no-response)
Some closed ports may be reported as filtered due to --defeat-rst-ratelimit
PORT     STATE SERVICE VERSION
5000/tcp open  rtsp    AirTunes rtspd 675.4.1
7000/tcp open  rtsp    AirTunes rtspd 675.4.1
...

We performed an nmap scan on the IP range 192.168.1.0/24, focusing on hosts with open ports and their service versions. We can identify a printer at 192.168.1.65 with various open ports (21, 23, 80, 443, 515, 631) running services like FTP, Telnet, HTTP, SSL/HTTP, and printer services. In this case, the printer appears to be a Brother/HP device.

3.2. Using avahi-browse

Another tool to identify the IP Address of a Network printer is avahi-browse. The avahi-browse command-line tool uses the avahi daemon to discover and display services on a local network. It provides information about available services, including their types, hostnames, IP addresses, ports, and additional details.

Before trying to use avahi-browse, we need to install avahi-utils using apt-get if we haven’t already:

$ sudo apt-get install avahi-utils

Now, let’s use avahi-browse to find the IP Address of the network printer:

$ avahi-browse --all -t -r
+  wlan0 IPv4 Brother DCP-L2540DW series                    _privet._tcp         local
+  wlan0 IPv4 Brother DCP-L2540DW series                    Web Site             local
+  wlan0 IPv4 Brother DCP-L2540DW series                    _scanner._tcp        local
+  wlan0 IPv4 Brother DCP-L2540DW series                    Internet Printer     local
+  wlan0 IPv4 Brother DCP-L2540DW series                    UNIX Printer         local
=  wlan0 IPv4 Brother DCP-L2540DW series                    Internet Printer     local
   hostname = [BRWA8934A226E35.local]
   address = [192.168.1.65]
   port = [631]
   txt = ["print_wfds=T" "UUID=e3248000-80ce-11db-8000-b422007dbb90" "PaperMax=legal-A4" "kind=document,envelope,label" "URF=W8,CP1,IS4-1,MT1-3-4-5-8,OB10,PQ4,RS300-600,V1.3,DM1" "TBCP=F" "Transparent=T" "Binary=T" "PaperCustom=T" "Scan=T" "Fax=F" "Duplex=T" "Copies=T" "Color=F" "usb_CMD=PJL,PCL,PCLXL,URF" "usb_MDL=DCP-L2540DW series" "usb_MFG=Brother" "priority=25" "adminurl=http://BRWA8934A226E35.local./net/net/airprint.html" "product=(Brother DCP-L2540DW series)" "ty=Brother DCP-L2540DW series" "note=" "rp=ipp/print" "pdl=application/octet-stream,image/urf,image/pwg-raster" "qtotal=1" "txtvers=1"]
...

The command output reveals the presence of a Brother DCP-L2540DW series printer on the local network, along with details about the services it offers, its IP address (in this case, 192.168.1.65), hostname (BRWA8934A226E35.local) and various capabilities.

Let’s break down the command to make it easy to understand:

  • avahi-browse – the command for browsing services using the avahi daemon
  • –all – instructs avahi to show all services, including those that are not currently resolving
  • -t – terminates after dumping a more-or-less complete list
  • -r – resolves service names and addresses

3.3. Using Angry IP Scanner

Angry IP Scanner is an open-source network scanning tool that quickly scans IP addresses and ports and provides information about live hosts and other basic details on a network.

First, let’s begin with the Angry IP Scanner installation. For this, we’ll go to the official site of Angry IP Scanner and download the package for Debian-based Linux Operating Systems:

Download Angry IP Scanner for Linux from official site

Once we’ve downloaded the package, let’s find its location and open the terminal there, and then proceed to install Angry IP Scanner using the dpkg package management tool with the -i option that signifies installation:

$ sudo dpkg -i ipscan_3.9.1_amd64.deb 

After installing Angry IP Scanner, let’s open the tool and perform a scan over the network range:

Scan Network range from Angry IP Scanner

On using Angry IP Scanner for a quick network scan, it identifies the IP address and hostname of the network printer. This matches the information we previously found with avahi-browse. Also, we can confirm it by right-clicking the identified IP section and opening it with the Web Browser:

Open Network Printer in web browserNot all the network printers can connect via a web browser. In the case of Brother printer, the web-related port i.e. 80 (HTTP) is open, it suggests the presence of a web-based interface. While Angry IP Scanner itself doesn’t directly interact with the web interface, the discovery of an open port associated with web access implies that users can potentially access the Brother printer’s configuration settings via a web browser.

4. Conclusion

In this article, we explored various methods to get the IP address of a network printer in Linux.

Whether we choose the powerful nmap or avahi-browse command-line tools, or the user-friendly Angry IP Scanner, each method provides a pathway to discover the IP address of our network printer in Linux. Armed with this knowledge, we can troubleshoot connectivity issues, send print jobs, and ensure a harmonious connection between the Linux system and the network printer.