# Connecting printer over Ethernet to 2nd NIC on motherboard?



## Draakje (Jul 2, 2018)

Hello everyone,

My plan was to connect a network printer over ethernet to a free ethernet port on my FreeNAS server. Somehow I think this will use less resources than a FreeBSD jail with CUPS, if I am wrong please say.
I have to do it like this, since the printer is physically close to the server and not the router/modem/switch.

In order for the computer/server and printer to communicate I need to do the following, choose a different subnet than I use on my router for example if I have 192.168.1.1 (router gateway) choose 192.168.2.1 (2nd NIC) and 192.168.2.2 (printer).
Then the NIC is on the same subnet and put the mask 255.255.255.0, the question here is should set I the gateway in printer settings to the computer/2nd NIC ip adress?
Also if I plug the ethernet cable in I expect it to auto assign some 169.X.X.X IP address just like in windows, however if I run ifconfig it doesn't show any extra network interfaces. Is this a problem? 
Afterwards I would like the computers in the 192.168.1.X subnet be able to print on the printer on the 192.168.2.X subnet, I should make some kind of bridge?

If all of this is done I should be able to print from any computer connected to my home wifi on the 192.168.1.X subnet, is this correct? 
If so that is nice, it means I understand it, then I only need to figure it out what kind of commands will achieve the aforementioned things.


----------



## shepper (Jul 2, 2018)

Draakje said:


> Somehow I think this will use less resources than a freebsd jail with CUPS, if I am wrong please say.


If you're are concerned about resources, the lpd(8) print spooler is much lighter than cups.  From a security standpoint, you can limit assess to a network printer port (usually :9100) with filter rule.



Draakje said:


> Also if I plug the ethernet cable in I expect it to auto assign some 169.X.X.X ip adress just like in windows, however if I run ifconfig it doesnt show any extra network interfaces. Is this a problem?



DHCP addresses can change although it is possible to link an address to a MAC.  The easiest way around this is to assign a static address to your printer.



Draakje said:


> If all of this is done I should be able to print from any computer connected to my home wifi on the 192.168.1.X subnet, is this correct?


As long as there is a routing table entry, 192.168.1.1 <-> 192.168.2.1 your print job should find its way.  See route(8).


----------



## SirDice (Jul 2, 2018)

PC-BSD, FreeNAS, NAS4Free, and all other FreeBSD Derivatives


----------



## Draakje (Jul 2, 2018)

SirDice said:


> PC-BSD, FreeNAS, NAS4Free, and all other FreeBSD Derivatives


Given the situation, I don't think specifically going to freenas forum will help the problem solution.
If that is not the case, please tell me what difference between freebsd and freenas could potentially give unwanted behaviour.
Another question, if I am somehow able to put this in a freenas jail, what difference is there between freebsd and a freenas jail, none right?
I am here to learn after all.


As long as there is a routing table entry, 192.168.1.1 <-> 192.168.2.1 your print job should find its way.  See route(8).[/QUOTE]



shepper said:


> If you're are concerned about resources, the lpd(8) print spooler is much lighter than cups.  From a security standpoint, you can limit assess to a network printer port (usually :9100) with filter rule.


Ah route is indeed what I want, what I do not understand is why would I still need to run a print spooler, as for I know the printer acts as something accessible? So I shouldn't need to have a print server running on my server right? Also I did set a static ip, however I somehow can not find it when calling ifconfig.


----------



## shepper (Jul 2, 2018)

Draakje said:


> what I do not understand is why would I still need to run a print spooler, as for I know the printer acts as something accessible?


A spooler is not absolutely necessary but both cups and lpd are spoolers
What is a print spooler?
Section 9.4 in the handbook describes "Direct" printing:
FreeBSD handbook 9.4


Draakje said:


> Also I did set a static ip, however I somehow can not find it when calling ifconfig.


You can also assign a static ip to the printer and if you do so, it will not show up in `ifconfig`


----------



## ondra_knezour (Jul 2, 2018)

If you plan to use your NAS just like switch to connect your printer to your network, why not just add current active and the free one (where a printer will be connected) ports to the bridge? And all unnecessary burden with the routing just disappears 

See if_bridge(4)


----------



## Draakje (Jul 2, 2018)

I have the feeling bridging the 2 connections is not what I want, since it will(?) create overhead. Whereas a route will just allow the data packets to go where they should. But maybe this isn't true.
I am a complete noob to networking hence my questions.


shepper said:


> A spooler is not absolutely necessary but both cups and lpd are spoolers
> What is a print spooler?
> Section 9.4 in the handbook describes "Direct" printing:
> FreeBSD handbook 9.4
> ...



