Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

i have a cups server running on ubuntu 9.10 on my home network. right now i can access it at 192.168.1.101:631, but when i try to access it at myservername.local:631 i get a 400 Bad Request. here's the relevant section from my current cupsd.conf:

ServerName 192.168.1.101

# Only listen for connections from the local machine.
Listen localhost:631
Listen /var/run/cups/cups.sock

# any of the below 'Listen' directives all yield the same result
Listen 192.168.1.101:631
#Listen *:631
#Listen myservername.local:631

# Show shared printers on the local network.
Browsing On
BrowseOrder allow,deny
BrowseAllow all
BrowseLocalProtocols CUPS dnssd
BrowseAddress 192.168.1.255

# Default authentication type, when authentication is required...
DefaultAuthType Basic

# Restrict access to the server...
<Location />
  Order deny,allow
  Deny from All
  Allow from 127.0.0.1
  Allow from 192.168.1.*
</Location>

# Restrict access to the admin pages...
<Location /admin>
  Order deny,allow
  Deny from All
  #Allow from 127.0.0.1
  #Allow from 192.168.1.*
</Location>

# Restrict access to configuration files...
<Location /admin/conf>
  AuthType Default
  Require user @SYSTEM
  Order deny,allow
  Deny from All
  #Allow from 127.0.0.1
  #Allow from 192.168.1.*
</Location>

i get the following in /var/log/cups/error_log:

E [03/Jan/2010:18:33:41 -0600] Request from "192.168.1.100" using invalid Host: field "myservername.local:631"

what do i need to do to be able to access the cups server at both 192.168.1.101:631 and myservername.local:631?

share|improve this question

5 Answers 5

up vote 3 down vote accepted

As of Cups 1.3.10, the server does not attempt to lookup its own hostname on startup. The old behaviour can be restored by adding

HostNameLookups on

To your cupsd.conf file. More information is available in this Gentoo Bug Report as well as the CUPS 1.3.10 Release Notes.

You may also want to look into the ServerName and ServerAlias config directives. See the manpage (man cupsd.conf or available online here) for more information.

share|improve this answer
    
no, i've tried setting Listen to *:631 and several other settings, but none have worked –  aaron Jan 4 '10 at 0:28
    
If you do ping myservername.local, is it able to resolve the IP address? –  Adam Luchjenbroers Jan 4 '10 at 0:36
    
yeah, it pings at myservername.local, and i know the cups server is getting the request b/c it shows up in the log (see the error message i added to the question above) –  aaron Jan 4 '10 at 1:15
    
Aha, as of Cups 1.3.10 it no longer attempts to lookup the local hostname by default, add HostNameLookups On to your config file to reinstawte the old behaviour. (bugs.gentoo.org/show_bug.cgi?id=266678) –  Adam Luchjenbroers Jan 4 '10 at 2:04
    
unfortunately that doesn't work either. interestingly enough, when i add HostNameLookups On with Listen *:631, the server doesn't even respond, however i can have HostNameLookups On with Listen myservername.local:631, and it behaves as before –  aaron Jan 4 '10 at 4:02

From your initial question, it appears that you may have tried (amongst others) a cupsd.conf variation containing the following statements:

ServerName 192.168.1.101

# Only listen for connections from the local machine.
Listen localhost:631
Listen /var/run/cups/cups.sock

# any of the below 'Listen' directives all yield the same result
#Listen 192.168.1.101:631
Listen *:631
#Listen myservername.local:631

This one certainly will have NOT worked, and likely, will have prevented the cupsd daemon from starting up. Because, the Listen localhost:631 statement will have bound it to the 127.0.0.1:631 socket. A few milliseconds later in its startup, the Listen *:631 statement would have asked for binding to all available sockets at port 631: that is, in your case at least 127.0.0.1:631 (again) and 192.168.1.101:631. When trying to bind a second time to 127.0.0.1:631, cupsd would find the socket occupied already, log an error and exit.

