Connecting two lans

Posted on 2000-04-04
Last Modified: 2011-09-20
I have a samba server with dial-in access and another linux box that dials up to it.  The samba box works great, it has 2 workstations connected to it and samba talks to it with no problems over the hub.

The second linux box has 2 workstations connected to it.  Each Lan can ping everything connected to it.  When I connect to the samba server via ppp I am only able to ping the samba server and the samba server is only able to ping the dial up linux box.  How can I get everything to ping one another?

----   ----   ----
|  |---|  |---|  |  <-
----   ----   ----    Samba Server
 .67    .68   |      
              |  <-- Modem Connection
----   ----   ----
|  |---|  |---|  |  <-
----   ----   ----    Dial-up Linux Box
 .75   .76
Question by:mistyblue1
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
LVL 10

Expert Comment

ID: 2686436
Pls post the output of the route command on both Linux pcs after the PPP connection is established. In general the ppp makes the route correctly but there could be some problems to.
After this
use the following command on both.

ipchains -A forward -j MASQ -d

Expert Comment

ID: 2686493
There's two problems - one is that you have two networks using the same IP address range, and also that ppp is changing your default routes which effectively disables your eth0 devices and thus your lan connections.

Since these are your own networks, the simplest thing would be to renumber one network.  Say, put the samba network on  The samba server would be, and the other machines would have their ip addresses changed to use 2 in the third 'octet'.  That will make the routing simpler, since you really have two nets and should number them accordingly.  

The second problem is how ppp works.  The ppp connection usually has the 'defaultroute' option set, which means that if you have a working eth0 interface set as the default route (to your LAN), once ppp connects it changes your routing tables and makes ppp0 the default route, thus erasing the route path to your lan.  Like this - before ppp starts, the output of 'route -n' on your Linux box probably looks like this:
destination  gateway genmask iface      * eth0

But after, it's      * ppp0

See, you lost your route to the eth0 device so you can only ping things visible to ppp0.

I think the best way to do this is to not make the route to eth0 a default route.  Instead, specifically make a route to your network through eth0 - then ppp won't affect it.  Using linuxconf, or by editing /etc/rc.d/rc.local, you want to (on the linux box dialing in) do

route add -net netmask dev eth0

at startup.  Then since this is no longer the magic 'default' route of, ppp will leave it alone.  (there's other ways to do this, but this is the simplest, I think).

You might not need netmask, I do it anyway because I can never remember how the network classes work.  Then when ppp starts, you will still be able to ping the other machines on your local lan.

To make it so you can see other machines on the other side of the ppp connection, you need to similarly alter the routing table on  the machine you are dialing into. First make a direct route to the samba lan at startup with

route add -net netmask dev eth0

Then when ppp makes a default route through ppp0 it won't alter the route through your eth0 to the local network.

Also, of course the other boxes on your lan that AREN'T part of the modem connection need to have the samba box and the linux box set up as their gateways - which you probably already have done.  

Author Comment

ID: 2691160
I will try it this evening and let you know how it went.
Thanks.  =)
Is Your Team Achieving Their Full Potential?

74% of employees feel they are not achieving their full potential. With Linux Academy, not only will you strengthen your team's core competencies but also their knowledge of of the newest IT topics.

With new material every week, we'll make sure that you stay ahead of the game.


Author Comment

ID: 2693817
Samba Server
destination        gateway genmask               iface  eth0      eth0  ppp0              lo

Dial up Server
destination        gateway genmask               iface  eth0      eth0  ppp0              lo

I am able to ping from machine, however I can't ping from

I did try adding in ipchains -A forward -s -d -j MASQ on the samba server after doing ipchains -P forward MASQ but neither worked.  I checked to make sure ipchains was enabled and it was.

I was able to add  both ipchain commands to the dial up box with no problem.  Suggestions?

Expert Comment

ID: 2694073
Check the contents of /proc/sys/net/ipv4/ip_forward on both machines (esp the 2.200 machine).  It should be 1.  If it's 0, do

echo 1 > /proc/sys/net/ipv4/ip_forward

and see if that helps.  I don't think you should need any ipchains stuff at all at this point and kind of confuses the issue.

Author Comment

ID: 2694318
Both machines contain 1 in ip_forward.

Accepted Solution

kiffney earned 275 total points
ID: 2703891
The output of your routing tables indicates no default route at all.  So you need to either add a default route through ppp0, OR add a specific net route to the other net through ppp0.  I don't know what ipchains -MASQ might be doing, it does not appear to me that you need that at all and it might be confusing the issue - I'd disable all that and get this running with straight routing tables first.  If you did a specific net route for your samba server, you'd say

route add -net netmask dev ppp0

and your routing table would then have a line ppp0


Author Comment

ID: 2715921
Adjusted points from 200 to 275

Author Comment

ID: 2715922
I added route add -net netmask dev ppp0 to the Linux dial up.
And route add -net to the Samba server.

Was able to set Samba as a Wins server and everything worked great!  Now both sides are able to ping back and forth and see everything.


Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The purpose of this article is to demonstrate how we can upgrade Python from version 2.7.6 to Python 2.7.10 on the Linux Mint operating system. I am using an Oracle Virtual Box where I have installed Linux Mint operating system version 17.2. Once yo…
It’s 2016. Password authentication should be dead — or at least close to dying. But, unfortunately, it has not traversed Quagga stage yet. Using password authentication is like laundering hotel guest linens with a washboard — it’s Passé.
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question