LinuxQuestions.org
Visit Jeremy's Blog.
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 07-15-2007, 05:00 PM   #1
veeruk101
Member
 
Registered: Mar 2005
Distribution: Ubuntu 12.04 LTS
Posts: 249

Rep: Reputation: 16
How to connect two private networks?


In conceptual terms, how can two computers on different subnets see each other's IP addresses? (Btw, I'm a newbie.)

I have two computers, each on a different private subnet for learning purposes. How would I get the two to see each other's IP addresses using ping?

Right now all I have are two private IP addresses (e.g. 192.168.100.1,192.168.200.1), and I've done nothing else. So if I do an "ifconfig eth0" on each, I'll see the private IP address assigned to each.

What are the steps needed to go from this to the two computers being able to see each other?

Thanks.
 
Old 07-15-2007, 05:18 PM   #2
Micro420
Senior Member
 
Registered: Aug 2003
Location: Berkeley, CA
Distribution: Mac OS X Leopard 10.6.2, Windows 2003 Server/Vista/7/XP/2000/NT/98, Ubuntux64, CentOS4.8/5.4
Posts: 2,986

Rep: Reputation: 45
You need what is called a router. Linux and Windows Server OS's can act as a router and route traffic to different networks. You could also buy a router device.

How is your little network set up? You have 1 computer with 2 NIC's?

Last edited by Micro420; 07-15-2007 at 05:21 PM.
 
Old 07-15-2007, 05:37 PM   #3
veeruk101
Member
 
Registered: Mar 2005
Distribution: Ubuntu 12.04 LTS
Posts: 249

Original Poster
Rep: Reputation: 16
I have one computer with one NIC, actually (the two "computers" in my previous post are actually VMWare servers, but hopefully that doesn't make things too complex...)

Would I have to set up each of the two computers to be a router (one for each private network), or one between the two of them?

I've been reading up on how to do this, and I'm totally confused between the mess of gateways, routers, NAT, iptables - different articles describe it using any/all of the above things, and I'm really hoping you could simplify this for a newbie.

Thanks.
 
Old 07-16-2007, 03:13 AM   #4
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
in a VM, if they are on seperate subnets, then you just need a common machine on both those subnets, with ip forwarding enabled. here, that'd most likely be the vmware host machine. i've not used routed networking in vmware myself, just always bridged it for simplicity, but i assume that if you use routed networking you'll have secondary interfaces created on your host which would be used as the gateway for the guest. with that done twice, "echo 1 > /proc/sys/net/ipv4/ip_forward" should make the routing work. this is largely dependent on VMware though, so ymmv.
 
Old 07-16-2007, 01:25 PM   #5
veeruk101
Member
 
Registered: Mar 2005
Distribution: Ubuntu 12.04 LTS
Posts: 249

Original Poster
Rep: Reputation: 16
Thanks, there's a start - I need one box on both subnets.

Btw, I don't want to use "bridging" or any VMWare-specific things, because I'm actually using the VMWare VMs to simulate independent standalone boxes that have nothing to do with VMWare.

Quote:
if you use routed networking you'll have secondary interfaces created on your host which would be used as the gateway for the guest
Again, there's no notion of "host" in my system, because both guests should really be seen as independent machines. So far VMWare is actually pretty invisible to the whole setup, so I think it should be possible to continue down this road. I'd create the machine that needs to be on both subnets as another VMware VM. Btw, what is meant by secondary interface - would this be 'IP aliases'?

Is the step "echo 1 > /proc/sys/net/ipv4/ip_forward" all that's needed, or do I have to do things with the "route" command, like "route add ..."? If so, what would I need to enable? (e.g. Would I need to get both machines talking to the third box that's on both subnets by configuring it to be the gateway?) If not, does the simple step you described really take care of all that?
 
Old 07-16-2007, 01:41 PM   #6
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
both guest machines only have a single route for a default gateway. that default gateway knows about both the networks involved as they are locally connected subnets. as such there is no need to provide any more information about the topology to any host here.

