Connecting two lans

Posted on 2000-04-04
Medium Priority
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 192.168.2.xxx.  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.  =)

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.


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

Cloud Training Guides

FREE GUIDES: In-depth and hand-crafted Linux, AWS, OpenStack, DevOps, Azure, and Cloud training guides created by Linux Academy instructors and the community.

Question has a verified solution.

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

1. Introduction As many people are interested in Linux but not as many are interested or knowledgeable (enough) to install Linux on their system, here is a safe way to try out Linux on your existing (Windows) system. The idea is that you insta…
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é.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
Suggested Courses
Course of the Month13 days, 2 hours left to enroll

777 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