Solved

Connecting two lans

Posted on 2000-04-04
9
226 Views
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?

----   ----   ----
|  |---|  |---|  |  <-192.168.1.200
----   ----   ----    Samba Server
 .67    .68   |      
              |  <-- Modem Connection
              |
----   ----   ----
|  |---|  |---|  |  <-192.168.1.85
----   ----   ----    Dial-up Linux Box
 .75   .76
0
Comment
Question by:mistyblue1
  • 5
  • 3
9 Comments
 
LVL 10

Expert Comment

by:rbr
Comment Utility
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 192.168.1.0/24 -d 0.0.0.0/0
0
 
LVL 4

Expert Comment

by:kiffney
Comment Utility
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 192.168.2.200, 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
0.0.0.0      *       0.0.0.0 eth0

But after, it's
0.0.0.0      *       0.0.0.0 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 192.168.1.0 netmask 255.255.255.0 dev eth0

at startup.  Then since this is no longer the magic 'default' route of 0.0.0.0, 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 192.168.2.0 netmask 255.255.255.0 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.  
0
 

Author Comment

by:mistyblue1
Comment Utility
I will try it this evening and let you know how it went.
Thanks.  =)
0
 

Author Comment

by:mistyblue1
Comment Utility
Samba Server
destination        gateway genmask               iface
 192.168.1.200  0.0.0.0    255.255.255.255  eth0
 192.168.1.0      0.0.0.0    255.255.255.0      eth0
 192.168.2.85    0.0.0.0    255.255.255.255  ppp0
 127.0.0.0          0.0.0.0    255.0.0.0              lo

Dial up Server
destination        gateway genmask               iface
 192.168.2.85    0.0.0.0    255.255.255.255  eth0
 192.168.2.0      0.0.0.0    255.255.255.0      eth0
 192.168.1.200  0.0.0.0    255.255.255.255  ppp0
 127.0.0.0          0.0.0.0    255.0.0.0              lo

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

I did try adding in ipchains -A forward -s 192.168.1.0/24 -d 0.0.0.0/0 -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?
0
Complete Microsoft Windows PC® & Mac Backup

Backup and recovery solutions to protect all your PCs & Mac– on-premises or in remote locations. Acronis backs up entire PC or Mac with patented reliable disk imaging technology and you will be able to restore workstations to a new, dissimilar hardware in minutes.

 
LVL 4

Expert Comment

by:kiffney
Comment Utility
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.
0
 

Author Comment

by:mistyblue1
Comment Utility
Both machines contain 1 in ip_forward.
0
 
LVL 4

Accepted Solution

by:
kiffney earned 275 total points
Comment Utility
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 192.68.2.0 netmask 255.255.255.0 dev ppp0

and your routing table would then have a line

192.68.2.0 0.0.0.0 255.255.255.0 ppp0

0
 

Author Comment

by:mistyblue1
Comment Utility
Adjusted points from 200 to 275
0
 

Author Comment

by:mistyblue1
Comment Utility
I added route add -net 192.168.1.0 netmask 255.255.255.0 dev ppp0 to the Linux dial up.
And route add -net 192.168.2.0 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.

Thanks!!!
0

Featured Post

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Join & Write a Comment

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…
The purpose of this article is to demonstrate how we can use conditional statements using Python.
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.

763 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now