I try to use GNU/Linux solutions whenever I can. However, one exception to this rule is the printing process in my home. I have one printer, and it is connected to my Windows 7 machine. As GNU/Linux becomes more popular in homes and businesses, it is becoming more common to see mixed GNU/Linux-Windows environments. Printing from GNU/Linux to Windows 7 using Samba did NOT work for me reliably, but I have found a method that works 100% of the time. In The Linux Week in Review 49, I’ll explain how to set up a 100% dependable GNU/Linux-to-Windows 7 printing network. The video at the end of TLWIR 49 demonstrates the entire setup process from beginning to end.
There are three basic steps to setting up GNU/Linux-to-Windows 7 printing:
- 1. Make your Windows 7 computer a fixed target instead of a moving one. (***Update***: a very astute reader pointed out to me a more flexible alternative to setting up the Windows 7 machine at a static IP address. I tested it, and it works great! I’ll explain the alternative in section 1a).
- 1a. Leave your Windows 7 PC and router set up to use DHCP, but reserve a permanent IP address for the Win 7 PC in the router’s DHCP settings.
- 2. Set up your Windows 7 machine for printing.
- 3. Set up your GNU/Linux machine for printing.
1. Making Your Windows 7 Machine a Fixed Target
(If you already know how to set up Windows 7 to use a static IP address, you can skip ahead to section 2.)
Your home LAN probably uses DHCP to assign IP addresses to clients on the network. The Dynamic Host Configuration Protocol is used to dynamically configure network clients and assign them IP addresses, as shown in Figure 1 below.
This is great for dynamically configuring your network when you are constantly turning devices on and off. However, I have found that a DHCP-configured Windows 7 computer is not very reliable when you print from a GNU/Linux computer to a printer connected to that Windows 7 PC. When I tried this setup using Samba, one of the most popular methods of talking to Windows machines from GNU/Linux, I could print one day, only to have it fail the next day. So what method worked reliably for me? It turns out that the first step was to set up the Windows 7 PC with a static IP address instead of a dynamically allocated one. Making the Windows 7 PC a fixed target instead of a moving one made my GNU/Linux-to-Windows printing much more reliable.
The instructions that I am about to provide assume that you have a network similar to the diagram in Figure 1 above. You’ll have to modify the instructions to match your exact configuration. You may have to use different IP addresses, depending on the manufacturer of your router. Let’s assume that your router acts as your network’s DHCP server. Let’s also assume that your network has the same IP addresses as Figure 1. The basic goal is to get your Windows 7 PC to be statically assigned an address such as 192.168.1.2. The rest of your network will continue to operate via DHCP. In our sample case, the DHCP devices will be bumped from the 192.168.1.2 to 192.168.1.5 address space to the 192.168.1.3 to 192.168.1.6 address space. Think of it as shifting all of your neighbors over one house to make room for the new house that you are building. You will stay in your new house all of the time, but your 4 neighbors will randomly switch houses.
The first thing that you’ll do is to log on to your router. I would also turn off all of the DHCP client devices to prevent network confusion as you change network settings. You’ll set the router’s DHCP up to start assigning IP addresses one IP address higher than it currently does. For example, if it currently starts at 192.168.1.2, you’ll change it to start at 192.168.1.3. 192.168.1.2 will now be available for exclusive use by your Windows 7 machine.
The next thing that you’ll do is to set up your Windows 7 machine to statically use 192.168.1.2. To do this, you’ll go to Control Panel, and navigate to a menu box similar to Figure 2 below. I won’t go through all of the steps to navigate there here, but I will demonstrate it in the video at the end of this article. Once the settings are complete, you should reboot your Windows 7 computer, and you can turn your DHCP client devices back on.
Finally, you’ll perform a test to see if the process worked. You’ll check your Windows 7 computer’s IP address is to make sure that it is correct. To do so, you’ll go to Start, and type cmd in the search programs and files box. Open cmd.exe. This will bring up a command line. Type ipconfig and hit Enter. You should get a result similar to Figure 3 below. You will probably have to scroll to see your IP address (you want the ipv4 address).