CUPS server running inside a KVM in NAT mode. CUPS clients hang

Erik Sjölund erik.sjolund at gmail.com
Thu May 10 01:07:10 PDT 2012


The CUPS clients (version 1.5.2) hang when they mistakingly try to connect to the internal NAT IP address of the CUPS server (version 1.5.2). The CUPS server seems to have told the clients about that IP address during a previous TCP connection.

I created a Serverfault question about this but haven't got any answer.

http://serverfault.com/questions/387508/cups-server-running-inside-a-kvm-in-nat-mode-cups-clients-hang

Longer story: I have a number of Ubuntu Linux desktops that have this configuration

user at desktop$ cat /etc/cups/client.conf
ServerName twin2.scilifelab.se

My goal is to install a CUPS server on a KVM host machine that only has one public IP address, so the CUPS server KVM needs to have an internal IP address (NAT mode).

When I first tried to install the CUPS server on a physical machine, printing from GUI programs and from the command line worked perfectly from the Ubuntu desktops. But when I instead install the CUPS server inside a KVM and then start the GUI program gtklp on a desktop computer like this "strace -f gtklp", the program gtklp is hanging at this system call:

connect(14, {sa_family=AF_INET, sin_port=htons(631), sin_addr=inet_addr("10.0.1.2")}, 16

Surprisingly, 10.0.1.2 is actually the internal IP address of the CUPS server KVM and not the IP address of the KVM host twin2.scilifelab.se (130.229.48.38). Some lines before in Strace output there is another connect but with the correct IP address.

connect(13, {sa_family=AF_INET, sin_port=htons(631),sin_addr=inet_addr("130.229.48.38")}, 16) = 0

So the Ubuntu desktop first successfully connects to the CUPS server via TCP. Over this TCP stream it then seems that the CUPS server informs the Ubuntu desktop about its local IP address on the internal network inside the KVM host. Then the Ubuntu desktop tries to connect to that IP address and then hangs.

I tried to change the ServerName setting on the CUPS server but it didn't solve the problem:

root at virt-cupsd:/etc/cups# cat /etc/issue
Ubuntu 12.04 LTS \n \l

root at virt-cupsd:/etc/cups# emacs cupsd.conf
root at virt-cupsd:/etc/cups# grep ServerName cupsd.conf
ServerName twin2.scilifelab.se
root at virt-cupsd:/etc/cups# service cups stop
cups stop/waiting
root at virt-cupsd:/etc/cups# service cups start
cups start/running, process 1834
root at virt-cupsd:/etc/cups#
root at virt-cupsd:/etc/cups# emacs cupsd.conf
root at virt-cupsd:/etc/cups# grep ServerName cupsd.conf
ServerName 130.229.48.38
root at virt-cupsd:/etc/cups# service cups stop
cups stop/waiting
root at virt-cupsd:/etc/cups# service cups start
cups start/running, process 1859

The CUPS server on the KVM is not totally broken because printing from the command line with the lpr command works just fine from the Ubuntu desktop, but all GUI programs I have tested (gedit, chromium-browser, gtklp) have problems. Typically they hang when they want to show the list of printers.

Do you have any ideas of how to fix this?

cheers,
Erik Sjölund




More information about the cups mailing list