Getting two machines in different domains to communicate over home LAN

Machine A is a home desktop set up with the standard LAN domain 192.168.1.x.

Machine B is a laptop which spends some time at home and some time in the office. It has static IP settings for the office with domain 131.111.25.x .

When machine B is taken home and attached to the LAN, it can't see or be seen by machine A. The LAN doesn't have a dedicated router, just several client machines connected by a switch. It's not connected to the internet, although it might be in future.

How should B be set up in order that it can maintain its domain and IP address settings for the office, but still participate in the LAN when it is brought home, without having to reset something manually every time?
In particular, is it possible to achieve this by making one of the machines on the LAN a gateway with suitable settings?

Linux variety of all machines is Debian. Thanks for your help.
LVL 1
glebspyAsked:
Who is Participating?
 
ahoffmannCommented:
on your laptop do:
  ifconfig eth0:1 192.168.1.y up
  route add -net 192.168.1.0 netmask 255.255.255.0 gw 192.168.1.y
0
 
majorwooCommented:
you could switch your home network to use the same IP scheme - if you are behind a NATing firewall, it won't cause you any problems.  How do machine A and B connect to the net when they are home?
0
 
glebspyAuthor Commented:
It is somewhat unusual but I am not connected to the net at home (yet!). The purpose of the home lan is to support a parallel cluster so at the moment it doesnt have an external connection.

The solution you propose certainly works, but I want to keep the settings of machine A as 192.168.1.x . The reason is that, as you suggest, I may want to connect the cluster to the net via PPP or PPPOE, *without* network address translation. The connection might end up containing a NATing device, or it might not. So I wish to keep the settings of machine A and B as they are, in order to be sure that there will be no future problems. I should have mentioned this.

Is there a solution on these terms?
0
Cloud Class® Course: Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

 
majorwooCommented:
you could place another machine in the loop with 2 nic's and have it act as a bridge between the two subnets - even using the desktop(machine A) with a second NIC for this purpose

The other option is to write a simple script that switches your net settings betweeb home/office for the laptop on bootup, i used to have something simple like that for handling my wireless and docked/undocked settings
0
 
glebspyAuthor Commented:
The 2nic idea is practical as far as hardware is concerned but it sounds complicated to set up. Also can you explain why it is necessary? i.e. why does a bridge require 2 network cards?
0
 
majorwooCommented:
A bridge serves as a gateway between two networks - it handles the translation from one network to the other.

The reason you need 2 NIC's is that you need to have it connected to both networks, for example the machine in the middle acting as the bridge, needs to have an IP on both schemes, so in your case it might be

eth0: 192.168.0.1
eth1: 131.111.25.1

and essentially passed the traffic between them back and forth.  It actually painless to do,

#1 - add the second NIC to the machine,
#2 - setup the IP for it on the second network (the 131. for you, since the first card is already on 192)
#3 - enable IP forwarding.  (in redhat which may be different echo "1" > /proc/sys/net/ipv4/ip_forward )
0
 
glebspyAuthor Commented:
ok I understand what you are saying but is there really no way of achieving the same thing with only one network card? Particularly I'm thinking, isnt it possible to use netmasks to make the network traffic independent of the first three bytes of the IP address, and only look at the fourth (the .x)? If not, then what are netmasks for?
0
 
majorwooCommented:
netmasks work the other way - you can ignore anything but the first quad (an IP such as 192.168.0.1 is called dotted quad notation)

so you could get it to treat 192.199.25.48 and 192.12.184.167 as the same network by trating them as 192.X.X.X but not the other way around.  Hence the second network card to have one machine act as the bridge between them.
0
 
glebspyAuthor Commented:
192.168.1.y means some local static IP address which we choose for the laptop right?
0
 
ahoffmannCommented:
yes, .y just to mark that it is different to .x
0
 
majorwooCommented:
its a second IP for the NIC (virtual adaptor), I've never done it myself - but if ahoffmann says it works it must ;-)
0
 
ahoffmannCommented:
yes it's a virtual NIC
0
 
troy_Commented:
Yeah, the virtual nic is the right idea, especially because you only want to connect to the local network at home (no internet).  Here is what I would do:

ifconfig eth0:1 192.168.1.3

This should allow that machine to participate in the local network freely.  If you later want internet access, then you could just add another gateway, like this:

route add default gw 192.168.1.1

I actually typed these commands in to my machine and it took it without question, of course I don't have a gateway at that address to test, so let us know if this works.

I had a similar problem and I elected to just set up a dhcp server both at the office and at home - now mine is happy no matter what.  I set the laptop for dhcp and it "just works".

Troy

Troy
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.