LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices



Reply
 
Search this Thread
Old 12-01-2003, 01:04 PM   #1
trees
Member
 
Registered: Dec 2003
Location: Earth... I think!?
Distribution: Debian
Posts: 32

Rep: Reputation: 15
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.
 
Old 12-01-2003, 02:04 PM   #2
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 65
Welcome to LQ.

You can set specific routes to specific hosts. This will be automatic if your networks are on different subnets.
 
Old 12-01-2003, 02:43 PM   #3
chort
Senior Member
 
Registered: Jul 2003
Location: Silicon Valley, USA
Distribution: OpenBSD 4.6, OS X 10.6.2, CentOS 4 & 5
Posts: 3,660

Rep: Reputation: 69
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.
 
Old 12-01-2003, 03:41 PM   #4
trees
Member
 
Registered: Dec 2003
Location: Earth... I think!?
Distribution: Debian
Posts: 32

Original Poster
Rep: Reputation: 15
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.
 
Old 12-01-2003, 04:45 PM   #5
chort
Senior Member
 
Registered: Jul 2003
Location: Silicon Valley, USA
Distribution: OpenBSD 4.6, OS X 10.6.2, CentOS 4 & 5
Posts: 3,660

Rep: Reputation: 69
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)

Last edited by chort; 12-01-2003 at 04:47 PM.
 
Old 12-02-2003, 12:02 PM   #6
trees
Member
 
Registered: Dec 2003
Location: Earth... I think!?
Distribution: Debian
Posts: 32

Original Poster
Rep: Reputation: 15
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.
 
Old 12-02-2003, 03:00 PM   #7
chort
Senior Member
 
Registered: Jul 2003
Location: Silicon Valley, USA
Distribution: OpenBSD 4.6, OS X 10.6.2, CentOS 4 & 5
Posts: 3,660

Rep: Reputation: 69
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.
 
Old 12-24-2003, 12:01 PM   #8
trees
Member
 
Registered: Dec 2003
Location: Earth... I think!?
Distribution: Debian
Posts: 32

Original Poster
Rep: Reputation: 15
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!
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Configure Two Networks RatonCrispiN Linux - Networking 3 08-24-2005 01:37 PM
Bridging networks alexr186 Linux - Software 0 08-06-2004 07:57 PM
networks and IP's wi77ard Linux - Networking 2 02-15-2004 07:26 PM
edonkey networks zetsui Linux - Software 2 09-05-2003 08:23 AM
new to networks!!! bigjohn Linux - Networking 0 01-28-2003 03:48 PM


All times are GMT -5. The time now is 11:03 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration