TLWIR 49: RELIABLY Printing From GNU/Linux to a Windows 7 Printer

by Rex Djere on November 22, 2012 · 4 comments

in TLWIR

Post image for TLWIR 49: RELIABLY Printing From GNU/Linux to a Windows 7 Printer

3. Set Up Your Gnu/Linux Machine For Printing
All of the hard work is done. Now, all you have to do is to add the LPD printer on your GNU/Linux machine. After this is done, we’ll print a test page to make sure that everything works. My GNU/Linux system is a laptop running Fedora 17. This general process should work on any version of GNU/Linux, but you will have to modify the instructions accordingly.

Once you are logged on to your GNU/Linux machine, you can check to see if it can connect to port 515 on the Windows 7 machine. To do so, you’ll need to open up a terminal and become the root user by issuing the su command (this may be the sudo command on other GNU/Linux distros). You’ll then be prompted to enter your administrative password. Once you are root, you will need to install the program Nmap, if it is not already installed. Nmap is a port scanning program that can be used to scan ports on computers on your network. You can install it on Fedora 17 by typing yum install nmap and hitting Enter.

(Note: installing Nmap is completely optional, and is for printer port testing purposes only, in the scope of this article. Installing Nmap could introduce the potential security risk that if someone took control of your GNU/Linux computer, they could use Nmap to scan network ports for nefarious reasons. If you don’t feel comfortable installing port scanning software on your GNU/Linux machine, don’t do it. Also, if you decide to do the scan, you could always uninstall Nmap after you are done.)

You can now scan the Windows 7 LPD port by issuing the command below (substitute the static address of your Windows 7 machine, if it is different):

[root@yourcomputername yourusername]# nmap -p 515 192.168.1.2

This command prompts Nmap to connect to your Windows 7 machine at 192.168.1.2, and scan port 515. It will then report the results of the scan, as shown in Figure 5 below. I have obscured my MAC address for security reasons, but you can see clearly that Nmap did connect to the printer port. You are now ready to add the Windows 7 printer.

Figure 5: Scanning the Windows 7 LPD Port With Nmap

In Fedora 17, you’ll go to Applications >> Other >> Printing. You’ll get a pop-up windows similar to Figure 6 below (I’ve already added my printer in Figure 6). You’ll click on the +Add button to add your Windows 7 printer. You’ll get a new pop-up window. Select Network Printer >> LPD/LPR Host or Printer. You’ll type in the IP address of your Windows 7 machine in the Host box, and the name of your printer in the Queue box. When you hit Forward, your GNU/Linux machine will start searching for drivers for your printer. It will return a Choose Driver dialog box. You’ll leave the choice as Select printer from database, and you’ll go in and find your printer manufacturer. Hit Forward. You’ll choose your model, and select the recommended driver, if not already selected. Hit Forward. If any other options such as duplex printer come up, hit what option(s) you want supported, and hit Forward again. The final dialog box that you come to should be Describe Printer. Put in all of your printer’s details that you want, and hit Apply. You will be asked for your administrative password. When you enter it, you will be asked if you want to print a test page. Hit Print Test Page,and you should get a beautifully printed CUPS test page full of colors and patterns.

Figure 6: Setting Up the LPD Printer in GNU/Linux

Pages: 1 2 3 4 5

{ 4 comments }

Tim Chase November 23, 2012 at 1:01 pm

Rather than tell Windows to use a static IP address, I’d leave the Windows machine using DHCP and then configure your router to hand out a static IP address to your Windows box based on its MAC (hardware) address. You can find the MAC in the output of the “ipconfig” command in the line reading “Physical Address” where it should look something like “XX-XX-XX-XX-XX-XX”. This allows your Windows PC to move uneventfully to other networks and still get the right internal IP address when it reconnects to your home network. It also prevents your router from accidentally handing out the Windows box’s IP address to other DHCP clients.

Rex Djere November 23, 2012 at 3:05 pm

@Tim Chase, thank you very much for the astute comment. I’ve updated the article to reflect your recommendation.

SW November 23, 2012 at 3:30 pm

If you don’t want to use nmap, you could also use netcat (nc) for this. Chances are good it will already be installed.

nc -zv
You will see this if it succeeded:
Connection to port [tcp/http] succeeded!
and this if it failed:
nc: connect to port (tcp) failed: Connection refused

SW November 23, 2012 at 3:31 pm

You can ignore my first comment as the site didn’t like angle brackets. Here’s the correct one.

If you don’t want to use nmap, you could also use netcat (nc) for this. Chances are good it will already be installed.

nc -zv (host) (port)
You will see this if it succeeded:
Connection to (host) (port) port [tcp/http] succeeded!
and this if it failed:
nc: connect to (host) (port) port (tcp) failed: Connection refused

Previous post:

Next post: