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.
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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?
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?
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
Angular Fundamentals

Learn the fundamentals of Angular 2, a JavaScript framework for developing dynamic single page applications.

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?
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


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 )
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?
netmasks work the other way - you can ignore anything but the first quad (an IP such as is called dotted quad notation)

so you could get it to treat and 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.
on your laptop do:
  ifconfig eth0:1 192.168.1.y up
  route add -net netmask gw 192.168.1.y

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
glebspyAuthor Commented:
192.168.1.y means some local static IP address which we choose for the laptop right?
yes, .y just to mark that it is different to .x
its a second IP for the NIC (virtual adaptor), I've never done it myself - but if ahoffmann says it works it must ;-)
yes it's a virtual NIC
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

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

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".


It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Linux Networking

From novice to tech pro — start learning today.