# how to print to a network printer in my home lan?

## wquiles

I have looked at the print guides but most information is for setting up a local printer that can be shared on a LAN.  In my setup, I already have a PC in my home LAN running Windoze 2K and sharing a laser printer that I want to use in my Gentoo box.

PC with shared printer:

//doris-pc/Samsung

I am already using mount -t smbfs to mount/share a drive on that PC to a local mount/folder in my system so I know the network is perfect.

I have done this on RedHat years ago and recently on Xandros 2.0 but I can't seem to find in my Gentoo system "where" to make this happen   :Embarassed: 

I am running KDE 3.2 and the 2.6.7-gentoo-r9 kernel with the following config file and flags:

```
bash-2.05b# cat make.conf

# These settings were set by the catalyst build script that automatically built this stage

# Please consult /etc/make.conf.example for a more detailed example

CFLAGS="-O3 -march=athlon-mp -pipe -fomit-frame-pointer"

CHOST="i686-pc-linux-gnu"

CXXFLAGS="${CFLAGS}"

MAKEOPTS="-j3"

GENTOO_MIRRORS="ftp:///ftp-stud.fht-esslingen.de/pub/Mirrors/gentoo/ http://mirrors.acm.cs.rpi.edu/gentoo/ http://gentoo.osuosl.org/ http://gentoo.mirrors.pair.com/"

USE="x86 3dnow -acpi alsa -apm arts cdr divx4linux dvd dvdr ftp -gnome -gtk mmx mozilla samba tiff usb xinerama"

bash-2.05b#
```

Thanks in advance,

William

----------

## donjuan

You probably used some GUIs written by the distro to do this in your other versions of Linux, but since Gentoo is Gentoo we don't have those  :Smile: .  So I'll give you another solution.  You can probably find other ways to do this, but this is how I do it.

Emerge foomatic and CUPS, and if you have an HP printer you probably also want hpijs.

```
emerge foomatic cups hpijs
```

You might want to add foomatic and CUPS to your use flags in make.conf

```
USE="foomaticdb cups"
```

You'll need CUPS running for the next step and to be able to print:

```
# rc-update add cupsd default

# /etc/init.d/cupsd start
```

Then go to a web browser on the Linux machine go to the url: http://localhost:631

Go to Manage Printers and select Add Printer

At some point you'll be asked for a username and password, I just always login as root.

At the next page you'll be asked for a name, location, and description.  These are just descriptive, so if you screw up here you'll just confuse yourself, but the printer will still work  :Razz: .

Continue to the next page titled "Device for <printer>" and choose "Windows Printer via SAMBA" from the drop-down list.

Continue to the next page.  Now this is where you need to be careful.  This is how you direct CUPS to connect to the printer shared by the Windoze machine.  Type in 

```
smb://<username>:<password>@<server>/<printer share name>
```

The username and password are those you are using to connect to the Windoze machine, most commonly the username will be guest, and the password will be blank.  The server is just what you had Windoze call the computer, and the printer share name is self-explanitory.  For me it is 

```
smb://guest:@Athlon/HP LaserJet 2100
```

On the next page choose the model.  I choose HP not HEWLETT-PACKARD so I get HP's Linux drivers, which I get from emerging hpijs.  Then on the next page browse through that huge list of drivers and choose your printer, hopefully it's there or else you have to go onto the internet and find a place to get drivers or choose something close and hope it works.  I haven't searched for drivers yet since all my printers are HPs.

Then after you're done with that, on the next page it will say "Printer <printer> has been added successfully."  Click on the <printer> link, and then if you want it as default click on the "Set As Default" button.  You'll probably want to print a test page also, just to make sure everything's OK  :Wink: .

EDIT: I don't think the "set as default" button will set that printer as the default for all users, so as user you can go to kprinter and set the new printer as default there, or on the command line type 

```
lpoptions -x <printer name>
```

The printer name here is what you told CUPS to call the printer.

----------

## tbg

Thank you DonJuan, that was very helpful!

----------

## wquiles

Outstanding - that worked GREAT for me as well.  I am now printing just fine   :Laughing: 

Thanks so much !

----------

## coax

Thank you! That did the trick allright  :Wink: 

----------

## Butts

Will this work for a network printer as well?

I have a wirelesss network with my SMC wireless router hosting the printer. Could I just give cups the ip address of the printer??

I will try this regardless, just wondering if you had any other insight.

Thanks.

----------

## Jimeh

Thank you donjuan thats one excellant guide, I can now print to the HP deskjet attached to my Windows XP box!!!!!!!  Superb  :Very Happy: 

----------

## Jimeh

 *donjuan wrote:*   

> 
> 
> EDIT: I don't think the "set as default" button will set that printer as the default for all users, so as user you can go to kprinter and set the new printer as default there, or on the command line type
> 
> ```
> ...

 

Oh btw I think you made a typo.  I believe you meant lpoptions -d <printer name> and not x.  It's a very easy mistake to make considering how close the two keys are the keyboard.

Here is what man lpoptions has to say about the two arguments:

```

-d dest[/instance]

            Sets  the  default  printer  to dest. If instance is supplied then

            that particular instance is used. This option overrides the system

            default printer for the current user.

-x dest[/instance]

            Removes  the  options  for  the named destination and instance, if

            specified.  If the named instance does not exist  then  this  does

            nothing.

```

----------