Lesson: If you use multiple Listen: ... directives in cupsd.conf, make sure you have no overlapping.

share|improve this answer

it is intentional behaviour that CUPS rejects requests addressed to the FQDN of the host when received over the local loopback interface.

Solution: don't make the FQDN of the host resolve to 127.0.0.1, but instead to the correct external IP address for that FQDN.

share|improve this answer
    
That's not correct. What you indeed do have to avoid is multiple Listen ... statements with overlapping sockets. What is completely "legal" with CUPS is having 2 (or more) separate Listen ... statements, one with Listen 127.0.0.1:631, another one with Listen 192.168.1.101:631. These do not overlap. What will always overlap is to use wildcard statements, such as Listen *:631 and also add specific ones such as Listen 192.168.1.101:631. –  Kurt Pfeifle Jul 1 '10 at 9:53

Enabling Printing using CUPS from the Mac – How my Mac now prints to a printer plugged into a Machine running Ubuntu 9.10!

After MANY missteps, I followed these steps and the printer finally started to work using CUPS and the setup above. As a relative noob to Ubuntu and Linux, I don't know which of these steps were the magic ones that worked. It is likely that some of these steps can be changed or omitted, but they worked for me, and hopefully, for you as well.

Printer attached to the parallel port on the Linux machine was installed, running, and set to shared over the local network from CUPS (http://localhost:631 typed into the firefox location bar).

On the Linux machine, I ran ifconfig from the terminal app. to discover the local IP address (starts with 192.168.xx.x) (Your xx.x will be different numbers).

From the Mac's Safari program's location bar, I went to the url of the Linux machine's CUPS port 631 (192.168.xx.x:631) where xx.x are numbers for the local address discovered using ifconfig above.

This brought up the CUPS system on the Linux machine (which was displayed on the screen of the Mac machine).

I then went to the printers tab on the Linux machine (through safari on the Mac) and copied the location for the printer onto the clipboard (http://192.168.xx.x:631/printers/Hewlett-Packard-HP-LaserJet-1100).

I then opened port 631 on the Mac machine (http://localhost:631) which brings up the CUPS system on the Mac. (If it doesn't bring up the Mac CUPS system, look elsewhere to figure this one out).

I went to Add Printer on the Mac CUPS system.

On the Mac, I gave the added printer a name of HP_LaserJet_1100 and “cut and pasted the location into both the location and the description fields.

For device I used IPP or internet printing protocol (http).

For Device URI, I pasted the location copied from the Linux machine yet again.

I selected the proper make and model for the driver on the next screen.

Worked! Hopefully this saves someone else the hour or two it took me to thread that needle.

share|improve this answer
    
thanks for the info! –  aaron Feb 5 '10 at 3:56

The following cupsd.conf file settings allowed me to print using either the IP or the hostname of the cups server:

ServerName myservername
ServerAlias *

# Only listen for connections from the local machine.
Listen localhost:631
Listen /var/run/cups/cups.sock
Listen myservername.local:631

# Show shared printers on the local network.
Browsing On
BrowseOrder allow,deny
BrowseAllow all
BrowseLocalProtocols CUPS dnssd
BrowseAddress 192.168.1.255

# Default authentication type, when authentication is required...
DefaultAuthType Basic

# Restrict access to the server...
<Location />
  Order deny,allow
  Deny from All
  Allow from 127.0.0.1
  Allow from 192.168.1.*
</Location>

# Restrict access to the admin pages...
<Location /admin>
  Order deny,allow
  Deny from All
  #Allow from 127.0.0.1
  #Allow from 192.168.1.*
</Location>

# Restrict access to configuration files...
<Location /admin/conf>
  AuthType Default
  Require user @SYSTEM
  Order deny,allow
  Deny from All
  #Allow from 127.0.0.1
  #Allow from 192.168.1.*
</Location>

apparently i was missing the ServerAlias * line

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.