if it doesnt show up in ifconfig how do I know which device I should set a static ip to? Now I only have set a static ip in the settings of printer, I haven't touched the network settings on my server yet.


----------



## ondra_knezour (Jul 2, 2018)

Routing is more resource hungry than simple bridging (at least in 99,something % cases, IMHO).

Connect printer to the port, run ifconfig. Disconnect it, run ifconfig again. Device you want to configure will change status from active to no carrier.


----------



## shepper (Jul 2, 2018)

https://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/printing-direct.html
The device (printer) itself.  How you do it depends on the make/model of printer.
Here is are examples
Example of Setting a Brother HL-1470 IP address
Youtube video on how to set an HP 400


----------



## Draakje (Jul 2, 2018)

shepper said:


> https://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/printing-direct.html
> The device (printer) itself.  How you do it depends on the make/model of printer.
> Here is are examples
> Example of Setting a Brother HL-1470 IP address
> Youtube video on how to set an HP 400


No, the problem is not setting up the printer as this was done before I started the thread. The problem is that I cant figure out how to communicate with the printer via my server.
If i send something to it with nc [static printer ip] 9100 < testfile.txt it doesnt do anything, probably it doesn't understand it. I cannot find anywhere in the networking manual on which port it listens on. The manual only described windows and mac. The driver page shows the source code for a CUPS wrapper driver, is this a hint I need to use CUPS?

In windows I just go to network settings and change the network interface ip to 192.168.2.1, while my printer static ip is 192.168.2.2. The printer and windows pc is connect via ethernet cable to that network interface, then my windows pc can just find it and print to it.
How do I do the same, in freebsd? As what you have been trying to tell me is once I switch my printer ip to static ifconfig will not show the network interface which puzzles me.
I expect the same thing to happen, it gives some strange APIPA, then I should change it to 192.168.2.1 just like on windows?

[edit] nevermind I didnt look really well, apparently it was shown as 0.0.0.0 now I am one step further let's apply the things I know and see what it does.

```
ifconfig em0 inet 192.168.2.1 netmask 255.255.255.0
```
Now I am able to ping to it from the server, now I need to be able to ping it from PC. I thought of doing 
	
	



```
route add -net 192.168.2.0/24 192.168.1.3
```
(server ip from DHCP of router).
However it says that the route is already there, this implies this doesn't do the routing that I had in mind.


----------



## shepper (Jul 3, 2018)

192.168.1.x is one network and 192.168.2.x is a second network.  


Draakje said:


> ifconfig em0 inet 192.168.4.1 netmask 255.255.255.0


is a third network 192.168.4.x.  This seems overly complex and will need routing table entries to tie them all together.
Given that you have just 3 devices: (PC, Printer, NAS) why not put them all on the same network?  What is the advantage of putting the printer on your Network Area Storage?


----------



## SirDice (Jul 3, 2018)

Draakje said:


> If that is not the case, please tell me what difference between freebsd and freenas could potentially give unwanted behaviour.
> Another question, if I am somehow able to put this in a freenas jail, what difference is there between freebsd and a freenas jail, none right?





> These derivative products are all customised in some way, which means, among other things, that their base system, ports/package management, source code, X system, kernel configuration, libraries, disk layout, installation procedure, disk systems, etc. etc. may be very different.


----------



## Draakje (Jul 3, 2018)

shepper said:


> 192.168.1.x is one network and 192.168.2.x is a second network.
> 
> is a third network 192.168.4.x.  This seems overly complex and will need routing table entries to tie them all together.
> Given that you have just 3 devices: (PC, Printer, NAS) why not put them all on the same network?  What is the advantage of putting the printer on your Network Area Storage?


that's a typo, it should be 192.168.2.x . 
My switch doesn't have any other ports, so the only place I have an extra ethernet port is on my NAS. It also is not physically close to the switch, need to have 15 meters of ugly cabling through my home.

It doesnt work since I have to set a route in my switch for devices connected to the switch to find the printer connected to the server...
Is there a way to make it accessible on the 192.168.1.X network? By giving it some ip outside my switch DHCP range, which then will be routed to 192.168.2.2?

if I ping 192.168.2.2 on my pc the switch won't know it needs to forward it to 192.168.1.3 which can forward it to 192.168.2.2?


SirDice said:


> snip


And do you think it applies here? I really think my question is just a basic networking question in freebsd, but yeah having no experience I can not judge this...


----------



## Draakje (Jul 4, 2018)

I solved it with just connecting to a switch, something very simple became too complex.


----------