note that bridging isn't "vmware" specific at all... if you're not familiar with it, just pretend that it's a switch and not a router. it just happens that the three "ports" on this switch, one to each vm and one on the host, are in software, not hardware... there is no downside of false architecture to bridging the connections at all, and will make a much simpler topology.
 
Old 07-16-2007, 02:11 PM   #7
veeruk101
Member
 
Registered: Mar 2005
Distribution: Ubuntu 12.04 LTS
Posts: 249

Original Poster
Rep: Reputation: 16
Thanks, but I'm a little confused as to what I should actually do now... My actual VMWare host is a Windows machine, so where would I actually run the echo command you specified? Perhaps you could kindly reiterate the steps, as I'm feeling a bit overwhelmed right now.

Quote:
both guest machines only have a single route for a default gateway. that default gateway knows about both the networks involved as they are locally connected subnets. as such there is no need to provide any more information about the topology to any host here.
What's the difference between setting a route to something, versus specifying something as a gateway? Don't they both essentially do similar things, which is telling a machine how to get beyond its own network - if that's the case, what's the difference between the two?
 
Old 07-16-2007, 02:31 PM   #8
rossonieri#1
Member
 
Registered: Jun 2007
Posts: 359

Rep: Reputation: 34
hi veeruk101,

actually - every device can be a router --> thats 127.0.0.1 mean --> it talks to itself.

in your case you can try it for whos going to be the default gateway? which is your 2 vm machine NIC.

example :
machine 192.168.100.1 --> gw 192.168.100.1
machine 192.168.200.1 --> gw 192.168.200.1

try ping..
the action will be any ip/subnet outthere i'll search them myself.

HTH.

Last edited by rossonieri#1; 07-16-2007 at 02:32 PM.
 
Old 07-16-2007, 03:20 PM   #9
veeruk101
Member
 
Registered: Mar 2005
Distribution: Ubuntu 12.04 LTS
Posts: 249

Original Poster
Rep: Reputation: 16
What happens when each of the two private networks adds more nodes, so that each network has 3 nodes: e.g.

192.168.100.1
192.168.100.2
192.168.100.3

192.168.200.1
192.168.200.2
192.168.200.3

Then what would I do? The "route" command? Setting gateways?
 
Old 07-16-2007, 03:39 PM   #10
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
still nothing if upstream tehre is a machine that knows of both networks. not sure why you seem to want to make this more complex than it is...
 
Old 07-17-2007, 06:57 AM   #11
rossonieri#1
Member
 
Registered: Jun 2007
Posts: 359

Rep: Reputation: 34
Quote:
Originally Posted by veeruk101
What happens when each of the two private networks adds more nodes, so that each network has 3 nodes: e.g.

192.168.100.1
192.168.100.2
192.168.100.3

192.168.200.1
192.168.200.2
192.168.200.3

Then what would I do? The "route" command? Setting gateways?
well, machine within the same subnet - you dont have to route. they already talk to each other.

but - to connect with machines in other network you need to route or router.

what i've explained is a single machine being itself as a router.
if you want to specify the other machine as well - no problem : just read well the post

why you only need one gateway for a subnet is that you dont have to put self as gateway to every machine.

but there are limitations -- this is out of the subject

HTH.
 
  


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
LXer: Creating virtual private networks with tsocks and VTun LXer Syndicated Linux News 0 06-12-2006 05:21 PM
how to configure Private & Public Networks naresh Linux - Hardware 0 11-18-2004 12:49 AM
Configuring redhat 9 to pass traffic betwen 2 private networks (gateway) menonrr Linux - Networking 2 09-14-2004 07:38 PM
Multiple private networks interconnection via internet cardner Linux - Networking 0 01-14-2002 02:15 PM
VPN - Virtual Private Networks? bnicolas Linux - Newbie 1 08-16-2001 04:24 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 08:46 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
Open Source Consulting | Domain Registration