Another routing problem

I have 3 Linux machines(Debian woody) A,B,C.
A and B are in same network.
C is in diffrent network.
I want to use B as the gateway for A for connecting to the C network.
 -------------------------------------------------
A and B are in 192.168.1.0 network
A    IPaddress -   192.168.1.2
       Netmask 255.255.255.0

B     IP address 192.168.1.1
       Netmask 255.255.255.0


C is in 192.168.0.0 network
     IP address -192.168.0.1
     Netmask      255.255.255.0

Now I want  to connect from   192.168.1.0 network to 192.168.0.0 network and vice versa.

For this In machine B I did a routing.
      route add -net 192.168.0.0 netmask 255.255.255.0  dev eth0
and in Machine C
   route add -net 192.168.1.0 netmask 255.255.255.0  dev eth0
 
  done.Now i am able to ping from machine B to C.

 No  I want to use my Machine B as Gateway for A to access the other network.
 For this In Machine A in the routing entry I added

     route add -net 192.168.0.0 netmask 255.255.255.0 gateway 192.168.1.1 dev eth0.
                     But I cud not ping or ssh to C from A .From C also I cud not ping to A .But I can access Machine B  .
Why?.Am i did anything wrong?.            
palanisaravananAsked:
Who is Participating?
 
JivkoConnect With a Mentor Commented:
da99rmd ,
There is no need of Masquerading or NAT in this situation.

echo 1 > /proc/sys/net/ipv4/conf/eth0/proxy_arp
 Enables proxy arp.

palanisaravanan ,
 Adding a two static routes on machine C :

route add 192.168.1.1 dev eth0
route add -net 192.168.1.0/24 gw 192.168.1.1

And on machine A:

route add -net 192.168.0.0/24 gw 192.168.1.1


Of cource enabling IP Forwarding on machine B is a MUST. :

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



Regards



0
 
JivkoCommented:

Why just not add a secondary IP address 192.168.0.254 for machine B?
ifconfig eth0:1 192.168.0.254 netmask 255.255.255.0

Then you can use machine B for a default GW in both networks
0
 
JivkoCommented:
And also enable IP Forwarding and Proxy Arp

echo 1 > /proc/sys/net/ipv4/ip_forward
echo 1 > /proc/sys/net/ipv4/conf/eth0/proxy_arp
0
Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

 
da99rmdCommented:
You must enable ip forwarding with
echo "1" > /proc/sys/net/ipv4/ip_forward
and add the ipmasq config with
/sbin/iptables -t nat -A POSTROUTING -o (ougoing interface name) -j MASQUERAD

all this is made on the GW machine

/Rob
0
 
da99rmdCommented:
jviko,
what does the  
echo 1 > /proc/sys/net/ipv4/conf/eth0/proxy_arp
command ?
0
 
palanisaravananAuthor Commented:
Jviko
 I don't want to use machine B as gateway for both the networks.
MY situation is
Machine B should be the gateway for all the outgoing packets sent from
Machine A to the other network i.e Machine C .
I know it is possible.It involves a bit of route command.There only I am struggling.
 
0
 
da99rmdCommented:
Yes thats true,
didnt se he was trying to route between 2 private nets :/

/Rob
0
 
da99rmdCommented:
Yes,
thats true aboute the NAT, i didnt se that he was trying to route between 2 private nets. :/

/Rob
0
 
da99rmdCommented:
:)
0
 
palanisaravananAuthor Commented:
yes!Every thing is in my private net.

Jivco!
  Thanks.But it is not working
0
 
palanisaravananAuthor Commented:
As Jivko said there is no need for NAT in my case
0
 
da99rmdCommented:
Try finding out what stops the communication beacuse it should work with the configuration jivco posted.

You dont have some kind of firewall stoping the communication.

Try running a tcpdump on each interface of the B machine and sort out the nessesary trafic perhaps with:

tcpdump -i eth(0 or 1) 'src (ip adress)'

/Rob
0
 
palanisaravananAuthor Commented:
Yeah!It is working now.I didn't do any new thing .Just i restarted my netwoking interfaces.And again start the routing configuration.It started working.Thank you guys
0
 
da99rmdCommented:
You are welcome
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.