Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game. |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
07-15-2007, 05:00 PM
|
#1
|
Member
Registered: Mar 2005
Distribution: Ubuntu 12.04 LTS
Posts: 249
Rep:
|
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.
|
|
|
07-15-2007, 05:18 PM
|
#2
|
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:
|
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.
|
|
|
07-15-2007, 05:37 PM
|
#3
|
Member
Registered: Mar 2005
Distribution: Ubuntu 12.04 LTS
Posts: 249
Original Poster
Rep:
|
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.
|
|
|
07-16-2007, 03:13 AM
|
#4
|
Moderator
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417
|
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.
|
|
|
07-16-2007, 01:25 PM
|
#5
|
Member
Registered: Mar 2005
Distribution: Ubuntu 12.04 LTS
Posts: 249
Original Poster
Rep:
|
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?
|
|
|
07-16-2007, 01:41 PM
|
#6
|
Moderator
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417
|
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.
|
|
|
07-16-2007, 02:11 PM
|
#7
|
Member
Registered: Mar 2005
Distribution: Ubuntu 12.04 LTS
Posts: 249
Original Poster
Rep:
|
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?
|
|
|
07-16-2007, 02:31 PM
|
#8
|
Member
Registered: Jun 2007
Posts: 359
Rep:
|
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.
|
|
|
07-16-2007, 03:20 PM
|
#9
|
Member
Registered: Mar 2005
Distribution: Ubuntu 12.04 LTS
Posts: 249
Original Poster
Rep:
|
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?
|
|
|
07-16-2007, 03:39 PM
|
#10
|
Moderator
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417
|
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...
|
|
|
07-17-2007, 06:57 AM
|
#11
|
Member
Registered: Jun 2007
Posts: 359
Rep:
|
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.
|
|
|
All times are GMT -5. The time now is 01:06 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|