LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   Use two networks? (https://www.linuxquestions.org/questions/linux-networking-3/use-two-networks-121650/)

trees 12-01-2003 12:04 PM

Use two networks?
 
Greetings,
We are running two networks, in two separate locations that are connected to each other. One network has some linux machines and the other is mostly windows.
Problemita: I need to access the printers that are on one network, but also need to be able to ssh..etc on another. I have two network cards that I can enable/disable and somehow get by, but is there a way to assign certain tasks to each card? For Example, use eth0 for printers/http and use eth1 for ftp/ssh?
Any help is much appreciated.

david_ross 12-01-2003 01:04 PM

Welcome to LQ.

You can set specific routes to specific hosts. This will be automatic if your networks are on different subnets.

chort 12-01-2003 01:43 PM

Well you can plug each NIC into a different network, but that may be difficult unless you have access to the wiring closet and you're allowed to plug into both at once. Usually spanning multiple networks is BAD because you want the traffic to go through a supported firewall or router. If your machine forwards packets it could become an unintentional bridge between two networks.

The correct way to handle the situation is to place a router between your networks and have it route traffic. In your routing table on the Linux box you would want to setup a route to the other network and point it at the router (assuming the router has an interface connected to your network). This is assuming that the same router isn't also your default router for all traffic, in which case it would happen automatically and you don't need to do anything.

trees 12-01-2003 02:41 PM

Thanks, that solves it!
I can ssh the router, which routes me to one of the computers on the Linux subnet and go from there.

chort 12-01-2003 03:45 PM

Well, that is a little bit different than what I was explaining, but if it works.. great!

Let me make things more clear. Say you are on one network, that is say 172.16.0.0/24 and there are some machines on another network, say 192.168.0.0/24 that you want to get to. Now there is a router at 172.16.0.1 that is your default route to the Internet. There is also a router at 172.16.0.100 that also has an interface on 192.168.0.100 and it will pass traffic in between. The catch is that you have only two routes on your box, one for 0.0.0.0/0 which points to 172.16.0.1, and one for 172.16.0.0/24 that points to eth0.

What you want is a third route, one that tells your machine where to find 192.168.0.0/24.

Right now your routing table looks like this (assuming 172.16.0.20 is your IP)
Code:

destination        gw                if
0.0.0.0/0        172.16.0.1      eth0
172.16.0.0/24    172.16.0.20    eth0

what you want is this
Code:

destination        gw                if
0.0.0.0/0          172.16.0.1      eth0
172.16.0.0/24      172.16.0.20    eth0
196.168.0.0/24    172.16.0.100    eth0

So you need to do
route add -net 192.168.0.0/24 gw 172.16.0.100

You can add that to /etc/rc.d/rc.local or on some distributions there's a file call /etc/static-routes (or something similar)

trees 12-02-2003 11:02 AM

I'm using Debian (Knoppix), We have one network 192.168.1.0/255 and another network 186.168.1.0/255. There is a router in between, WAN IP. I think I was doing is going there manually ssh and there is a way to configure it automatically in the routing tables.
I don't quite understand it completely.
I think I see how it will work if I am on the Windows network (192...)running Linux, and I can use the printers on the Linux network (186...) if they are connected to a server, but in our case here it's quite different. The printers are stand alone and some are connected to windows machines. Is there a way that I can be on Linux (186...) network and access the printers as stand alone machines on 192... or do I have to configure the router for each one?
Sorry, I'm a bit confused on this.
Thanks.

chort 12-02-2003 02:00 PM

First, /255 is not a valid bitmask. IPs are formed by <network number><host number> where the network number is always static. The CIDR notation is just a shorthand way of saying how many bits of the IP are static, i.e. how many bits are used to specify the network. Thus a dotted decimal subnet mask of 255.255.255.0 would translate into a CIDR bitmask of /24, becuase the first 24 out of 32 bits are static.

OK, now that we have that out of the way...

The router between the 192 and 186 networks should have two interfaces, one on 192 and one on 186. If this router is not your default router for all non-local traffic, then you will need to create static routes on all the 192 machines to point to the router for 186 addresses and vis versa.

trees 12-24-2003 11:01 AM

I think I understood more of what you are saying :)
I configured the second network card to be on the other network (but without a gateway)
Now everything is working fine and here's what the routing tables look like:
Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.1.0 * 255.255.255.0 U 0 0 0 eth1
187.26.16.0 * 255.255.255.0 U 0 0 0 eth0
default 187.26.16.254 0.0.0.0 UG 0 0 0 eth0

Many Thanks!


All times are GMT -5. The time now is 10:07 AM.