I have an HP Photosmart C4700. I have enabled the Uncomplicated firewall for Ubuntu 11.10. I can connect and print to the printer when all outgoing is allowed under UFW. I have Been using GUFW and when i deny outgoing and add "allow out port 631" for both TCP and UDP i cannot print.

IPP and Localhost: 631

Don't Know if maybe there is another port it will
accept have also tried 515 and 9100.